[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
mkdir -p -- minor cleanup
From: |
Paul Eggert |
Subject: |
mkdir -p -- minor cleanup |
Date: |
Wed, 19 Apr 2006 01:02:30 -0700 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
In reviewing Bruno Haible's proposed patch to move $(mkdir_p) from
Automake to Autoconf
<http://lists.gnu.org/archive/html/bug-autoconf/2006-04/msg00041.html>
I noticed an inconsistency in how $(mkdir_p) is set. Normally it is
set to 'mkdir -p --', but it might be set to '$(install_sh) -d' or to
'$(mkinstalldirs)' or to '$(install_sh) -d'. The former definition
allows a making directory with a leading "-", but the latter two
mean you have to use "--" yourself.
I vaguely recall that when I contributed this mkdir -p business a
while ago, it was being used in a different context; but now that
$(mkdir_p) is intended to mean 'mkdir -p' I think it's more consistent
for the expansion to not include the '--'.
Here's a proposed Automake patch to implement this. I noticed that
install-sh handles neither -- nor unknown options, so I added support
for that as well.
2006-04-19 Paul Eggert <address@hidden>
* lib/install.sh: Handle --, and diagnose unknown options.
* m4/mkdirp.m4 (AM_PROG_MKDIR_P): In the normal case, set
mkdir_p='mkdir -p', not to 'mkdir -p --', for consistency with
the other ways that mkdir_p might be set.
Index: lib/install-sh
===================================================================
RCS file: /cvs/automake/automake/lib/install-sh,v
retrieving revision 1.29
diff -p -u -r1.29 install-sh
--- lib/install-sh 12 Jan 2006 21:11:14 -0000 1.29
+++ lib/install-sh 19 Apr 2006 07:51:05 -0000
@@ -109,7 +109,7 @@ Environment variables override the defau
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
-while test -n "$1"; do
+while test $# -ne 0; do
case $1 in
-c) shift
continue;;
@@ -150,25 +150,33 @@ while test -n "$1"; do
--version) echo "$0 $scriptversion"; exit $?;;
- *) # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- test -n "$dir_arg$dstarg" && break
- # Otherwise, the last argument is the destination. Remove it from
address@hidden
- for arg
- do
- if test -n "$dstarg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dstarg"
- shift # fnord
- fi
- shift # arg
- dstarg=$arg
- done
+ --) shift
break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
esac
done
-if test -z "$1"; then
+if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from
address@hidden
+ for arg
+ do
+ if test -n "$dstarg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dstarg"
+ shift # fnord
+ fi
+ shift # arg
+ dstarg=$arg
+ done
+fi
+
+if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
Index: m4/mkdirp.m4
===================================================================
RCS file: /cvs/automake/automake/m4/mkdirp.m4,v
retrieving revision 1.8
diff -p -u -r1.8 mkdirp.m4
--- m4/mkdirp.m4 7 Aug 2005 08:10:06 -0000 1.8
+++ m4/mkdirp.m4 19 Apr 2006 07:51:05 -0000
@@ -1,5 +1,5 @@
## -*- Autoconf -*-
-# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -29,7 +29,7 @@
# this.)
AC_DEFUN([AM_PROG_MKDIR_P],
[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
- # We used to define $(mkdir_p) as `mkdir -p -- .', in order to
+ # We used to define $(mkdir_p) as `mkdir -p .', in order to
# allow $(mkdir_p) to be used without argument. As in
# $(mkdir_p) $(somedir)
# where $(somedir) is conditionally defined. However we don't do
@@ -48,7 +48,7 @@ AC_DEFUN([AM_PROG_MKDIR_P],
# 3. $(mkdir_p) is named after `mkdir -p' and we don't expect this
# to accept no argument.
# 4. having something like `mkdir .' in the output is unsightly.
- mkdir_p='mkdir -p --'
+ mkdir_p='mkdir -p'
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
- moving $(mkdir_p) from automake to autoconf, Bruno Haible, 2006/04/18
- Re: moving $(mkdir_p) from automake to autoconf, Stepan Kasal, 2006/04/18
- mkdir -p -- minor cleanup,
Paul Eggert <=
- Re: mkdir -p -- minor cleanup, Stepan Kasal, 2006/04/19
- Re: mkdir -p -- minor cleanup, Ralf Wildenhues, 2006/04/22
- Re: mkdir -p -- minor cleanup, Stepan Kasal, 2006/04/24
- Re: mkdir -p -- minor cleanup, Paul Eggert, 2006/04/24
- Re: mkdir -p -- minor cleanup, Ralf Wildenhues, 2006/04/25
Re: moving $(mkdir_p) from automake to autoconf, Ralf Wildenhues, 2006/04/19