#!/bin/ksh # @(#) Skeleton command #..# systems: #..# sites: #..# level: #..# publish: y ## #..# publish: n #..# keys: #..# date: #..# vers: 1.1 13/Jul/2005-10:09 #..# vers: 1.3 03/Aug/2006-15:57 ## [ $0 = ${0#/} ] && this=$(pwd -H)/$0 || this=$0 tag=${0##*/} tm=/tmp/${tag} tmp=${tm}$$ #rm -f ${tm}+([0-9]) set -A AWK $(whence nawk) [ ${#AWK[*]} -gt 0 -a "${AWK[0]}" != no ] && alias awk=${AWK[0]} usage="Usage: $tag " while [ $# -gt 0 ]; do case "$1" in -v|-x) set "$1" ;; -vi) lockvi $this; exit ;; -view) view $this; exit ;; -about) echo "$tag was written by David Ledger" echo "dledger@ivdcs.co.uk" echo "Free to use at your own risk" echo "Copyright 2006" exit ;; -ver) ver=$(egrep '#..#[ ]*vers:' $this) ver=${ver#"${ver%%[1-9]*}"} print ${ver%%[!0-9.]*} exit ;; -h) echo "" echo "$usage" echo "" echo "$tag " echo "" exit ;; --) ;; -*) opt="$1" shift set -- -- $(getopt hvx $opt) $@ || exit ;; *) f="$1" ## [ "${f##*/}" = $f ] && { ## [ "${LOGNAME%0}" = "$LOGNAME" ] && { ## f=~/bin/$f ## } || { ## f=~${LOGNAME%0} ## f=$(ls -d $f)/bin/$f ## print $f ## }; } ## [ -s $f ] && { ## echo "$f already exists" ## exit; } ## ksh -c "touch $f; chmod 666 $f" ## awk ' ## /[ ]*##[ ]*$/ { next } ## /#..# date:/ { ## print $0 "'"$(date)"'" ## next ## } ## { print } ## ' $0 > $f ## chmod 755 $f ## chown ${LOGNAME%0} $f ## [ "${LOGNAME%0}" = "$LOGNAME" ] && ## [ "$f" != ~/bin/${f##*/} ] && ## ln -s $f ~/bin/${f##*/} ## ;; esac shift done