File: ensure-dir.sh

package info (click to toggle)
zephyr 3.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 4,744 kB
  • ctags: 2,626
  • sloc: ansic: 41,183; sh: 8,927; makefile: 849; python: 416; yacc: 250; lisp: 127
file content (21 lines) | stat: -rwxr-xr-x 337 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

pathname=$1
mode=$2
OLDIFS="${IFS}"; IFS=/; set $pathname; IFS="${OLDIFS}"

case $pathname in
	/*)	partial=/; ;;
	*)	partial=""; ;;
esac

for i do
	case i in "") continue; ;; esac
	partial="${partial}${i}"
	if [ ! -d ${partial} ]; then
		mkdir ${partial} || exit 1;
		chmod ${mode} ${partial}
	fi
	partial="${partial}/"
done