Re: Bash' code to store string of any characters containing pair of "" a
From:
Greg Wooledge
Subject:
Re: Bash' code to store string of any characters containing pair of "" and '' at once
Date:
Sat, 21 Dec 2024 19:47:31 -0500
User-agent:
Mutt/1.10.1 (2018-07-13)
On Sun, Dec 22, 2024 at 07:29:14 +0700, Robert Elz wrote:
> Date: Sat, 21 Dec 2024 13:49:48 -0500
> From: Greg Wooledge <greg@wooledge.org>
> Message-ID: <20241221184948.GM29532@wooledge.org>
>
> | Choice #2: use $'...' quoting,
> | Choice 2 is a bash extension.
>
> No it isn't, or at least not any more. Dollar-Quote quoting (sometimes
> called C-stye strings) is in the latest POSIX standard.
OK, it may be part of the official standard now, but that version of
the standard *just* came out this year. I wouldn't expect it to be
anywhere close to universal adoption for a couple years. That's about
how long it takes to roll out new versions of system software in
production enviroments.
hobbit:~$ dpkg -l dash | tail -n1
ii dash 0.5.12-2 amd64 POSIX-compliant shell
hobbit:~$ dash
$ x=$'hi\tmom'; printf %s\\n "$x"
$hi\tmom
Debian 13 will probably come out next year. Maybe that version of Debian
will have a dash shell with this feature added. Maybe it won't; I haven't
checked the changelogs.
Either way, it's not widespread yet, and one shouldn't expect it to be
available outside of bash.