Liste des Groupes | Revenir à cu shell |
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_04
Nor is the 'printf' utility:
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/printf.html#tag_20_96
and 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_04
However, 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.
Les messages affichés proviennent d'usenet.