aboutsummaryrefslogtreecommitdiff
path: root/mkinstalldirs
diff options
context:
space:
mode:
Diffstat (limited to 'mkinstalldirs')
-rw-r--r--mkinstalldirs17
1 files changed, 12 insertions, 5 deletions
diff --git a/mkinstalldirs b/mkinstalldirs
index 6504b744..6fbe5e11 100644
--- a/mkinstalldirs
+++ b/mkinstalldirs
@@ -1,7 +1,7 @@
1#! /bin/sh 1#! /bin/sh
2# mkinstalldirs --- make directory hierarchy 2# mkinstalldirs --- make directory hierarchy
3 3
4scriptversion=2003-11-08.23 4scriptversion=2004-02-15.20
5 5
6# Original author: Noah Friedman <friedman@prep.ai.mit.edu> 6# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
7# Created: 1993-05-16 7# Created: 1993-05-16
@@ -66,9 +66,15 @@ case $# in
66 0) exit 0 ;; 66 0) exit 0 ;;
67esac 67esac
68 68
69# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
70# mkdir -p a/c at the same time, both will detect that a is missing,
71# one will create a, then the other will try to create a and die with
72# a "File exists" error. This is a problem when calling mkinstalldirs
73# from a parallel make. We use --version in the probe to restrict
74# ourselves to GNU mkdir, which is thread-safe.
69case $dirmode in 75case $dirmode in
70 '') 76 '')
71 if mkdir -p -- . 2>/dev/null; then 77 if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
72 echo "mkdir -p -- $*" 78 echo "mkdir -p -- $*"
73 exec mkdir -p -- "$@" 79 exec mkdir -p -- "$@"
74 else 80 else
@@ -77,16 +83,17 @@ case $dirmode in
77 # directories to create, and then abort because `.' already 83 # directories to create, and then abort because `.' already
78 # exists. 84 # exists.
79 test -d ./-p && rmdir ./-p 85 test -d ./-p && rmdir ./-p
80 test -d ./-- && rmdir ./-- 86 test -d ./--version && rmdir ./--version
81 fi 87 fi
82 ;; 88 ;;
83 *) 89 *)
84 if mkdir -m "$dirmode" -p -- . 2>/dev/null; then 90 if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
91 test ! -d ./--version; then
85 echo "mkdir -m $dirmode -p -- $*" 92 echo "mkdir -m $dirmode -p -- $*"
86 exec mkdir -m "$dirmode" -p -- "$@" 93 exec mkdir -m "$dirmode" -p -- "$@"
87 else 94 else
88 # Clean up after NextStep and OpenStep mkdir. 95 # Clean up after NextStep and OpenStep mkdir.
89 for d in ./-m ./-p ./-- "./$dirmode"; 96 for d in ./-m ./-p ./--version "./$dirmode";
90 do 97 do
91 test -d $d && rmdir $d 98 test -d $d && rmdir $d
92 done 99 done