bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is it a bug that \e's dont get escaped in declare -p output


From: Chet Ramey
Subject: Re: is it a bug that \e's dont get escaped in declare -p output
Date: Wed, 17 Mar 2021 18:15:18 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 3/17/21 4:04 PM, Greg Wooledge wrote:
On Wed, Mar 17, 2021 at 09:58:24PM +0200, Ilkka Virta wrote:
On Wed, Mar 17, 2021 at 8:26 PM Greg Wooledge <greg@wooledge.org> wrote:

I thought, for a moment, that bash already used $'...' quoting for
newlines, but it turns out that's false.  At least for declare -p.
It would be nice if it did, though.  Newlines, carriage returns, escape
characters, etc.


It does in some cases:

  $ a=($'new \n line' $'and \e esc'); declare -p a
declare -a a=([0]=$'new \n line' [1]=$'and \E esc')

But not for string variables, it seems.

unicorn:~$ unset a b; a=($'x\ny') b=$'c\nd'; declare -p a b
declare -a a=([0]=$'x\ny')
declare -- b="c
d"

It would be nice if the string variables were handled the same way as
the array elements.

This is not unreasonable.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]