findlinks, mklinks, mdw-setup: Spruce up style.
[cfd] / mklinks.in
index af3ac2c..0d57afd 100755 (executable)
@@ -1,40 +1,39 @@
 #! /bin/sh
+### -*-sh-*-
+###
+### Create links to the repository
+###
+### (c) 1997 Mark Wooding
+###
 
-# -*-sh-*-
-#
-# Create links to the repository
-#
-# (c) 1997 Mark Wooding
-#
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the Common Files Distribution (`common').
+###
+### `Common' is free software; you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 2 of the License, or
+### (at your option) any later version.
+###
+### `Common' is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with `common'; if not, write to the Free Software Foundation,
+### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-#----- Licensing notice -----------------------------------------------------
-#
-# This file is part of the Common Files Distribution (`common').
-#
-# `Common' is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# `Common' is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with `common'; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+set -e
 
-# --- Configuration variables ---
+pkgdatadir="@pkgdatadir@"
+VERSION="@VERSION@"
 
-prefix=@prefix@
-datarootdir=@datarootdir@
-datadir=@datadir@/@PACKAGE@
-
-# --- Parse command line arguments ---
+###--------------------------------------------------------------------------
+### Parse command line arguments.
 
 while [ $# -gt 0 ]; do
-  case $1 in
+  case "$1" in
     -h | --h | --he | --hel | --help)
       cat <<EOF
 Usage: mklinks [FILE...]
@@ -46,9 +45,7 @@ EOF
       exit 0
       ;;
     -v | --v | --ve | --ver | --vers | --versi | --versio | --version)
-      version=`echo '$Revision: 1.4 $' |
-       sed -n -e 's;^.*: \([0-9.]*\) *\\$;\1;p'`
-      echo "mklinks $version; Common Files Distribution version @VERSION@"
+      echo "mklinks: Common Files Distribution version $VERSION"
       exit 0
       ;;
     --)
@@ -67,14 +64,17 @@ EOF
       ;;
   esac
   shift
-done  
+done
 
-# --- Main code ---
-#
-# This is really trivial.
+###--------------------------------------------------------------------------
+### Main code.
 
 [ $# = 0 ] && set .links
 cat "$@" | while read name; do
-  base="`echo $name | sed -e 's;^.*/;;'`"
-  [ -r "$datadir/$base" ] && ln -sf "$datadir/$base" "$name"
+  base="$(echo $name | sed 's;^.*/;;')"
+  dir="$(echo $name | sed 's;/[^/]*$;;')"
+  mkdir -p "$dir"
+  [ -r "$pkgdatadir/$base" ] && ln -sf "$pkgdatadir/$base" "$name"
 done
+
+###----- That's all, folks --------------------------------------------------