I ran into a strange situation the other day. I was compiling a program that was core dumping ( 52.9 ) . At some point, I decided to delete the object files and the core file, and start over, so I gave the command:
%rm *.o core
It works as expected most of the time,
except when
no object files exist. (I don't remember why I did this, but it was probably by using
!!
(
11.7
)
when I knew there weren't any
.o
's around.) In this case,
you get
No match
, and the
core
file is
not
deleted.
It turns out, for C shell users, that if none of the wildcards can be expanded, you get a
No match
error. It doesn't matter that there's a perfectly good match for other name(s). That's because, when
csh
can't match a wildcard, it aborts and prints an error - it won't run the command. If you create one
.o
file or remove the
*.o
from the command line,
core
will disappear happily.
On the other hand, if the Bourne shell can't match a wildcard, it just passes the unmatched wildcard and other filenames:
*.o core
to the command (in this case, to
rm
) and lets the command decide what to do with it. So, with Bourne shell, what happens will depend on what your command does when it sees the literal characters
*.o
.
You can make csh act a lot like sh by using:
set nonomatch
-
,