[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cleanup initialization of configure process (issue 549350043 by addr
From: |
dak |
Subject: |
Re: Cleanup initialization of configure process (issue 549350043 by address@hidden) |
Date: |
Thu, 16 Jan 2020 05:24:21 -0800 |
On 2020/01/16 11:22:24, hahnjo wrote:
On 2020/01/16 10:57:46, dak wrote:
> https://codereview.appspot.com/549350043/diff/545440043/configure.ac
> File configure.ac (right):
>
>
https://codereview.appspot.com/549350043/diff/545440043/configure.ac#newcode8
> configure.ac:8: [m4_esyscmd([. ${SRCDIR:-.}/VERSION; echo -n
> $MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL])],
> The proposal using m4_esyscmd_s allowed to use echo without -n
option (which
is
> a bit of a portability thing). Was there a reason not to take it?
I didn't notice that you changed this and just took the changes with
SRCDIR. But
is there an actual advantage of using m4_esyscmd_s?
The bit of a portability thing? From the autoconf documentation:
'echo'
The simple 'echo' is probably the most surprising source of
portability troubles. It is not possible to use 'echo' portably
unless both options and escape sequences are omitted. Don't expect
any option.
Do not use backslashes in the arguments, as there is no consensus
on their handling. For 'echo '\n' | wc -l', the 'sh' of Solaris
outputs 2, but Bash and Zsh (in 'sh' emulation mode) output 1. The
problem is truly 'echo': all the shells understand ''\n'' as the
string composed of a backslash and an 'n'. Within a command
substitution, 'echo 'string\c'' will mess up the internal state of
ksh88 on AIX 6.1 so that it will print the first character 's'
only, followed by a newline, and then entirely drop the output of
the next echo in a command substitution.
Because of these problems, do not pass a string containing
arbitrary characters to 'echo'. For example, 'echo "$foo"' is safe
only if you know that FOO's value cannot contain backslashes and
cannot start with '-'.
If this may not be true, 'printf' is in general safer and easier to
use than 'echo' and 'echo -n'. Thus, scripts where portability is
not a major concern should use 'printf '%s\n'' whenever 'echo'
could fail, and similarly use 'printf %s' instead of 'echo -n'.
For portable shell scripts, instead, it is suggested to use a
here-document like this:
cat <<EOF
$foo
EOF
Alternatively, M4sh provides 'AS_ECHO' and 'AS_ECHO_N' macros which
choose between various portable implementations: 'echo' or 'print'
where they work, 'printf' if it is available, or else other
creative tricks in order to work around the above problems.
https://codereview.appspot.com/549350043/
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), (continued)
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), jonas . hahnfeld, 2020/01/14
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), nine . fierce . ballads, 2020/01/14
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), nine . fierce . ballads, 2020/01/14
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), jonas . hahnfeld, 2020/01/15
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), jonas . hahnfeld, 2020/01/15
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), jonas . hahnfeld, 2020/01/16
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), dak, 2020/01/16
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), jonas . hahnfeld, 2020/01/16
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden),
dak <=
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), nine . fierce . ballads, 2020/01/17
- Re: Cleanup initialization of configure process (issue 549350043 by address@hidden), jonas . hahnfeld, 2020/01/17