On Thu, Feb 12, 2004 at 01:24:07AM -0800, Paul Eggert wrote:
> > i.e. the \b is processed. This interacts very badly with
> > --program-transform-name='s/g\(.*\)/g\1-3.4/',
>
> Hmm, but your script doesn't necessarily indicate any problem with
> --program-transform-name.
>
> POSIX says that the last echo is equivalent to
>
> $ echo 'a\b'
>
> and that the results are implementation-defined, since 'echo' has
> undefined behavior if its operands contain a backslash. (On
> XSI-conformant systems, the system must print a backslash; perhaps
> that's what ash did.)
>
> --program-transform-name doesn't pass backslash to echo, so it won't
> run into that problem.
>
> For example, with POSIX you must get this behavior:
>
> $ a='a\b'
> $ expr "X$a" : 'X\(.*\)'
> a\b
That's a neat trick, I didn't know it. Is this in the shell
portability guide? Note that all --enable, --with, and A=B options are
passed through echo and sed, at least as of the latest version I have
installed.
My comment was based on a previous version of autoconf which passed
ac_optarg to echo; I see that this was fixed in June 2000, so I suppose
I must have been looking at a very old version. I thought I'd
double-checked with 2.57 at the time but I suppose not. Oh, wait, here
it is, in _AC_INIT_PREPARE:
case $ac_arg in
...
dnl If you change this globbing pattern, test it on an old shell --
dnl it's sensitive. Putting any kind of quote in it causes syntax errors.
[ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)]
ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
So subdirs get corrupted --program-transform-name. There are plenty of
other instances, even this jewel with a wildly incorrect comment:
# Double any \ or $. echo might interpret backslashes.
# By default was `s,x,x', remove it if useless.
cat <<\_ACEOF >conftest.sed
s/[\\$]/&&/g;s/;s,x,x,$//
_ACEOF
program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
rm conftest.sed
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer