[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: possible BUG about cmd `rm` or `bash`
From: |
Bob Proulx |
Subject: |
Re: possible BUG about cmd `rm` or `bash` |
Date: |
Thu, 8 Mar 2001 21:17:51 -0700 |
> I met a problem about Linux command 'rm', I created a file named as =
> "--full-time" by occasionally, then i tried to remove it, I had already =
> tried following cmd under bash:
>
> 1) rm --full-time
> 2) rm "--full-time"
> 3) rm \-\-full\-time
>
> As a result the three approaches all failed.
>
> So I think there might be some BUGs in cmd 'rm' or 'bash'?
There is no bug there. The rm command is interpreting the first
argument as an option instead of as a filename. It looks like an
option and so that makes sense. Quoting it won't change things.
Prove that to yourself using the echo command to print what the rm
command would see. Quoting would only protect against shell
metacharacter ($, *, |, ;, etc.) expansion.
echo rm --full-time
rm --full-time
echo rm "--full-time"
rm --full-time
echo rm \-\-full\-time
rm --full-time
You need to make the file not look like an option. Either specify the
path or explicitly mark the end of options with "--".
rm ./--full-time
rm /full/path/to/--full-time
rm -- --full-time
Bob