bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

exit status of rm


From: Eric Blake
Subject: exit status of rm
Date: Thu, 23 Jun 2005 20:45:05 +0000

POSIX requires that rm have an argument, but also that it exit with 0 status
if "All of the named directory entries for which rm performed actions
equivalent to the rmdir() or unlink() functions were removed."  This puts the
invocation of rm without arguments in the implementation's realm, where
currently, coreutils is not consistent on what it returns:

$ rm
rm: missing operand
Try `rm --help' for more information.
$ echo $?   # used improperly
1
$ rm -f
$ echo $?    # all (zero) calls to unlink succeeded
0

Both return statuses are defensible (neither is more intuitive).  So is it
worth bringing this up with the austin group?  Is it worth changing rm to
be consistent in its status regardless of options, or to keep the status quo
of -f affecting the status?  And if it is made consistent, I would lean towards
a status of 0, so that constructs like "rm -f `generate a list`" succeed even if
the list is empty.  On the other hand, solaris rm also has the -f dichotomy,
but returns 2 for syntax error if -f is not present.

Furthermore, it is always possible for forced deletes to match POSIX
requirements by using this idiom, since the file '' does not exist:
rm -f `generate a list` ''
But the same cannot be said for rm when -f is not in effect.  Should this be
mentioned in the autoconf portability documentation?  Are there any systems
out there where "rm -f ``" has non-zero status?

--
Eric Blake




reply via email to

[Prev in Thread] Current Thread [Next in Thread]