-
Notifications
You must be signed in to change notification settings - Fork 6
/
mkdir
executable file
·50 lines (45 loc) · 780 Bytes
/
mkdir
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# $Id$
#
# Make a directory and all it's parents.
# this is how mkdir works on most systems, but not all.
for a in $@ ; do
case $a in
--help)
cat <<EOF
Usage: mkdir [OPTION] DIRECTORY...
-p, --parents no error if existing, make parent directories as needed
--help display this help and exit
--version output version information and exit
EOF
exit
;;
--version)
echo Per hacks 0.0
exit
;;
-p)
recurse=1;
;;
/*)
dname=$a
dir=""
;;
*)
dname=$a
dir="."
;;
esac
done
if [ x$recurse = x ] ; then
/bin/mkdir $dname
exit $?
fi
IFS='/'
for a in $dname; do
IFS=' '
dir="$dir/$a"
if [ ! -d $dir ] ; then
/bin/mkdir $dir || exit 1
fi
done