Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Jun 2012 16:19:42 +0200
From:      Fred Morcos <fred.morcos@gmail.com>
To:        Damien Fleuriot <ml@my.gd>
Cc:        questions@freebsd.org
Subject:   Re: rm returns 0 although directory didn't exist and wasn't deleted ?
Message-ID:  <CAH3a3KUce7jJ61YdR2qugAgoQKT7iJiWZaihfyUXp81295oYpg@mail.gmail.com>
In-Reply-To: <4FE089AE.5050206@my.gd>
References:  <4FE08093.1040607@my.gd> <CAH3a3KWzhnt7Ykvn7vaF-Ej-juqUfa4iY%2BiSq_jSnxnY8MxzqA@mail.gmail.com> <4FE089AE.5050206@my.gd>

next in thread | previous in thread | raw e-mail | index | archive | help
The man page [1] explicitly states that if the file doesn't exist, -f
will not show an error message nor alter the exit code.

-f   Attempt to remove the files without prompting for confirmation,
regardless of the file's permissions.  If the file does not exist, do
not display a diagnostic message or modify the exit status to reflect
an error.  The -f option overrides any previous -i options.

[1] http://www.freebsd.org/cgi/man.cgi?query=3Drm&apropos=3D0&sektion=3D0&m=
anpath=3DFreeBSD+9.0-RELEASE&arch=3Ddefault&format=3Dhtml

On Tue, Jun 19, 2012 at 4:16 PM, Damien Fleuriot <ml@my.gd> wrote:
> I always assumed -f would only force removal, not modify the exit code.
>
> No bug then, working as intended, all good.
>
>
>
> Cheers
>
> On 6/19/12 3:43 PM, Fred Morcos wrote:
>> You used -f which means rm will not complain if a file or directory
>> cannot be deleted (or does not exist in the first place).
>>
>> On Tue, Jun 19, 2012 at 3:37 PM, Damien Fleuriot <ml@my.gd> wrote:
>>> I've stumbled upon this *so weird* behaviour.
>>>
>>>
>>>
>>> # ls -la /var/tmp/stunnel/
>>> ls: /var/tmp/stunnel/: No such file or directory
>>>
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 # rm -Rf
>>> /var/tmp/stunnel/
>>>
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 # echo $?
>>> 0
>>>
>>>
>>>
>>> Anyone knows if that's intended ?
>>>
>>> FreeBSD pf2.[snip].com 8.3-STABLE FreeBSD 8.3-STABLE #0: Tue Jun 19
>>> 10:45:31 CEST 2012
>>>
>>> _______________________________________________
>>> freebsd-questions@freebsd.org mailing list
>>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>>> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd=
.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAH3a3KUce7jJ61YdR2qugAgoQKT7iJiWZaihfyUXp81295oYpg>