Gentoo Archives: gentoo-dev

From: Roy Marples <uberlord@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: RFC: sh versionator.eclass
Date: Tue, 02 Oct 2007 17:04:11
Message-Id: 1191343930.2189.28.camel@uberlaptop.development.ltl
In Reply to: Re: [gentoo-dev] Re: RFC: sh versionator.eclass by George Shapovalov
1 On Tue, 2007-10-02 at 18:30 +0200, George Shapovalov wrote:
2 > Tuesday, 2. October 2007, Roy Marples Ви написали:
3 > > And here it is
4 > - if [[ "${FORTRANC}" = "gfortran" ]]; then
5 > + if [ "${FORTRANC}" = "gfortran" ]; then
6 >
7 > You know, it is funny to see these lines after all those cries about how [ is
8 > evil and we should really never ever use it but rather always use [[ form :).
9 >
10 > Oh, btw, does the compliant sh correctly process the most cited composition? :
11 > [ -n $foo ] && [ -z $foo ] && echo "huh?"
12 > (straight from devmanual, the primary reason why [ is considered bad)
13
14 bash and sh do the same thing
15 roy@uberlaptop ~ $ bash -c '[ -n $foo ] && [ -z $foo ] && echo "huh?"'
16 huh?
17 roy@uberlaptop ~ $ sh -c '[ -n $foo ] && [ -z $foo ] && echo "huh?"'
18 huh?
19
20 Maybe if you quoted properly it would work?
21 roy@uberlaptop ~ $ bash -c '[ -n "$foo" ] && [ -z "$foo" ] && echo
22 "huh?"'
23 roy@uberlaptop ~ $ sh -c '[ -n "$foo" ] && [ -z "$foo" ] && echo "huh?"'
24
25 By golly it does work!
26 And on both shells!
27 Amazing!
28
29 With [[ ]] you don't need to quote, which encourages people not to
30 bother learning when and when not to quote.
31
32 Regular readers of -dev will also notice a large amount of people not
33 quoting correctly, my view is that bash encourages this through the use
34 of [[ ]].
35
36 Thanks
37
38 Roy
39
40 --
41 gentoo-dev@g.o mailing list

Replies

Subject Author
[gentoo-dev] Re: Re: RFC: sh versionator.eclass Steve Long <slong@××××××××××××××××××.uk>