From root@tpextu02.tele.net  Thu Aug 17 11:28:04 2006
Return-Path: <root@tpextu02.tele.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9CF0116A4DA
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 17 Aug 2006 11:28:04 +0000 (UTC)
	(envelope-from root@tpextu02.tele.net)
Received: from tpextu02.tele.net (tpextu02.tele.net [194.208.104.60])
	by mx1.FreeBSD.org (Postfix) with ESMTP id DFE5043D64
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 17 Aug 2006 11:28:00 +0000 (GMT)
	(envelope-from root@tpextu02.tele.net)
Received: from tpextu02.tele.net (localhost [127.0.0.1])
	by tpextu02.tele.net (8.13.6/8.13.6) with ESMTP id k7HBRvFZ088299;
	Thu, 17 Aug 2006 13:27:57 +0200 (CEST)
	(envelope-from root@tpextu02.tele.net)
Received: (from root@localhost)
	by tpextu02.tele.net (8.13.6/8.13.6/Submit) id k7HBRtWx088298;
	Thu, 17 Aug 2006 13:27:55 +0200 (CEST)
	(envelope-from root)
Message-Id: <200608171127.k7HBRtWx088298@tpextu02.tele.net>
Date: Thu, 17 Aug 2006 13:27:55 +0200 (CEST)
From: Florian Meister <florian.meister@medienhaus.at>
Reply-To: Florian Meister <florian.meister@medienhaus.at>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Florian Meister <florian.meister@medienhaus.at>
Subject: the -n switch of the test command does not work
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         102184
>Category:       bin
>Synopsis:       the -n switch of the test command does not work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 17 11:30:13 GMT 2006
>Closed-Date:    Thu Aug 17 13:48:24 GMT 2006
>Last-Modified:  Thu Aug 17 13:50:19 GMT 2006
>Originator:     Florian Meister
>Release:        FreeBSD 6.1-RELEASE amd64
>Organization:
Teleport Consulting and Systemmanagement GmbH
>Environment:
System: FreeBSD tpextu02.tele.net 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May 7 04:15:57 UTC 2006 root@bloom.cse.buffalo.edu:/usr/obj/usr/src/sys/SMP amd64


>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.
>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.
>Fix:
>Release-Note:
>Audit-Trail:

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 16:56:16 +0400 (MSD)

 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

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

 maybe a shell problem - what shell do you use ?
 
 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
 --snap--
 
 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.
 > 

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

 sorry - typo ... i used -f ...
 
 > maybe a shell problem - what shell do you use ?
 > 
 > 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
 > --snap--
 > 
 > bye, florian
 > 
 

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

 Hi Maxim,
 
 Maxim Konovalov wrote:
 > [...]
 >>> 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
 > 
 
 what about that:
 --snip--
 tpextu02# set testvar="lala" ; [ -n $testvar ] ; echo $? ; echo $testvar
 0
 lala
 tpextu02# set testvar="" ; [ -n $testvar ] ; echo $? ; echo $testvar
 0
 
 --snap--
 
 I have printed out the $testvar at the end to ensure the the variable is 
 set correctly.

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

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:21:39 +0400 (MSD)

 On Thu, 17 Aug 2006, 15:16+0200, Florian Meister wrote:
 
 > Hi Maxim,
 >
 > Maxim Konovalov wrote:
 > > [...]
 > > > > 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
 > >
 >
 > what about that:
 > --snip--
 > tpextu02# set testvar="lala" ; [ -n $testvar ] ; echo $? ; echo $testvar
 > 0
 > lala
 > tpextu02# set testvar="" ; [ -n $testvar ] ; echo $? ; echo $testvar
 > 0
 >
 > --snap--
 >
 > I have printed out the $testvar at the end to ensure the the variable is set
 > correctly.
 
 > set testvar="lala" ; [ -n "$testvar" ] ; echo $? ; echo $testvar
 0
 lala
 > set testvar="" ; [ -n "$testvar" ] ; echo $? ; echo $testvar
 1
 
 
 -- 
 Maxim Konovalov

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

 hi maxim,
 
 >> set testvar="lala" ; [ -n "$testvar" ] ; echo $? ; echo $testvar
 > 0
 > lala
 >> set testvar="" ; [ -n "$testvar" ] ; echo $? ; echo $testvar
 > 1
 
 okay I see, but then there is a bug in the /etc/rc.d/jail script at line 
 167:
 
 --snip--
 if [ -n ${jail_interface} ]; then
     ifconfig ${jail_interface} alias ${jail_ip} netmask 255.255.255.255
 fi
 --snap--
 
State-Changed-From-To: open->closed 
State-Changed-By: maxim 
State-Changed-When: Thu Aug 17 13:47:30 UTC 2006 
State-Changed-Why:  
The bug in /etc/rc.d/jail was fixed some time ago.  test -n works 
as expected. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102184 

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:41:46 +0400 (MSD)

 On Thu, 17 Aug 2006, 15:35+0200, Florian Meister wrote:
 
 > hi maxim,
 >
 > > > set testvar="lala" ; [ -n "$testvar" ] ; echo $? ; echo $testvar
 > > 0
 > > lala
 > > > set testvar="" ; [ -n "$testvar" ] ; echo $? ; echo $testvar
 > > 1
 >
 > okay I see, but then there is a bug in the /etc/rc.d/jail script at
 > line 167:
 >
 > --snip--
 > if [ -n ${jail_interface} ]; then
 >    ifconfig ${jail_interface} alias ${jail_ip} netmask 255.255.255.255
 > fi
 
 That was already fixed in HEAD and RELENG_6.
 
 Do any other problems with -n flag remain?  Can I close the PR?
 
 -- 
 Maxim Konovalov

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

 okay :) - thanks for you help.
 
 Maxim Konovalov wrote:
 > On Thu, 17 Aug 2006, 15:35+0200, Florian Meister wrote:
 > 
 >> hi maxim,
 >>
 >>>> set testvar="lala" ; [ -n "$testvar" ] ; echo $? ; echo $testvar
 >>> 0
 >>> lala
 >>>> set testvar="" ; [ -n "$testvar" ] ; echo $? ; echo $testvar
 >>> 1
 >> okay I see, but then there is a bug in the /etc/rc.d/jail script at
 >> line 167:
 >>
 >> --snip--
 >> if [ -n ${jail_interface} ]; then
 >>    ifconfig ${jail_interface} alias ${jail_ip} netmask 255.255.255.255
 >> fi
 > 
 > That was already fixed in HEAD and RELENG_6.
 > 
 > Do any other problems with -n flag remain?  Can I close the PR?
 > 
>Unformatted:
