Subject: Re: "rm *" files "-f" and "-r" - weird behaviour...
To: Martin Husemann <martin@duskware.de>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-userlevel
Date: 01/20/2006 18:24:17
> On Fri, Jan 20, 2006 at 06:12:36PM +0600, Ian Zagorskih wrote:
> > $ echo > -r
> > $ echo > -f
> > $ rm *
>
> [..]
>
> > IMHO quite weird rm behavior, no? :)
>
> What do you not understand about it? Your shell expands * into all files,
> and you get "rm -r -f foo" as a result. Now rm executes this and the result
> is as expected.
>
> If you don't want to risk this, do not use * in this context or use -- to
> stop option parsing:
>
>  $ rm -- *
>  rm: foo: is a directory
>
> (but it will rm the -r and -f file)
>
> Another common way to express this is to use
>
>  rm ./*
>
> which has the same effect, basically (since no options start with ./)

Thanks, now I understand :) I missed that '*' is actually resolved by shell 
and no by rm. But from end user point of view this looks quite weird :)

// wbr