On 01/12/2012 05:25 PM, Karl Berry wrote:
> Hi Eric, Jim,

Hello, and thanks for revisiting this.

>     > echo '\input texinfo.tex @bye' >txiversion.tex
>     Ouch - this is a non-portable use of echo.  You CANNOT expect backslashes
>     to make it through echo, but should use printf instead.
> 
> Excuse my skepticism, but on what platform(s) does echo '\i' fail to
> pass the \?

Hmm, I guess you have a point.  Dash is a classic example of a shell
where echo eats backslash, but it only does so when it recognizes the
escape sequence, and \i is not a common escape sequence.  Still, better
safe than sorry by avoiding the potential portability trap in the first
place.

$ dash -c 'echo "\\r"' | od -tx1z
0000000 0d 0a                                            >..<
0000002
$ dash -c 'echo "\\i"' | od -tx1z
0000000 5c 69 0a                                         >\i.<
0000003

> 
> Thanks for reporting that, Jim.  Looks to me like it was breakage
> unknowingly introduced by someone "forcing" me to use set -e.  (Aside:
> curmudgeon that I am, I hate set -e, even though everyone else seems to
> love it.  Just seen so many warts introduced to placate it.  Like this
> one.  Sigh.)

I also hate set -e.  So many shells have buggy implementations of it;
and even if they had the same semantics, it tends to be unintuitive,
especially when mixed with shell functions.  That's why autoconf does
NOT use it.

> 
>     if (
>       ...
>       printf %s\\n '\input texinfo.tex @bye' > txiversion.tex
>       $TEX txiversion.tex </dev/null >txiversion.out 2>txiversion.err
>     ); then
> 
> Ok, I munged that into place, thanks Eric.  Hope if (...) is portable
> (in reality) as an if condition.  Never tried that before.

Yes, that's quite portable.  if has always taken _any_ command,
including a subshell, as its condition.

-- 
Eric Blake   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to