bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: archive generated by shar -V does not support the -c option]


From: Paul Eggert
Subject: Re: archive generated by shar -V does not support the -c option]
Date: Sat, 28 Aug 2010 22:52:55 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6

On 08/28/2010 05:17 PM, Ralf Wildenhues wrote:

> AFAIK it's strict left-to-right evaluation in both cases.  The caveat is
> that no programmer expects that evaluation order

I guess Steve Bourne thought it was simpler that way.  And it
is indeed portable: all Bourne-like shells have done it that
way since the late 1970s, as far as I know.  The style
(a && b && c || d) is fairly common in some scripts.  The other form
(a || b || c && d) is (1) less useful and (2) more
confusing to programmers who expect && to bind more
tightly than ||, so I'd stay away from it.

For this particular example I'd suggest replacing this:

        test "X$1" = "X-c" && keep_file=false || keep_file=true

with this:

        option=$1

and this:

        if test -f %s && ${keep_file}; then

with this:

        if test "X$option" = "X-c" && test -f %s; then

This is a tad simpler and will save a file access when -c is absent.



reply via email to

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