On 12/14/24 8:30 AM, Rob Landley wrote:
In devuan deadmaus, which claims bash --version 5.2.15(1)-release (x86_64- pc-linux-gnu) when I do:

echo -e 'echo \n' | env -i PATH=${PATH@Q} PS1='\\$ ' bash --noediting -- noprofile --norc -is

It prints $ three times instead of printing \$ three times. But when I add -c 'echo $PS1' it says "\\$" which has both slashes. (Which makes sense because single quotes, above...)
\\
The man page says \\ is a literal backslash, but it's not printing.

OK, think about this in terms of all the expansions for PS1.

First, it expands \\$ because of the \\ prompt expansion, leaving \$
when that phase is complete.

Then, after expanding the backslash-escape sequences,

"After the  string  is
 decoded,  it is expanded via parameter expansion, command substitution,
 arithmetic expansion, and quote removal, subject to the  value  of  the
 promptvars shell option"

Since promptvars is enabled by default, quote removal removes the
backslash, leaving `$ '.

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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to