[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 063013969700f71d4edc911ac6dee7c4e3a7b744
Ville Skyttä
ville.skytta at iki.fi
Sun Sep 5 08:02:40 UTC 2010
The following commit has been merged in the master branch:
commit 063013969700f71d4edc911ac6dee7c4e3a7b744
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Sun Sep 5 11:02:03 2010 +0300
Add POSIX sh completion.
diff --git a/CHANGES b/CHANGES
index 1628488..79c8396 100644
--- a/CHANGES
+++ b/CHANGES
@@ -8,7 +8,7 @@ bash-completion (2.x)
[ Ville Skyttä ]
* Activate hping2 completion also for hping and hping3.
- * Add crontab and lrzip completions.
+ * Add crontab, lrzip, and POSIX sh completions.
* Add *.gif (Alioth: #312512), *.3gpp, *.3gpp2, and *.awb to mplayer
filename completions.
* Add "short" tarball extensions to unxz, unlzma etc completions.
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index f8420e1..3733c60 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -129,6 +129,7 @@ static_bashcomp = abook \
sbcl \
screen \
service \
+ sh \
shadow \
sitecopy \
smartctl \
diff --git a/contrib/sh b/contrib/sh
new file mode 100644
index 0000000..f33705d
--- /dev/null
+++ b/contrib/sh
@@ -0,0 +1,41 @@
+# POSIX sh(1) completion
+
+have sh &&
+_sh()
+{
+ COMPREPLY=()
+ local cur prev
+ _get_comp_words_by_ref cur prev
+
+ case $prev in
+ -c)
+ return 0
+ ;;
+ -o|+o)
+ COMPREPLY=( $( compgen -W 'allexport errexit ignoreeof monitor
+ noclobber noglob noexec nolog notify nounset verbose vi
+ xtrace' -- "$cur" ) )
+ return 0
+ ;;
+ esac
+
+ local opts="-a -b -C -e -f -h -i -m -n -o -u -v -x"
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W "$opts -c -s" -- "$cur" ) )
+ return 0
+ elif [[ "$cur" == +* ]]; then
+ COMPREPLY=( $( compgen -W "${opts//-/+}" -- "$cur" ) )
+ return 0
+ fi
+
+ _filedir sh
+} &&
+complete -F _sh -o filenames sh
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 4
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/test/completion/sh.exp b/test/completion/sh.exp
new file mode 100644
index 0000000..599f3b2
--- /dev/null
+++ b/test/completion/sh.exp
@@ -0,0 +1 @@
+assert_source_completions sh
diff --git a/test/lib/completions/sh.exp b/test/lib/completions/sh.exp
new file mode 100644
index 0000000..e1a51bb
--- /dev/null
+++ b/test/lib/completions/sh.exp
@@ -0,0 +1,38 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "sh -"
+
+
+sync_after_int
+
+
+assert_complete_any "sh +"
+
+
+sync_after_int
+
+
+assert_complete_any "sh -o "
+
+
+sync_after_int
+
+
+assert_no_complete "sh -c "
+
+
+sync_after_int
+
+
+teardown
--
bash-completion
More information about the Bash-completion-commits
mailing list