On Tue, Jun 28, 2016 at 10:50:48AM -0400, Ted Unangst wrote:
> [email protected] wrote:
> > >Synopsis: rm -rf "" # prints error message but should be silent
> > >Category: system
> > >Environment:
> > System : OpenBSD 5.9
> > Details : OpenBSD 5.9 (GENERIC.MP) #1888: Fri Feb 26 01:20:19 MST
> > 2016
> >
> > [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> >
> > Architecture: OpenBSD.amd64
> > Machine : amd64
> > >Description:
> > The command:
> >
> > rm -rf ""
> >
> > prints to STDERR:
> >
> > rm: No such file or directory
> >
> > but it should print nothing because of the -f flag.
>
> This fixes it.
There is still a bug:
$ mkdir foo; cd foo; touch bar; rm -rf "" bar; echo $?; ls -la; \
rm -rf nonexistend bar; echo $?; ls -la
0
total 8
drwxr-xr-x 2 florian wheel 512 Jun 28 17:20 ./
drwxrwxrwt 9 root wheel 512 Jun 28 17:20 ../
-rw-r--r-- 1 florian wheel 0 Jun 28 17:20 bar
0
total 8
drwxr-xr-x 2 florian wheel 512 Jun 28 17:20 ./
drwxrwxrwt 9 root wheel 512 Jun 28 17:20 ../
i.e. rm does not continue when it fails on "", this only happens when
specifying -r (because fts_open fails)
Posix says this:
1. If the file does not exist:
a. If the -f option is not specified, rm shall write a diagnostic message
to standard error.
b. Go on to any remaining files.
>
>
> Index: rm.c
> ===================================================================
> RCS file: /cvs/src/bin/rm/rm.c,v
> retrieving revision 1.37
> diff -u -p -r1.37 rm.c
> --- rm.c 15 Apr 2016 23:09:57 -0000 1.37
> +++ rm.c 28 Jun 2016 14:49:42 -0000
> @@ -150,8 +150,11 @@ rm_tree(char **argv)
> flags = FTS_PHYSICAL;
> if (!needstat)
> flags |= FTS_NOSTAT;
> - if (!(fts = fts_open(argv, flags, NULL)))
> - err(1, NULL);
> + if (!(fts = fts_open(argv, flags, NULL))) {
> + if (!fflag || errno != ENOENT)
> + err(1, NULL);
> + return;
> + }
> while ((p = fts_read(fts)) != NULL) {
> switch (p->fts_info) {
> case FTS_DNR:
>
--
I'm not entirely sure you are real.