GNU bug report logs -
#7823
Rm -f fails on non-existant file
Previous Next
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
"rm -f" is supposed to succeed (and not print an error message) when the
given file name does not exist.
Unfortunately, I found a rare case where this is not happening.
It appears that when mounting a Windows filesystem using Samba, if I try
running:
command
#!/bin/sh
mkdir emptydir
rm -f emptydir/*
The shell leaves this "*" unchanged, and rm gives this name to unlink(2),
which oddly enough returns EINVAL (invalid argument) instead of the expected
ENOENT (no such file or directory!).
I'm guessing the smbfs people chose to give this as a special error when
"invalid" characters are used in the file name (this is a concept that doesn't
exist in Unix), but I'm not sure why it was so important to them to not
just return ENOENT in this case... But still, I think "rm" should behave
well in this case.
So currently, in the above example "rm -f emptydir/*", instead of just doing
nothing silently, prints an error message (Invalid Argument) and does exit(1).
This, for example, causes problems in Makefiles which run "rm -f" assuming it
won't fail (yes, I know, make has the "-" modifier - unfortunately some
makefiles don't use it...).
Anyway, in remove.c, you have
static inline bool
nonexistent_file_errno (int errnum)
{
switch (errnum)
{
case ENOENT:
case ENOTDIR:
return true;
default:
return false;
}
}
And I wonder whether EINVAL shouldn't also be added to it.
Thanks,
Nadav Har'El.
--
Nadav Har'El | Tuesday, Jan 11 2011, 6 Shevat 5771
nyh <at> math.technion.ac.il |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Share your knowledge. It's a way to
http://nadav.harel.org.il |achieve immortality.
This bug report was last modified 14 years and 134 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.