Gentoo Archives: gentoo-user

From: Pandu Poluan <pandu@××××××.info>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] "/usr/bin/[" and coreutils
Date: Tue, 08 Nov 2011 06:03:18
Message-Id: CAA2qdGX+ej080ZsvguuCjB_qhLWZZT2y2g4EWJoVZ62Wm3d7Mw@mail.gmail.com
In Reply to: Re: [gentoo-user] "/usr/bin/[" and coreutils by "Claudio Roberto França Pereira"
1 On Nov 8, 2011 9:02 AM, "Claudio Roberto França Pereira" <spideybr@×××××.com>
2 wrote:
3 >
4 > What about [[? I've seen scripts using [[ instead of only one [. Whats
5 the point/difference?
6
7 AFAIK [[ was originally a bash-specific built-in command that provides more
8 functionality than /bin/[, but can still use /bin/['s convoluted syntax.
9
10 The two converged quickly, though. IIRC [ is now also a bash built-in,
11 which still maintains compatibility with /bin/[
12
13 An example:
14
15 [ $VAR ] will produce an error if VAR is empty or unset, but [[ $VAR ]]
16 won't.
17
18 (for the former, you have to put double quotes around, e.g., [ "$VAR"] )
19
20 Rgds,

Replies

Subject Author
Re: [gentoo-user] "/usr/bin/[" and coreutils Pandu Poluan <pandu@××××××.info>