bug-coreutils
[Top][All Lists]
Advanced

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

bug#22216: test, expr Operator Precedence and Associativity


From: Eric Blake
Subject: bug#22216: test, expr Operator Precedence and Associativity
Date: Mon, 21 Dec 2015 17:05:09 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 12/21/2015 05:00 PM, 積丹尼 Dan Jacobson wrote:
> OK. Also make sure (info "(coreutils) test invocation") makes it clear that
> one cannot use
> test -f $1 -a $1 ! -ot $2 #and must use
> test -f $1 -a ! $1 -ot $2 #.

Use of -a in test is inherently non-portable.  POSIX even says so -
there are some expressions which are completely ambiguous when you
attempt to use -a or -o.

Also, your lack of quoting is a classic pitfall for how to incorrectly
use test.

Better than what you typed would be using:

test -f "$1" && test ! "$1" -ot "$2"

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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