Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Mar 2014 21:43:34 GMT
From:      John Wolfe <jlw@xinuos.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/187264: rm command: rm -r file1 file2 "" does not remove existing files or directories
Message-ID:  <201403042143.s24LhYDs078216@cgiserv.freebsd.org>
Resent-Message-ID: <201403042150.s24Lo02T086803@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         187264
>Category:       bin
>Synopsis:       rm command: rm -r file1 file2 "" does not remove existing files or directories
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 04 21:50:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     John Wolfe
>Release:        FreeBSD 9.2   (PC-BSD 9.2)
>Organization:
Xinuos, Inc.
>Environment:
FreeBSD sapphire.nj.sco.com 9.2-RELEASE-p12 FreeBSD 9.2-RELEASE-p12 #0: Thu Jan 16 21:12:30 UTC 2014     root@amd64-builder.pcbsd.org:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
When the gmake/make clean target contains a command of the form

   rm -rf "a.out" "$(DSYM)"  main.o main.d

the  command fails to remove any of the existing files if DSYM is null.
The '-f' option hides the error associated with the zero length file name, but gives no indication that, in fact, NO files/directories have been removed.


>How-To-Repeat:
Use the following script to see the problem

rm.bug.sh:
======================
#! /bin/sh
set -x

cat  > file_1 << !EOF
12345
How no brown cow
!EOF
cp file_1 file_2
cp file_1 file_3

# The following command should remove file_[123], but does not.
# The '-r' implies the '-d' option - attempt to remove directories 
# as well as other types of files.    The "" results in an error 
# when treated as a possible directory.
#
#  $ rm -r ""
#  rm: fts_open: No such file or directory
#
# which is a valid error, but none of the arguments are removed.
# 
# When the following command is run without the '-r', all three 
# files are removed.


rm -r "file_1" "" file_[23]

ls -l

# Yet a "rm -r " with a non-existant file in the list, will remove 
# all existing files.

rm -r "file_1" "xxx" file_2

ls -l

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403042143.s24LhYDs078216>