[Top][All Lists]
[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: |
Sun, 23 Nov 2008 07:26:41 -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/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 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
iEYEARECAAYFAkkpaCEACgkQ84KuGfSFAYAiKwCcCiuwIlxSv7qI7fhpLNnGB5R5
gzMAn2zjMeQxPs2liMcCc4xJTbQBlU9a
=7sSU
-----END PGP SIGNATURE-----
- Re: [PATCH 6/6] use print or printf or cat as $ECHO, (continued)
- Re: [PATCH 6/6] use print or printf or cat as $ECHO, Paolo Bonzini, 2008/11/10
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Paolo Bonzini, 2008/11/10
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Ralf Wildenhues, 2008/11/10
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Paolo Bonzini, 2008/11/10
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Ralf Wildenhues, 2008/11/11
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Ralf Wildenhues, 2008/11/22
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Paolo Bonzini, 2008/11/22
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Eric Blake, 2008/11/22
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Eric Blake, 2008/11/22
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Ralf Wildenhues, 2008/11/23
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really),
Eric Blake <=
- Re: [PATCH 6/6] use print or printf or cat as $ECHO (really), Ralf Wildenhues, 2008/11/23
- Re: [PATCH 6/6] use print or printf or cat as $ECHO, Eric Blake, 2008/11/10
- Re: [PATCH 6/6] use printf as $ECHO, Eric Blake, 2008/11/10
- Re: [PATCH 6/6] use printf as $ECHO, Ralf Wildenhues, 2008/11/10
- Re: [PATCH 6/6] use printf as $ECHO, Sven Mascheck, 2008/11/10
- Re: [PATCH 6/6] use printf as $ECHO, Ralf Wildenhues, 2008/11/11