bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Comparison failure


From: Chet Ramey
Subject: Re: Comparison failure
Date: Fri, 11 Jan 2008 20:46:30 -0500
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)

Dave Rutherford wrote:

I know test's quirks.  Does [[ have quirks?  Are they the same?
Is there room in my grey matter to hold both sets of quirks
and keep them straight?

[[ was designed to remedy test's quirks, so it shouldn't really have
any of its own.  In addition to the functionality provided by the
new operators and extended matching there is:

1.  a more regular grammar, including operator short-circuiting and
    better parsing ( [[ -f ]] is an error, for instance; and
    [[ -f = ]] doesn't throw an error like the system v test)

2.  no word splitting or pathname expansion performed on arguments --
    each argument ends up as a single word

3.  parameter and variable expansion is more convenient, since [[ is
    not a command invoked after all expansions a performed.  The intent
    is to eliminate the need for excessive quoting:  [[ -n $n ]] and
    [ -n $n ] behave differently when `n' is unset or null; [ requires
    quoting arguments but even that isn't sufficient in all cases

Since [[ was new and had a single specification, the intent was that
users would not have to deal with the portability problems inherent in
the different historical test implementations (Dave Korn implemented it
in the pre-Posix era, remember).

Posix tried to fix some of test's shortcomings within the constraint
of leaving it a builtin command, mostly by defining the behavior based
on the number of arguments and specifying some operator precedence,
but [[ still has its advantages.  That means that test is more portable
than [[, of course.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]