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

According to Ralf Wildenhues on 11/23/2008 1:10 AM:
>> At least we can hard-code the fact that ZSH_VERSION or
>> BASH_VERSION implies a builtin printf, to skip the forks on those shells.
> 
> You mean like this?
> Are we certain enough no bash or zsh version has problems with a long
> format string?

I'm not certain they are bug-free on all possible formats (for example,
printf %100000s\\n), but for our usage, they do just fine on long strings
where Solaris /bin/printf does not.

> +  test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || {
> +    
> ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
> +    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
> +    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
> +    ( PATH=/empty FPATH=/empty; export PATH FPATH
> +      test "X`printf %s $ECHO`" = "X$ECHO" ) }])])

Still not enough.  Solaris /bin/sh correctly fails this test.  However,
because we did not check for print, Solaris ksh _also_ fails the test, and
we end up wrongly favoring /bin/sh, even though it lacks a builtin.  On
Solaris, we _want_ to choose ksh over /bin/sh, because builtin print is
faster than the here-doc fallback used in /bin/sh.  I think the last line
has to be:

   ( PATH=/empty FPATH=/empty; export PATH FPATH
     test "X`printf %s $ECHO`" = "X$ECHO" \
       || test "X`print -r -- $ECHO`" = "X$ECHO" ) }])])

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

Eric Blake             [EMAIL PROTECTED]
-----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

iEYEARECAAYFAkkpaCEACgkQ84KuGfSFAYAiKwCcCiuwIlxSv7qI7fhpLNnGB5R5
gzMAn2zjMeQxPs2liMcCc4xJTbQBlU9a
=7sSU
-----END PGP SIGNATURE-----


Reply via email to