GNU bug report logs -
#12336
test bug
Previous Next
Reported by: Bala Murugan <bala.spidy <at> gmail.com>
Date: Sun, 2 Sep 2012 18:19:01 UTC
Severity: normal
Tags: notabug
Done: Bob Proulx <bob <at> proulx.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12336 in the body.
You can then email your comments to 12336 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#12336
; Package
coreutils
.
(Sun, 02 Sep 2012 18:19:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Bala Murugan <bala.spidy <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Sun, 02 Sep 2012 18:19:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi team ,
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.
[balamup2 <at> cl-flor-dvvm026 ~]$ test -f "test*.txt"
[balamup2 <at> cl-flor-dvvm026 ~]$ echo $?
1
[balamup2 <at> cl-flor-dvvm026 ~]$
but its working fine for KSH shell.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12336
; Package
coreutils
.
(Sun, 02 Sep 2012 20:32:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 12336 <at> debbugs.gnu.org (full text, mbox):
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 <at> cl-flor-dvvm026 ~]$ test -f "test*.txt"
> [balamup2 <at> cl-flor-dvvm026 ~]$ echo $?
> 1
> [balamup2 <at> 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
Added tag(s) notabug and moreinfo.
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Sun, 02 Sep 2012 20:32:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12336
; Package
coreutils
.
(Wed, 05 Sep 2012 00:09:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 12336 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Bob,
thanks for u r reply.
See i will explain u neatly.
I am using bash shell. When I tried to do this i getting this.I am getting
this error.
[balamup2 <at> cl-flor-dvvm026 ~]$ echo $SHELL
*/bin/bash*
[balamup2 <at> cl-flor-dvvm026 ~]$ ls
*test1.txt test3.txt testdir test.txt*
[balamup2 <at> cl-flor-dvvm026 ~]$ test -f test*.txt
*-bash: test: too many arguments*
--------------------------------------------------------------------------------------------
But my friend is using ksh shell. He is fine with that command . I will
past this O/P also.
$ echo $SHELL
*/usr/bin/ksh*
$ ls
*123.txt a1.txt abc.txt a.txt dead.letter nohup.out ww1.txt*
$ test -f a*.txt
$ echo $?
*0*
Please take a deep look and resolve this problem
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12336
; Package
coreutils
.
(Wed, 05 Sep 2012 00:19:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 12336 <at> debbugs.gnu.org (full text, mbox):
Please keep the mailing list in the reply. I have set Reply-To accordingly.
Bala Murugan wrote:
> I am using bash shell. When I tried to do this i getting this.I am getting
> this error.
>
> [balamup2 <at> cl-flor-dvvm026 ~]$ echo $SHELL
> */bin/bash*
I am sure that those '*' characters are not there. You must have
added them for emphasis.
> [balamup2 <at> cl-flor-dvvm026 ~]$ ls
> *test1.txt test3.txt testdir test.txt*
So you have three files that match test*.txt in that directory.
> [balamup2 <at> cl-flor-dvvm026 ~]$ test -f test*.txt
> *-bash: test: too many arguments*
That is correct. You are passing in too many arguments. The test -f
operator requires one argument. You have passed *three* arguments.
That is two too many.
You can verify this by using 'echo'. Try this:
$ echo test -f test*.txt
Using that you will see that the test*.txt is matching and being
expanded by the shell into three arguments.
It is almost always incorrect to pass a '*' or other shell file glob
metacharacter unquoted on the command line to test. Your usage is
very problematic. Instead you may want to loop over the files.
for file in test*.txt; do
test -f "$file" && echo file: "$file" || echo nofile: "$file"
done
> But my friend is using ksh shell. He is fine with that command .
But does your friend have three files that match that file glob in his
directory? Have you friend do this:
$ touch test1.txt test2.txt test3.txt
$ echo test -f test*.txt
$ test -f test*.txt
By creating the extra files with touch that should ensure that
multiple files are matched.
> I will past this O/P also.
>
> $ echo $SHELL
> */usr/bin/ksh*
>
> $ ls
> *123.txt a1.txt abc.txt a.txt dead.letter nohup.out ww1.txt*
>
> $ test -f a*.txt
> $ echo $?
> *0*
I cannot reproduce that result. I tried this:
$ mkdir /tmp/testdir
$ cd /tmp/testdir
/testdir$ touch 123.txt a1.txt abc.txt a.txt dead.letter nohup.out ww1.txt
/testdir$ ls a*.txt
a.txt a1.txt abc.txt
/testdir$ test -f a*.txt
bash: test: too many arguments
That is correct behavior because a*.txt matches several files.
> Please take a deep look and resolve this problem
I am sorry but I think this is simply incorrect usage.
Bob
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12336
; Package
coreutils
.
(Wed, 12 Sep 2012 20:49:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 12336 <at> debbugs.gnu.org (full text, mbox):
tags 12336 - moreinfo
close 12336
thanks
I haven't seen anything new on this for a week. I believe this to be
a usage problem. Therefore I am closing this bug ticket. If you have
different or new information please feel free to respond with it.
Bob
Removed tag(s) moreinfo.
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Wed, 12 Sep 2012 20:49:01 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
12336 <at> debbugs.gnu.org and Bala Murugan <bala.spidy <at> gmail.com>
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Wed, 12 Sep 2012 20:49:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 11 Oct 2012 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 255 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.