libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/6] use print or printf or cat as $ECHO (really)


From: Eric Blake
Subject: Re: [PATCH 6/6] use print or printf or cat as $ECHO (really)
Date: Sat, 22 Nov 2008 07:31:10 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18) Gecko/20081105 Thunderbird/2.0.0.18 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Ralf Wildenhues on 11/22/2008 6:57 AM:
> I propose two alternative patches to fix these issues.  Both, as the
> code before the patch, assume that `test' is a built-in command.  Yuck.

But reasonably safe; per http://www.in-ulm.de/~mascheck/bourne/, all
System III shells provide this.

> +  PATH=/empty FPATH=/empty test "X`printf %s $ECHO`" = "X$ECHO"])])

Your attempt to modify PATH in-place won't work.  Even with bash 3.2:

$ foo=bar echo `env | grep foo`
$

In other words, although echo sees the altered $foo, the `` subshell does not.

> +  ( PATH=/empty FPATH=/empty; export PATH FPATH
> +    test "X`printf %s $ECHO`" = "X$ECHO" )])])

Yes, that looks more portable (even if it is slower).

But do we even need to _AS_DETECT_SUGGEST for a working builtin printf?
As long as we search for 'print -r' before 'printf', we are either
guaranteed to find the working builtin variant, or we end up resorting to
forking no matter which alternative we choose.  The primary use case where
this will help is with Solaris /bin/sh, which lacks both builtins, so we
really _do_ want to suggest a shell that is more likely to provide a
builtin.  But on a Solaris machine, ksh fails the suggested test (it lacks
builtin printf), so ksh is not determined to be better than /bin/sh, and
you end up running with /bin/sh and forking for every $ECHO anyway.

Maybe a better suggested test would be one that checks for either print or
printf (that way, a Solaris machine will let ksh pass the suggested test).
   Since the overall test is running with stderr silenced, we don't even
have to worry about messages about command not found.  In other words, why
not:

_AS_DETECT_SUGGESTED([
ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
test "X`print -r -- $ECHO`" = "X$ECHO" \
 || test "X`printf %s $ECHO`" = X$ECHO"])

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkoF64ACgkQ84KuGfSFAYAGRgCeM3rJDiTmFgdSSOu74dwNqpd+
CmkAnR++b8sDGKRxrWW+ovGcgZqcCJoU
=GuTz
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]