[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem with "test"
From: |
rmarsha8 |
Subject: |
Problem with "test" |
Date: |
Thu, 7 Dec 2000 11:59:23 -0500 |
I have been working for some time on a problem with a shell script, and I
believe that either the binary "test" from the package "sh-utils" (versions
1.16 and 2.0) contains a bug, or that my usage is incorrect.
Specifically, when using bash (version 1.14.7-13) or pdksh (versions
5.2.12-5, 5.2.13-3, and 5.2.14) in Linux (kernel 2.0.36), a single wildcard
expansion will, if it matches multiple files, be returned as a list of
filenames. The binary "test" does not handle these multiple filenames as I
would expect. In both version 1.16 and version 2.0 of "test", I receive an
error message upon such expansion.
For example, these commands work as expected:
# ls /etc/hosts
/etc/hosts
# test -f /etc/hosts && echo yes
yes
When a wildcard only returns one filename, "test" works as expected:
# ls /etc/hosts.lp*
/etc/hosts.lpd
# test -f /etc/hosts.lp* && echo yes
yes
However, when the shell returns multiple filenames for a filename
containing a wildcard, "test" does not perform as expected:
# ls /etc/h*
/etc/hosts /etc/host.conf /etc/hosts.lpd
# test -f /etc/h* && echo yes
test: too many arguments
The same command on a Solaris box (version 7) returns what I would expect:
# ls /etc/h*
/etc/halt /etc/hostname.hme0 /etc/hosts /etc/hosts.equiv
# test -f /etc/h* && echo yes
yes
I would be happy to admit that my usage is incorrect, but I cannot see how
it might be. I also find it difficult to believe that this could be a bug,
since testing for the existence of wildcarded filenames is a staple for
shell programmers.
I hope you can light my way. Thank you for your time and attention.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Problem with "test",
rmarsha8 <=