Subject: Re: bug#12336: test bug

From: Bob Proulx <[email-masked]>
Date: Sun, 2 Sep 2012 14:29:37 -0600

tag 12336 + notabug moreinfo
thanks

Bala Murugan wrote:
> we are using Red Hat Enterprise Linux Server release 5.8. Our default shell
> is BASH. while using *test command* for single file its working fine.But
> when we use test command for multiple files we are facing this issue. I
> will paste the issue.

Thank you for the report.  However this is almost certainly not a bug
in test but instead is a usage problem.

First though test is both a standalone coreutils command (usually
/usr/bin/test) and a shell builtin command.  Using it as you are using
it above will invoke the shell builtin and not the standalone.  You
have reported this to the coreutils bug tracker for the standalone.
For the builtin you should report it to the bash shell bug list.
However in this case there isn't any difference between the two.  But
if you are going to report here then you should call the command
/usr/bin/test in order to use our version of the test command.

> while using *test command* for single file its working fine.

The test command example you showed was only for a single file.  But
it included a '*' character (which was properly quoted) and therefore

> But when we use test command for multiple files we are facing this
> issue.

I fear that you might be trying to use it as a shell file glob.  That
won't work.  The test -f action is only designed to take a single
argument.  It isn't designed to take multiple arguments.  By what you
have said it seems you are trying to pass in multiple arguments.  That
would be an incorrect usage.

> I will paste the issue.
>
> [balamup2@cl-flor-dvvm026 ~]$ test -f "test*.txt"
> [balamup2@cl-flor-dvvm026 ~]$ echo $?
> 1
> [balamup2@cl-flor-dvvm026 ~]$

If there is no file named "test*.txt" with exactly those characters
including the '*' character then the above is correct behavior.
Please include the output of:

  $ ls -ldog "test*.txt"

> but its working fine for KSH shell.

Please paste an exact example.  I cannot reproduce that behavior.

Bob