NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: standards/38754: /bin/rm rm.c consistancy with other bsds
The following reply was made to PR standards/38754; it has been noted by GNATS.
From: Murray Armfield <murray%river-styx.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: standards/38754: /bin/rm rm.c consistancy with other bsds
Date: Mon, 2 Jun 2008 16:51:22 +1000
On Mon, 2 Jun 2008 09:05:03 am you wrote:
> The following reply was made to PR standards/38754; it has been noted by
> GNATS.
>
> From: Alan Barrett <apb%cequrux.com@localhost>
> To: gnats-bugs%NetBSD.org@localhost
> Cc: netbsd-bugs%NetBSD.org@localhost
> Subject: Re: standards/38754: /bin/rm rm.c consistancy with other bsds
> Date: Mon, 2 Jun 2008 00:00:13 +0100
>
> On Mon, 26 May 2008, murray%river-styx.org@localhost wrote:
> > rm will display the usage message if there are no file arguments and
> > the -f flag is used. This does not follow POSIX. POSIX says...
> > "Do not write diagnostic messages or modify the exit status in the
> > case of nonexistent operands."
>
> You seem to interpret "nonexistent operands" to mean the number of
> operands (not counting options such as the "-f" itself) is zero.
>
> I believe that "nonexistent operands" should be interpreted to mean
> operands that contain strings that do not refer to entities that exist
> in the file system.
>
> Thus, "rm -f" does not contain any "nonexistent operands"; it contains
> no operands at all, and "rm" should print a diagnostic message
> complaining about incorrect usage, and exit with an error status.
>
> However, "rm -f /this/file/or/directory/does/not/exist" does contain
> a "nonexistent operand", and "rm" should exit without any error or
> diagnostic message.
>
> --apb (Alan Barrett)
I see your point. "Nonexistent operands" could refer to no operands, or no
operands that exist. The original code used the "if (argc < 1)" just as a
fast exit path. The addition of testing for the -f flag in the fast exit path
is to just drop the usage message in that case and bring rm in line with how
I read the standard around 'file' processing. FreeBSD and OpenBSD both drop
the usage message if the -f flag is used. A concern here is obviously the
change in behaviour which may affect existing shell script, while at the same
time bringing rm -f behaviour in line with other BSD's. Yet to be consistant
with other utility programs, if no operand is given, usage is displayed.
The way I was also thinking about this was from a shell scripting point of
view. If I have a list variable building up a list of files to remove, when I
pass it to rm -f, I want it to quietly do its thing. If my variable had no
items, I would still want it to quietly do its thing and not issue a usage
message and exit with non-zero.
I don't know where to go from here other than to ask other people for their
point of view.
Thanks for questioning this point.
Take care,
Murray Armfield
Home |
Main Index |
Thread Index |
Old Index