* RFC: expand $'' within heredocs
@ 2022-09-28 20:30 Eric Cook
2022-09-28 21:19 ` Mikael Magnusson
2022-09-29 9:03 ` Jun T
0 siblings, 2 replies; 3+ messages in thread
From: Eric Cook @ 2022-09-28 20:30 UTC (permalink / raw)
To: zsh-workers
Hey all,
bash 5.2[1] recently released and a change i found of interest is allowing $'' to be expanded
within heredocs. $'' is currently the only expansion that uses the `$' operator that doesn't
expand within heredocs(even $[] does); so i can see that edgecase being confusing in addition
to the feature just being useful.
cat <<eof
hello$'\t'world
eof
...
[1] https://lists.gnu.org/archive/html/help-bash/2022-09/msg00002.html
Not to bandwagon other shells, i just like the idea.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RFC: expand $'' within heredocs
2022-09-28 20:30 RFC: expand $'' within heredocs Eric Cook
@ 2022-09-28 21:19 ` Mikael Magnusson
2022-09-29 9:03 ` Jun T
1 sibling, 0 replies; 3+ messages in thread
From: Mikael Magnusson @ 2022-09-28 21:19 UTC (permalink / raw)
To: Eric Cook; +Cc: zsh-workers
On 9/28/22, Eric Cook <llua@gmx.com> wrote:
> Hey all,
>
> bash 5.2[1] recently released and a change i found of interest is allowing
> $'' to be expanded
> within heredocs. $'' is currently the only expansion that uses the `$'
> operator that doesn't
> expand within heredocs(even $[] does); so i can see that edgecase being
> confusing in addition
> to the feature just being useful.
> cat <<eof
> hello$'\t'world
> eof
> ...
$'foo' is technically a form of quoting, not expansion, so it is
consistent the way it is now. Eg, there is no $ operator in play, the
$' together form an operator (if you want to call it that) which
begins this particular form of quotes.
% cat << EOF
"foo" 'foo' $'foo'
EOF
"foo" 'foo' $'foo'
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RFC: expand $'' within heredocs
2022-09-28 20:30 RFC: expand $'' within heredocs Eric Cook
2022-09-28 21:19 ` Mikael Magnusson
@ 2022-09-29 9:03 ` Jun T
1 sibling, 0 replies; 3+ messages in thread
From: Jun T @ 2022-09-29 9:03 UTC (permalink / raw)
To: zsh-workers
> 2022/09/29 5:30, Eric Cook <llua@gmx.com> wrote:
>
> cat <<eof
> hello$'\t'world
> eof
I think bash-5.2 does not substitute $'\t' by a TAB in this case.
Here-document is something like a string quoted by "...". All of
bash-5.1, 5.2 and zsh do not replace $'\t' by a TAB in
$ echo -E "foo$'\t'bar"
In the following example:
$ a=$'\tHello'
$ cat <<EOF
${a#$'\t'}
EOF
5.2 removes the TAB (as zsh does) and just outputs 'Hello',
while 5.1 does not remove the TAB.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-29 9:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 20:30 RFC: expand $'' within heredocs Eric Cook
2022-09-28 21:19 ` Mikael Magnusson
2022-09-29 9:03 ` Jun T
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).