NetBSD-Bugs archive

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

standards/38754: /bin/rm rm.c consistancy with other bsds



>Number:         38754
>Category:       standards
>Synopsis:       /bin/rm rm.c consistancy with other bsds
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    standards-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon May 26 08:00:06 +0000 2008
>Originator:     murray armfield
>Release:        NetBSD-current
>Organization:
N/A
>Environment:
NetBSD zeus.river-styx.org 4.99.63 NetBSD 4.99.63 (ZEUS) #1: Sun May 25 
11:08:57 EST 2008  
admin%zeus.river-styx.org@localhost:/vol01/build/obj/sys/arch/amd64/compile/ZEUS
 amd64
>Description:
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."
Also, while here, exit immediately if there are no arguments and -f given, and 
remove a NULL cast and improve an error message.
>How-To-Repeat:
Inspect code from NetBSD versus *BSD
>Fix:
Index: rm.c
===================================================================
RCS file: /cvsroot/src/bin/rm/rm.c,v
retrieving revision 1.46
diff -u -u -p -r1.46 rm.c
--- rm.c        24 Jun 2007 17:59:31 -0000      1.46
+++ rm.c        26 May 2008 06:24:03 -0000
@@ -126,8 +126,11 @@ main(int argc, char *argv[])
        argc -= optind;
        argv += optind;

-       if (argc < 1)
+       if (argc < 1) {
+               if (fflag)
+                       exit(0);
                usage();
+       }

        checkdot(argv);

@@ -168,9 +171,8 @@ rm_tree(char **argv)
                flags |= FTS_NOSTAT;
        if (Wflag)
                flags |= FTS_WHITEOUT;
-       if (!(fts = fts_open(argv, flags,
-           (int (*)(const FTSENT **, const FTSENT **))NULL)))
-               err(1, NULL);
+       if (!(fts = fts_open(argv, flags, NULL)))
+               err(1, "fts_open");
        while ((p = fts_read(fts)) != NULL) {

                switch (p->fts_info) {



Home | Main Index | Thread Index | Old Index