[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grep-2.9.69-f91c on OSF/1
From: |
Stefano Lattarini |
Subject: |
Re: grep-2.9.69-f91c on OSF/1 |
Date: |
Sat, 12 Nov 2011 17:21:24 +0100 |
User-agent: |
KMail/1.13.7 (Linux/2.6.30-2-686; KDE/4.6.5; i686; ; ) |
On Saturday 12 November 2011, Jim Meyering wrote:
> Stefano Lattarini wrote:
> > This might cause annoying slow-downs on systems where forks are more
> > expensive (i.e., MinGW and Cygwin). What about doing something like
> > this instead, so that the extra forks are avoided when the shell is
> > Bash (as is the usual case under MinGW and Cygwin, if I'm not
> > mistaken):
> >
> > if test -n "$BASH_VERSION"; then
> > export_with_values () { export "$@"; }
> > else
> > export_with_values () { ... your implementation here ... }
> > fi
> >
> > My testing shows that this idiom should work with at least bash 4.1,
> > 3.2, 3.0, 2.05 and 2.0.
>
> I like the idea but prefer to test for the precise feature being replaced.
> Then we don't even penalize those who use dash or zsh.
>
Or you could do this, to shave off the extra fork on MinGW and Cygwin:
> It is tricky, due to the brokenness of Solaris' /bin/sh, but as we
> learned via init.sh, you have to eval the test in a sub-shell:
>
> if (eval "export v=x") 2>/dev/null; then
> export_with_values () { export "$@"; }
> else
> export_with_values () { ... Bruno's implementation here ... }
> fi
>
Or you could do this, to shave off the extra fork on MinGW and Cygwin:
if test -n "$BASH_VERSION" || (eval "export v=x") 2>/dev/null; then
export_with_values () { export "$@"; }
else
export_with_values () { ... Bruno's implementation here ... }
BTW, autoconf does similar optimizations; for example, when looking for
a portable "echo-like" command, `configure' does:
if test -z "$BASH_VERSION$ZSH_VERSION" \
&& (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
...
Regards,
Stefano
- Re: grep-2.9.69-f91c on OSF/1, (continued)
- Re: grep-2.9.69-f91c on OSF/1, Jim Meyering, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1, Jim Meyering, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1, Bruno Haible, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1, Stefano Lattarini, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1, Bruno Haible, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1, Stefano Lattarini, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1, Jim Meyering, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1,
Stefano Lattarini <=
- Re: grep-2.9.69-f91c on OSF/1, Jim Meyering, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1, Stefano Lattarini, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1, Jim Meyering, 2011/11/12
- Re: grep-2.9.69-f91c on OSF/1, Jim Meyering, 2011/11/12
grep-2.9.69-f91c testing, Bruno Haible, 2011/11/11