bug-bash
[Top][All Lists]
Advanced

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

Re: Bug with 'test' built-in.


From: mwoehlke
Subject: Re: Bug with 'test' built-in.
Date: Thu, 10 Aug 2006 10:32:15 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.5) Gecko/20060719 Thunderbird/1.5.0.5 Mnenhy/0.7.4.0

John Wenker wrote:
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H -D_GNU_SOURCE -I. -I. -I./include -I./lib -O2 -march=i386 -mcpu=i686 uname output: Linux ragtop 2.4.18-3 #1 Thu Apr 18 07:32:41 EDT 2002 i686 unknown
Machine Type: i686-pc-linux-gnu

Bash Version: 2.05a

And despite this version being ancient, I'll point out that I can reproduce (assuming this isn't a case of wrong syntax) on "3.00.15(1)-release" (whatever that is; came with FC4) and 3.1.17 built from sources.

To venture a guess, it seems like '-a' is being parsed as 'and' in this case, rather than the test for file existence.

Patch Level: 0
Release Status: release

Description:
        There is a problem using '!' (boolean negation) with the -a flag
      of the 'test' built-in command.  The following construct
      _always_ evaluates true, regardless of whether the file exists
      or not.

         if [ ! -a file ]; then
            echo "This line always prints no matter what."
         else
            echo "This line never prints."
         fi

      Using -a w/o the negation works fine.

--
Matthew
vIMprove your life! Now on version 7!





reply via email to

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