tech-userlevel archive

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

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

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.

If nobody is against it I'll send a PR.

Best regards, Aleksey Cheusov.

Home | Main Index | Thread Index | Old Index