bug-sh-utils
[Top][All Lists]
Advanced

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

Re: Problem with "test" utility


From: Bob Proulx
Subject: Re: Problem with "test" utility
Date: Wed, 4 Apr 2001 23:37:57 -0600

> I'm having a problem with the "test" utility.
> I'm using Red Hat Linux v6.1 (Cartman) - Kernel 2.2.12-20 which I installed 
> not long ago.

Which shell are you using?  The test command is a builtin command of
the shell.  Therefore it is important to know the shell.  

There is also an external test program which would be called in corner
cases such as from find or some such other non-shell program.  here
you can see the difference between the bash builtin test command and
the external command.

  address@hidden bob]$ type test
  test is a shell builtin
  address@hidden bob]$ test --version
  address@hidden bob]$ /usr/bin/test --version
  test (GNU sh-utils) 2.0
  Written by FIXME: ksb and mjb.

> I've been typing in some simple shell scripts (inspired by Linux Programming 
> for Dummies) to compare 2 numeric variables - equals, greater than, less 
> than etc etc.
> Whatever I do, it's giving me the wrong answer - $? is equal to 1 when it 
> should be 0, and vice versa.

Very interesting.  When supplying a bug report if you could supply the
exact commands that you use to create the problem such that others
could recreate it then it would help to isolate the problem.  In this
case I am reluctant to admit a problem since that is such a commonly
used feature that I don't think it could slip past the shell
regression test.  I can't recreate a problem here.

  $ echo hello
  hello
  $ echo $?
  0
  $ echo hello
  hello
  $ test $? -eq 0 && echo works
  works

Bob




reply via email to

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