bug-bash
[Top][All Lists]
Advanced

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

Re: Test exit status misinterpreted in scripts when buit without job con


From: Chet Ramey
Subject: Re: Test exit status misinterpreted in scripts when buit without job control
Date: Thu, 4 Aug 2016 14:36:37 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 8/4/16 12:05 PM, Dan Cross wrote:

> Bash Version: 4.3
> Patch Level: 30
> Release Status: release
> 
> Description:
>         When bash is built without job control, shell scripts that use
>         the 'test' builtin (e.g., via '[') in conditionals may take the
>         wrong branch becuase the exit status of the test is lost.
> 
> Repeat-By:
>         Configure without job control.  Via e.g.,
>         ./configure --prefix=/usr --bindir=/bin --without-bash-malloc 
> --disable-nls --disable-job-control
>         Invoke the resulting shell and run the following sequence of commands:
> 
>         $ cat > foo.sh
>         if [ $# -lt 2 ]
>         then
>                 echo "$# args is less than 2"
>         else
>                 echo "$# args is not less than 2"
>         fi
>         $ chmod +x ./foo.sh
>         $ ./foo.sh 1 2 3 4
>         4 args is less than 2
>         $
> 
>         Observe the output: '4' is not actually less than '2' yet the
>         script incorrectly reports it as such.

Thanks for the report.  I took a quick look at this, and it's not disabling
job control that does it: it's disabling both job control and nls.
Disabling either one while leaving the other enabled doesn't produce this
error (which only happens in the case where you run a script with the
execute bit set without a #! line after running an executable that causes
the shell to call waitpid()).  It's a strange set of circumstances.
I'll see what I can find.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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