Sujet : Re: How to convert <binaryGlowMixedWithASCII> to pure ASCII
De : flexibeast (at) *nospam* gmail.com (Alexis)
Groupes : comp.unix.shellDate : 15. May 2025, 07:08:19
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <87wmaixv70.fsf@gmail.com>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Gnus/5.13 (Gnus v5.13)
Janis Papanagnou <janis_papanagnou+
ng@hotmail.com> writes:
Concerning portability the question in the first place is IMO what to
do with those '\u....' . - I don't think this is standard, or is it?
>
So if it's non-standard we could use arbitrary common but non-standard
shell features.
>
Like the shell built-in 'printf' without $'...' to use just '...'.
Or IMO best just the already suggested ANSI strings var=$'...' .
The 'echo' utility as specified by the current version of POSIX,
POSIX-1.2024, isn't required to support the '\u...' sequence:
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/echo.html#tag_20_37_04Nor is the 'printf' utility:
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/printf.html#tag_20_96and OpenBSD Ksh doesn't support using that sequence in an argument to
its 'echo' builtin.
Additionally, this version of POSIX added dollar-single quotes to the
standard:
A sequence of characters starting with a <dollar-sign> immediately
followed by a single-quote ($') shall preserve the literal value of
all characters up to an unescaped terminating single-quote (')
--
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_02_04However, although it's supported by Bash, ATT Ksh, and Zsh, it doesn't
seem to be supported by Dash (as of version 0.5.12):
$ eg=$'\n'
$ printf '%s' "${eg}" | od -c
0000000 $ \ n
0000003
$
or by OpenBSD Ksh (as of the version included in OpenBSD 7.6; not sure
about its status in 7.7):
$ eg=$'\n'
$ printf '%s' "${eg}" | od -c
0000000 $ \ n
0000003
$
(i should probably add a table about this to a page on the Gentoo wiki
that i've been slowly working on,
https://wiki.gentoo.org/wiki/Shell/Scripting )
Alexis.