Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Aug 2006 13:20:29 GMT
From:      Maxim Konovalov <maxim@macomnet.ru>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/102184: the -n switch of the test command does not work
Message-ID:  <200608171320.k7HDKTN9009822@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

The following reply was made to PR bin/102184; it has been noted by GNATS.

From: Maxim Konovalov <maxim@macomnet.ru>
To: Florian Meister <florian.meister@medienhaus.at>
Cc: bug-followup@freebsd.org
Subject: Re: bin/102184: the -n switch of the test command does not work
Date: Thu, 17 Aug 2006 17:19:08 +0400 (MSD)

 On Thu, 17 Aug 2006, 15:07+0200, Florian Meister wrote:
 
 > maybe a shell problem - what shell do you use ?
 
 /bin/sh
 
 > when I do the following I can also reproduce the error:
 >
 > --snip--
 > tpextu02# set testvar="lala"; [ -f $lala ]; echo $?
 > 1
 > tpextu02# set testvar="" ; [ -f $lala ] ; echo $?
 > 1
 > tpextu02# [ -f "lala" ] ; echo $?
 > 1
 > tpextu02# [ -f "" ] ; echo $?
 > 1
 
 I see no problems in the tests above.
 
 -f file       True if file exists and is a regular file.
 
 But I don't undestand how it correlates with the -n flag.  Could you
 elaborate?
 
 > bye, florian
 >
 > Maxim Konovalov wrote:
 > > Hi Florian,
 > >
 > > [...]
 > > > > Description:
 > > >  test -n does not work. I always get a return code of zero, no
 > > >  matter if the variable has zero or more characters. I
 > > >  crosschecked it with the -z switch. This switch works with the
 > > >  same test-script.
 > >
 > > Works for me:
 > >
 > > $ /bin/test -n "aa"; echo $?
 > > 0
 > > $ /bin/test -n ""; echo $?
 > > 1
 > > $ export n="aa"; /bin/test -n "$n"; echo $?
 > > 0
 > > $ export n=""; /bin/test -n "$n"; echo $?
 > > 1
 > >
 > > > > How-To-Repeat:
 > > > sample shell script:
 > > > --snip--
 > > > jail_interface="lala"
 > > > if [ -n ${jail_interface} ]; then
 > > >                         echo "interface: -$jail_interface-"
 > > >                 fi
 > > > --snap--
 > > >
 > > > try to replace the variable jail_interface with nothing - same
 > > > result. If you replace -n with -z you get the expected results.
 > >
 >
 >
 
 -- 
 Maxim Konovalov



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608171320.k7HDKTN9009822>