tech-userlevel archive

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

Re: /bin/sh: built-in "test" command and -eq, -ne etc.



On Sun, Aug 31, 2008 at 12:21:37PM +0300, Aleksey Cheusov wrote:
 > Built-in test command shows the warning if arguments of -eq, -ne etc.
 > operators are not numbers but doesn't if arguments are an empty string.
 > 
 >   0 ~>/bin/sh -c 'test 1 -eq 1'  
 >   0 ~>/bin/sh -c 'test 1 -eq a' 
 >   test: a: bad number
 >   2 ~>/bin/sh -c 'test a -eq 1' 
 >   test: a: bad number
 >   2 ~>/bin/sh -c 'test "" -eq 1'
 >   1 ~>
 > 
 > I propose to display a warning and make an exit status
 > equal to 2 in the latter case too. bash and dash works this way.
 > And I think it is useful for debugging.

Sounds like a good idea to me.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index