]> arthur.barton.de Git - ax-make.git/blobdiff - scripts/axify
axify: Simplify AUTHORS file creation
[ax-make.git] / scripts / axify
index ccd7b8db395d9b685c020d031f4ab3e12bf43e93..93adf396671bffea3568c3e3b1f9f5c75a9498e8 100755 (executable)
 
 NAME=`basename "$0"`
 
+Usage() {
+       echo "Usage: $NAME [<lib-dir>]"
+       echo
+       echo "  <lib-dir>    Library directory. Default: current working directory."
+       echo
+       exit 2
+}
+
+while true; do
+       case "$1" in
+               "-"*)
+                       Usage
+                       ;;
+               *)
+                       break
+                       ;;
+       esac
+       shift
+done
+
+[ $# -gt 1 ] && Usage
+
 [ -n "$1" ] && LIB_D="$1" || LIB_D="."
 
 if [ -r "/usr/local/share/ax-make/Makefile.ax" ]; then
@@ -25,7 +47,9 @@ fi
 
 # -- Makefile.ax --
 
-[ ! -d "$LIB_D" ] && mkdir -pv "$LIB_D"
+if [ ! -d "$LIB_D" ]; then
+       mkdir -pv "$LIB_D" || exit 1
+fi
 
 target="$LIB_D/`basename "$MAKEFILE_AX"`"
 if [ ! -e "$target" -o "$MAKEFILE_AX" -nt "$target" ]; then
@@ -64,16 +88,14 @@ fi
 
 # --- Standard project files ---
 
-authors=AUTHORS
 if [ ! -e AUTHORS ]; then
        if git --version >/dev/null 2>&1; then
                echo "Creating \"AUTHORS\" file ..."
                echo "`git config user.name` <`git config user.email`>" >>AUTHORS
-               authors=
        fi
 fi
 
-for f in $authors COPYING README; do
+for f in AUTHORS COPYING README; do
        if [ ! -e "$f" ]; then
                echo "Creating empty \"$f\" file ..."
                touch "$f"