aboutsummaryrefslogtreecommitdiff
path: root/support/mkdirhier
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-05-25 20:09:04 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-05-25 20:09:04 +0200
commit4440a86cfa359b8e40a484a2cd46d33db5455d8a (patch)
treef5c0c59aebf0058ae97e7ef8b5fb8017f459a05a /support/mkdirhier
downloadircd-4440a86cfa359b8e40a484a2cd46d33db5455d8a.tar.gz
Initial
Diffstat (limited to 'support/mkdirhier')
-rwxr-xr-xsupport/mkdirhier70
1 files changed, 70 insertions, 0 deletions
diff --git a/support/mkdirhier b/support/mkdirhier
new file mode 100755
index 0000000..244462a
--- /dev/null
+++ b/support/mkdirhier
@@ -0,0 +1,70 @@
+#!/bin/sh
+# $XConsortium: mkdirhier.sh,v 1.7 94/03/24 15:46:34 gildea Exp $
+# Courtesy of Paul Eggert
+#
+# $Id: mkdirhier,v 1.2 1997/07/22 12:40:10 kalt Exp $
+#
+
+newline='
+'
+IFS=$newline
+
+case ${1--} in
+-*) echo >&2 "mkdirhier: usage: mkdirhier directory ..."; exit 1
+esac
+
+status=
+
+for directory
+do
+ case $directory in
+ '')
+ echo >&2 "mkdirhier: empty directory name"
+ status=1
+ continue;;
+ *"$newline"*)
+ echo >&2 "mkdirhier: directory name contains a newline: \`\`$directory''"
+ status=1
+ continue;;
+ ///*) prefix=/;; # See Posix 2.3 "path".
+ //*) prefix=//;;
+ /*) prefix=/;;
+ -*) prefix=./;;
+ *) prefix=
+ esac
+
+ IFS=/
+ set x $directory
+ case $2 in
+ */*) # IFS parsing is broken
+ IFS=' '
+ set x `echo $directory | tr / ' '`
+ ;;
+ esac
+ IFS=$newline
+ shift
+
+ for filename
+ do
+ path=$prefix$filename
+ prefix=$path/
+ shift
+
+ test -d "$path" || {
+ paths=$path
+ for filename
+ do
+ if [ "$filename" != "." ]; then
+ path=$path/$filename
+ paths=$paths$newline$path
+ fi
+ done
+
+ mkdir $paths || status=$?
+
+ break
+ }
+ done
+ done
+
+exit $status