bug-bash
[Top][All Lists]
Advanced

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

Re: test with -z switch fails with Debian Linux


From: Bob Proulx
Subject: Re: test with -z switch fails with Debian Linux
Date: Fri, 21 Dec 2007 15:24:54 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

John Moore wrote:
>     I'm not sure if this is an issue or not, but the bash test with the -z
> switch appears to be broken. This code came from the Unix Hacks book I
> believe and it used to work:

Look closely and see if there is a missing '$' sign in the example.

>         ffind (){
>         FILELIST="/root/filelist.txt"
>         PATTERN="$1"
>         if [ -z "PATTERN" ]; then

The -z tests if the string is non-zero in length.  "PATTERN" is a
static string and will always be non-zero in length.  Therefore the
test for -z "PATTERN" will always be true.  You almost certainly
wanted "$PATTERN" there so as to get the "$1" value assigned to it in
the previous line.

Bob




reply via email to

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