Subject: Re: bug#22998: File removal bug

From: Eric Blake <[email-masked]>
Date: Sat, 12 Mar 2016 20:47:58 -0700

tag 22998 notabug
thanks

On 03/12/2016 10:33 AM, Avineshwar Singh wrote:
> Hi.
> 
> Let's say I manage to create a file named "-filename.extension". It's not being removed using "rm -filename.extension",

Indeed, and that's a FAQ:

https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#I-have-a-file-called-_002d_002dhelp_002e-How-do-I-remove-it_003f

> however, it is being removed using "/filepath/-filename.extension".

Indeed, and that is one of the work-arounds for this non-bug.  The other
workaround is to use:

rm -- -filename.extension.

> There is a potential fix for this. It is existing in Ubuntu, Fedora, NetBSD, FreeBSD and OmniOS, atleast.

This is not a bug, but the behavior mandated by POSIX.  Therefore I'm
closing this report.  However, feel free to ask further related
questions in response to this thread.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org