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: Léa Gris
Subject: Re: is it a bug that \e's dont get escaped in declare -p output
Date: Wed, 17 Mar 2021 21:17:45 +0100
User-agent: Telnet/1.0 [tlh] (PDP11/DEC)

Le 17/03/2021 à 20:58, Ilkka Virta écrivait :
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')


I'd expect bash to escape any character not in the POSIX [:print:] class.

Although this is just a question of QOL improvement, since the produced declare statement just works as-is. It is not user friendly but code friendly and compact if you use the declare -p foo bar baz >savedvars.sh for later include savedvars.sh

--
Léa Gris

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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