bug-bash
[Top][All Lists]
Advanced

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

Re: Bash-5.2-alpha available


From: Robert Elz
Subject: Re: Bash-5.2-alpha available
Date: Tue, 25 Jan 2022 01:51:18 +0700

    Date:        Mon, 24 Jan 2022 12:03:39 -0500
    From:        Chet Ramey <chet.ramey@case.edu>
    Message-ID:  <3aeb9d02-b134-216f-6d11-921e42941522@case.edu>

  | Except it's not unconditional. You have to accommodate ${x#$'value'} in
  | the here-document expansion path because "${x#$'value'}" is processed for
  | escape sequences. You're right that it should not be treated differently,
  | but it's not as simple as leaving $'...' and $"..." unmodified.

Quite correct, here docs (with unquoted delim word on the redirect operator)
are read exactly the same as double-quoted strings (except " is just a 
character, nothing special at all, including \" resulting in 2 chars, not one).

>From a non-bash sh ...

$ x=abcdef
$ cat <<EOF
${x#$'abc'}
EOF
def
$ 

No escape chars used there, but if they had been, they would have worked,
as the word after the # (or % and ## %% of course) is parsed in its own
quoting context, regardless of what the context is of the overall expansion.

And, of course:

$ cat <<EOF
$'abc'
EOF
$'abc'
$ 

I should have changed PS1 away from being '$ ' I guess, let me do those
two again with PS1='<%> ' just to avoid any ambiguity...

$ PS1='<%> '
<%> cat <<EOF
${x#$'abc'}
EOF
def
<%> cat <<EOF
$'abc'
EOF
$'abc'
<%> 

(I didn't bother to repeat the initialisation of x - nothing changed it).

kre




reply via email to

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