Ted Unangst(t...@tedunangst.com) on 2016.06.28 10:50:48 -0400:
> rkito...@gmail.com 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
> >                      
> > dera...@amd64.openbsd.org:/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.

ok

> 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:
> 

-- 

Reply via email to