[Bash-completion-commits] [SCM] bash-completion branch, master, updated. d13d73345ea6c23fba54c335e0f839d27fe7f8a5
Guillaume Rousse
guillaume at oberkampf.msr-inria.inria.fr
Sun Sep 20 20:10:36 UTC 2009
The following commit has been merged in the master branch:
commit 0643ce2567e68d1f501ca15a2fa29749cf56df21
Author: Guillaume Rousse <guillaume at oberkampf.msr-inria.inria.fr>
Date: Sun Sep 20 22:12:18 2009 +0200
simpler interface (kiss rules)
diff --git a/install-completions b/install-completions
index 37f504b..0cbf4d0 100755
--- a/install-completions
+++ b/install-completions
@@ -3,37 +3,43 @@
# found in a given directory, and symlinking those matching
# 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
- d) debug=1;;
- i) install=1;;
+ h) usage; exit 0;;
esac
done
shift $((OPTIND - 1))
-if [ $# -ne 2 ]; then
- echo "usage: $0 <completion_dir> <installation_dir>"
+completion_dir=$1
+if [ -z "$completion_dir" ]; then
+ echo "missing completion directory"
+ usage
exit 1
fi
-
-completion_dir=$1
if [ ! -d $completion_dir ]; then
echo "invalid directory $completion_dir"
+ usage
exit 1
fi
installation_dir=$2
if [ ! -d $installation_dir ]; then
echo "invalid directory $installation_dir"
+ usage
exit 1
fi
-have()
-{
- PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null
-}
-
# many scripts requires this
shopt -s extglob
@@ -46,15 +52,15 @@ for script in $completion_dir/*; do
# check completion output
output=$(complete -p)
- if [ -n "$output" ]; then
- if [ -n "$install" ]; then
- ln -sf $script $installation_dir/$(basename $script)
- else
- echo "$script OK"
- fi
+
+ if [ -z "$output" ]; then
+ continue
fi
- if [ -n "$debug" ]; then
- echo $output
+ if [ -n "$installation_dir" ]; then
+ ln -sf $script $installation_dir/$(basename $script)
+ else
+ echo "$script OK"
fi
+
done
--
bash-completion
More information about the Bash-completion-commits
mailing list