simpler interface (kiss rules)
This commit is contained in:
parent
f5b6261826
commit
0643ce2567
@ -3,37 +3,43 @@
|
|||||||
# found in a given directory, and symlinking those matching
|
# found in a given directory, and symlinking those matching
|
||||||
# an installed command to another directory
|
# an installed command to another directory
|
||||||
|
|
||||||
while getopts ":di" flag; do
|
have()
|
||||||
|
{
|
||||||
|
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
echo "usage: $0 <completion_dir> [installation_dir]"
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts ":h" flag; do
|
||||||
case $flag in
|
case $flag in
|
||||||
d) debug=1;;
|
h) usage; exit 0;;
|
||||||
i) install=1;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
if [ $# -ne 2 ]; then
|
completion_dir=$1
|
||||||
echo "usage: $0 <completion_dir> <installation_dir>"
|
if [ -z "$completion_dir" ]; then
|
||||||
|
echo "missing completion directory"
|
||||||
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
completion_dir=$1
|
|
||||||
if [ ! -d $completion_dir ]; then
|
if [ ! -d $completion_dir ]; then
|
||||||
echo "invalid directory $completion_dir"
|
echo "invalid directory $completion_dir"
|
||||||
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
installation_dir=$2
|
installation_dir=$2
|
||||||
if [ ! -d $installation_dir ]; then
|
if [ ! -d $installation_dir ]; then
|
||||||
echo "invalid directory $installation_dir"
|
echo "invalid directory $installation_dir"
|
||||||
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
have()
|
|
||||||
{
|
|
||||||
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# many scripts requires this
|
# many scripts requires this
|
||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
|
|
||||||
@ -46,15 +52,15 @@ for script in $completion_dir/*; do
|
|||||||
|
|
||||||
# check completion output
|
# check completion output
|
||||||
output=$(complete -p)
|
output=$(complete -p)
|
||||||
if [ -n "$output" ]; then
|
|
||||||
if [ -n "$install" ]; then
|
if [ -z "$output" ]; then
|
||||||
ln -sf $script $installation_dir/$(basename $script)
|
continue
|
||||||
else
|
|
||||||
echo "$script OK"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$debug" ]; then
|
if [ -n "$installation_dir" ]; then
|
||||||
echo $output
|
ln -sf $script $installation_dir/$(basename $script)
|
||||||
|
else
|
||||||
|
echo "$script OK"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user