2012-04-18 00:17:01 +03:00
|
|
|
#!/bin/sh -e
|
|
|
|
#
|
2012-06-26 03:04:59 +03:00
|
|
|
# mkgencat-wrapper - Generate wrapper script for gencat
|
2012-04-18 00:17:01 +03:00
|
|
|
#
|
|
|
|
# Copyright 2012 by Werner Almesberger
|
|
|
|
#
|
|
|
|
# This program 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.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
MODE=555
|
|
|
|
DIR=
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo "usage: $0 [-m mode] [-p directory] wrapper-path" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while [ "$1" ]; do
|
|
|
|
case "$1" in
|
|
|
|
-m) shift
|
|
|
|
MODE=$1;;
|
|
|
|
-p) shift
|
|
|
|
DIR=$1;;
|
|
|
|
-*) usage;;
|
|
|
|
*) break;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
: ${DIR:=`dirname $1`}
|
|
|
|
|
|
|
|
[ -d "$DIR" ] && [ "$1" ] && [ -z "$2" ] || usage
|
|
|
|
|
|
|
|
trap "rm -f _wrapper" 0
|
|
|
|
|
|
|
|
cat <<EOF >_wrapper
|
|
|
|
#!/bin/sh
|
|
|
|
PATH=\$PATH:$DIR
|
2012-06-26 03:04:59 +03:00
|
|
|
exec gencat-bin "\$@"
|
2012-04-18 00:17:01 +03:00
|
|
|
EOF
|
|
|
|
chmod $MODE _wrapper
|
|
|
|
|
|
|
|
mv _wrapper "$1"
|