Mercurial > ~dholland > hg > ag > index.cgi
comparison mk/mkinstalldirs.sh @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 #!/bin/sh | |
2 # mkinstalldirs - create install directories | |
3 # usage: mkinstalldirs dirs | |
4 | |
5 # make this work right even if someone puts spaces in | |
6 ( | |
7 while [ "x$1" != x ]; do | |
8 echo "$1" | |
9 shift | |
10 done | |
11 ) | awk '{ | |
12 if ($0 ~ "^/") { | |
13 lead = "/"; | |
14 sub("^/", "", $0); | |
15 } | |
16 else { | |
17 lead = ""; | |
18 } | |
19 | |
20 n = split($0, a, "/"); | |
21 | |
22 for (i=1;i<=n;i++) { | |
23 printf "%s", lead; | |
24 for (j=1;j<=i;j++) { | |
25 printf "%s", a[j]; | |
26 if (j<i) printf "/"; | |
27 } | |
28 printf "\n"; | |
29 } | |
30 }' | sort -u | awk '{ | |
31 printf "if [ ! -d \"%s\" ]; then\n", $0; | |
32 printf " echo \" [MKDIR] %s\"\n", $0; | |
33 printf " mkdir \"%s\" || exit 1\n", $0; | |
34 printf " chmod 755 \"%s\"\n", $0; | |
35 printf "fi\n" | |
36 }' | sh |