emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-bug-tracker] bug#7823: closed (Rm -f fails on non-existant file)


From: GNU bug Tracking System
Subject: [Emacs-bug-tracker] bug#7823: closed (Rm -f fails on non-existant file)
Date: Wed, 12 Jan 2011 05:28:01 +0000

Your message dated Wed, 12 Jan 2011 06:34:54 +0100
with message-id <address@hidden>
and subject line Re: bug#7823: Rm -f fails on non-existant file
has caused the GNU bug report #7823,
regarding Rm -f fails on non-existant file
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
7823: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7823
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: Rm -f fails on non-existant file Date: Tue, 11 Jan 2011 14:58:43 +0200 User-agent: Mutt/1.4.2.2i
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
address@hidden             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Share your knowledge. It's a way to
http://nadav.harel.org.il           |achieve immortality.



--- End Message ---
--- Begin Message --- Subject: Re: bug#7823: Rm -f fails on non-existant file Date: Wed, 12 Jan 2011 06:34:54 +0100
Eric Blake wrote:
...
> Actually, this is a bug fix, so I'm also squashing this NEWS blurb in,
> then pushing:
>
> diff --git i/NEWS w/NEWS
...
> +  rm -f no longer fails for EINVAL or EILSEQ on file systems that
> +  reject file names invalid for that file system.

Thanks to both of you.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]