autoconf-patches
[Top][All Lists]
Advanced

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

POSIX says "rm -rf" isn't portable


From: Paul Eggert
Subject: POSIX says "rm -rf" isn't portable
Date: 04 Jan 2004 23:07:40 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

While fixing another problem I noticed that Autoconf uses the common
idiom "rm -rf".  Unfortunately POSIX says this isn't portable, and
you're supposed to use "rm -r -f".  I installed this patch.

2004-01-04  Paul Eggert  <address@hidden>

        * lib/autoconf/general.m4 (AC_ARG_PROGRAM):
        Use "rm -f" to remove conftest.sed, not plain "rm".
        Bug reported by David Relson in
        <http://mail.gnu.org/archive/html/autoconf/2004-01/msg00011.html>.

        * Makefile.am (autom4te-update):
        Replace "rm -rf" and "rm -fr" with "rm -f -r", as POSIX requires.
        * Makefile.maint (my-distcheck, do-po-update): Likewise.
        * doc/autoconf.texi (Guidelines): Likewise.
        * lib/autoconf/general.m4 (_AC_INIT_PREPARE): Likewise.
        * lib/autoconf/libs.m4 (_AC_PATH_X_XMKMF): Likewise.
        * lib/autoconf/specific.m4 (AC_SYS_LONG_FILE_NAMES): Likewise.
        * lib/autotest/general.m4 (AT_INIT): Likewise.
        * lib/m4sugar/m4sh.m4 (AS_TMPDIR): Likewise.
        * tests/Makefile.am (clean-local): Likewise.
        * tests/tortue.at (AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS,
        srcdir): Likewise.
        * doc/autoconf.texi (Limitations of Usual Tools):
        Warn against "rm -fr".
        
Index: Makefile.am
===================================================================
RCS file: /cvsroot/autoconf/autoconf/Makefile.am,v
retrieving revision 1.92
diff -p -u -r1.92 Makefile.am
--- Makefile.am 13 Sep 2003 22:00:36 -0000      1.92
+++ Makefile.am 5 Jan 2004 06:51:58 -0000
@@ -1,7 +1,9 @@
 ## Process this file with automake to create Makefile.in. -*-Makefile-*-
 
 ## Makefile for Autoconf.
-## Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+## Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software
+## Foundation, Inc.
 
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -73,7 +75,7 @@ autom4te_files = \
   Autom4te/XFile.pm
 
 autom4te-update:
-       rm -rf Fetchdir > /dev/null 2>&1
+       rm -f -r Fetchdir > /dev/null 2>&1
        mkdir Fetchdir; mkdir Fetchdir/Autom4te
 ## If a get fails then that is a problem.
        (cd Fetchdir && \
Index: Makefile.maint
===================================================================
RCS file: /cvsroot/autoconf/autoconf/Makefile.maint,v
retrieving revision 1.26
diff -p -u -r1.26 Makefile.maint
--- Makefile.maint      26 Aug 2003 07:28:37 -0000      1.26
+++ Makefile.maint      5 Jan 2004 06:51:58 -0000
@@ -2,7 +2,7 @@
 # This Makefile fragment is shared between the coreutils,
 # CPPI, Bison, and Autoconf.
 
-## Copyright (C) 2001-2003 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 ##
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -329,7 +329,7 @@ null_AM_MAKEFLAGS = \
 TMPDIR ?= /tmp
 t=$(TMPDIR)/$(PACKAGE)/test
 my-distcheck: $(local-check)
-       -rm -rf $(t)
+       -rm -f -r $(t)
        mkdir -p $(t)
        GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
        cd $(t)/$(distdir) \
@@ -342,7 +342,7 @@ my-distcheck: $(local-check)
        (cd $(t) && mv $(distdir) $(distdir).old \
          && $(AMTAR) -zxf - ) < $(distdir).tar.gz
        diff -ur $(t)/$(distdir).old $(t)/$(distdir)
-       -rm -rf $(t)
+       -rm -f -r $(t)
        @echo "========================"; \
        echo "$(distdir).tar.gz is ready for distribution"; \
        echo "========================"
@@ -418,7 +418,7 @@ po_repo = http://www.iro.umontreal.ca/co
 .PHONY: do-po-update po-update
 do-po-update:
        tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
-       rm -rf $$tmppo && \
+       rm -f -r $$tmppo && \
        mkdir $$tmppo && \
        (cd $$tmppo && \
          $(WGET) $(WGETFLAGS) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.786
diff -p -u -r1.786 autoconf.texi
--- doc/autoconf.texi   4 Jan 2004 01:41:25 -0000       1.786
+++ doc/autoconf.texi   5 Jan 2004 06:52:14 -0000
@@ -6363,7 +6363,7 @@ example, if you call @code{AC_HEADER_STD
 
 If a test program needs to use or create a data file, give it a name
 that starts with @file{conftest}, such as @file{conftest.data}.  The
address@hidden script cleans up by running @samp{rm -rf conftest*}
address@hidden script cleans up by running @samp{rm -f -r conftest*}
 after running test programs and if the script is interrupted.
 
 @node Test Functions
@@ -11276,6 +11276,13 @@ nor can
 exec > foo
 rm -f foo
 @end example
+
address@hidden @command{rm}
address@hidden ---------------
address@hidden @command{rm}
+Avoid @samp{rm -fr}; instead, use @samp{rm -f -r}.  @acronym{POSIX} says
+that scripts must not combine options into a single argument when
+invoking a standard utility like @command{rm}.
 
 @item @command{sed}
 @c ----------------
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.825
diff -p -u -r1.825 general.m4
--- lib/autoconf/general.m4     5 Jan 2004 06:18:09 -0000       1.825
+++ lib/autoconf/general.m4     5 Jan 2004 06:52:17 -0000
@@ -1192,7 +1192,7 @@ trap 'exit_status=$?
     echo "$as_me: exit $exit_status"
   } >&AS_MESSAGE_LOG_FD
   rm -f core *.core &&
-  rm -rf conftest* confdefs* conf$[$]* $ac_clean_files &&
+  rm -f -r conftest* confdefs* conf$[$]* $ac_clean_files &&
     exit $exit_status
      ' 0
 for ac_signal in 1 2 13 15; do
@@ -1201,7 +1201,7 @@ done
 ac_signal=0
 
 # confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
+rm -f -r conftest* confdefs.h
 # AIX cpp loses on an empty file, so make sure it contains at least a newline.
 # NextStep 3.3 (patch 3) loses unless the first echo outputs at least 14 bytes.
 ac_space=' '
Index: lib/autoconf/libs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/libs.m4,v
retrieving revision 1.8
diff -p -u -r1.8 libs.m4
--- lib/autoconf/libs.m4        22 May 2003 13:24:05 -0000      1.8
+++ lib/autoconf/libs.m4        5 Jan 2004 06:52:18 -0000
@@ -1,7 +1,7 @@
 # This file is part of Autoconf.                       -*- Autoconf -*-
 # Checking for libraries.
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002 Free Software Foundation, Inc.
+# 2002, 2003, 2004 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -180,7 +180,7 @@ m4_popdef([AC_Lib_Name])dnl
 # Internal subroutine of _AC_PATH_X.
 # Set ac_x_includes and/or ac_x_libraries.
 m4_define([_AC_PATH_X_XMKMF],
-[rm -fr conftest.dir
+[rm -f -r conftest.dir
 if mkdir conftest.dir; then
   cd conftest.dir
   # Make sure to not put "make" in the Imakefile rules, since we grep it out.
@@ -211,7 +211,7 @@ _ACEOF
     esac
   fi
   cd ..
-  rm -fr conftest.dir
+  rm -f -r conftest.dir
 fi
 ])# _AC_PATH_X_XMKMF
 
Index: lib/autoconf/specific.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/specific.m4,v
retrieving revision 1.357
diff -p -u -r1.357 specific.m4
--- lib/autoconf/specific.m4    24 Nov 2003 10:40:59 -0000      1.357
+++ lib/autoconf/specific.m4    5 Jan 2004 06:52:19 -0000
@@ -2,7 +2,7 @@
 # Macros that test for specific, unclassified, features.
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003 Free Software Foundation, Inc.
+# 2002, 2003, 2004 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -234,10 +234,10 @@ for ac_dir in  . $ac_tmpdirs `eval echo 
   ac_val=`cat $ac_tf1 2>/dev/null`
   if test ! -f $ac_tf1 || test "$ac_val" != 1; then
     ac_cv_sys_long_file_names=no
-    rm -rf $ac_xdir 2>/dev/null
+    rm -f -r $ac_xdir 2>/dev/null
     break
   fi
-  rm -rf $ac_xdir 2>/dev/null
+  rm -f -r $ac_xdir 2>/dev/null
 done])
 if test $ac_cv_sys_long_file_names = yes; then
   AC_DEFINE(HAVE_LONG_FILE_NAMES, 1,
Index: lib/autotest/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autotest/general.m4,v
retrieving revision 1.154
diff -p -u -r1.154 general.m4
--- lib/autotest/general.m4     27 Nov 2003 10:04:14 -0000      1.154
+++ lib/autotest/general.m4     5 Jan 2004 06:52:20 -0000
@@ -253,7 +253,7 @@ do
        ;;
 
     --clean | -c )
-       rm -rf $at_suite_dir $at_suite_log
+       rm -f -r $at_suite_dir $at_suite_log
        exit 0
        ;;
 
@@ -600,7 +600,7 @@ do
       # Create a fresh directory for the next test group, and enter.
       at_group_dir=$at_suite_dir/$at_group_normalized
       at_group_log=$at_group_dir/$as_me.log
-      rm -rf $at_group_dir
+      rm -f -r $at_group_dir
       mkdir $at_group_dir ||
        AS_ERROR([cannot create $at_group_dir])
       cd $at_group_dir
@@ -692,7 +692,7 @@ _ATEOF
          echo "$at_log_msg" >&AS_MESSAGE_LOG_FD
 
          # Cleanup the group directory, unless the user wants the files.
-         $at_debug_p || rm -rf $at_group_dir
+         $at_debug_p || rm -f -r $at_group_dir
          ;;
        *)
          # Upon failure, include the log into the testsuite's global
Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.109
diff -p -u -r1.109 m4sh.m4
--- lib/m4sugar/m4sh.m4 25 Dec 2003 15:43:01 -0000      1.109
+++ lib/m4sugar/m4sh.m4 5 Jan 2004 06:52:20 -0000
@@ -1,7 +1,7 @@
 # This file is part of Autoconf.                          -*- Autoconf -*-
 # M4 sugar for common shell constructs.
 # Requires GNU M4 and M4sugar.
-# Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -896,7 +896,7 @@ m4_define([AS_TMPDIR],
 [# Create a temporary directory, and hook for its removal unless debugging.
 $debug ||
 {
-  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  trap 'exit_status=$?; rm -f -r $tmp && exit $exit_status' 0
   trap 'AS_EXIT([1])' 1 2 13 15
 }
 
Index: tests/Makefile.am
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/Makefile.am,v
retrieving revision 1.84
diff -p -u -r1.84 Makefile.am
--- tests/Makefile.am   23 Jun 2003 11:11:42 -0000      1.84
+++ tests/Makefile.am   5 Jan 2004 06:52:20 -0000
@@ -1,7 +1,7 @@
 ## Process this file with automake to create Makefile.in. -*-Makefile-*-
 
 ## Makefile for Autoconf testsuite.
-## Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -96,7 +96,7 @@ atconfig: $(top_builddir)/config.status
 clean-local:
        test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
        rm -f *.tmp
-       rm -rf autom4te.cache
+       rm -f -r autom4te.cache
 
 check-local: atconfig atlocal $(TESTSUITE)
        $(SHELL) $(TESTSUITE)
Index: tests/torture.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/torture.at,v
retrieving revision 1.45
diff -p -u -r1.45 torture.at
--- tests/torture.at    25 Sep 2003 09:30:35 -0000      1.45
+++ tests/torture.at    5 Jan 2004 06:52:21 -0000
@@ -1,6 +1,6 @@
 #                                                      -*- Autotest -*-
 
-# Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -128,7 +128,7 @@ AT_SETUP([AC_CONFIG_FILES, HEADERS, LINK
 
 AT_DATA([configure.ac],
 [[AC_INIT
-rm -rf header var-header file var-file link var-link command var-command
+rm -f -r header var-header file var-file link var-link command var-command
 echo 'OK' >input
 
 # Be sure to also stress the associated INIT-CMDS.
@@ -481,7 +481,7 @@ AT_CLEANUP
 
 AT_SETUP([srcdir])
 
-rm -rf at-dir
+rm -f -r at-dir
 mkdir at-dir
 : >at-dir/bar.in
 : >foo.in
@@ -497,7 +497,7 @@ AC_CONFIG_COMMANDS([report],
                   [srcdir=$srcdir])
 
 AC_OUTPUT
-rm -rf foo at-dir/bar
+rm -f -r foo at-dir/bar
 ]])
 
 AT_CHECK_AUTOCONF




reply via email to

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