Mercurial > ~dholland > hg > ag > index.cgi
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mk/mkinstalldirs.sh Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,36 @@ +#!/bin/sh +# mkinstalldirs - create install directories +# usage: mkinstalldirs dirs + +# make this work right even if someone puts spaces in +( + while [ "x$1" != x ]; do + echo "$1" + shift + done +) | awk '{ + if ($0 ~ "^/") { + lead = "/"; + sub("^/", "", $0); + } + else { + lead = ""; + } + + n = split($0, a, "/"); + + for (i=1;i<=n;i++) { + printf "%s", lead; + for (j=1;j<=i;j++) { + printf "%s", a[j]; + if (j<i) printf "/"; + } + printf "\n"; + } +}' | sort -u | awk '{ + printf "if [ ! -d \"%s\" ]; then\n", $0; + printf " echo \" [MKDIR] %s\"\n", $0; + printf " mkdir \"%s\" || exit 1\n", $0; + printf " chmod 755 \"%s\"\n", $0; + printf "fi\n" +}' | sh