[Bash-completion-commits] [bash-completion] 01/01: timeout: New completion.

Ville Skyttä scop-guest at alioth.debian.org
Tue Oct 22 19:01:31 UTC 2013


This is an automated email from the git hooks/post-receive script.

scop-guest pushed a commit to branch master
in repository bash-completion.

commit 63b499593a595cffd09403852555577e3f590cb5
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Tue Oct 22 22:01:09 2013 +0300

    timeout: New completion.
---
 completions/Makefile.am          |    1 +
 completions/timeout              |   38 ++++++++++++++++++++++++++++++++++++++
 test/completion/timeout.exp      |    1 +
 test/lib/completions/timeout.exp |   21 +++++++++++++++++++++
 4 files changed, 61 insertions(+)

diff --git a/completions/Makefile.am b/completions/Makefile.am
index 90ffd9e..5305f3a 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -332,6 +332,7 @@ bashcomp_DATA = 2to3 \
 		tcpdump \
 		tcpkill \
 		tcpnice \
+		timeout \
 		tracepath \
 		tshark \
 		tune2fs \
diff --git a/completions/timeout b/completions/timeout
new file mode 100644
index 0000000..33fb0af
--- /dev/null
+++ b/completions/timeout
@@ -0,0 +1,38 @@
+# timeout(1) completion                                    -*- shell-script -*-
+
+_timeout()
+{
+    local cur prev words cword split i found=false
+    _init_completion -s || return
+
+    for (( i=1; i <= COMP_CWORD; i++ )); do
+        if [[ ${COMP_WORDS[i]} != -* && ${COMP_WORDS[i-1]} != = ]]; then
+            if $found; then 
+                _command_offset $i
+                return
+            fi
+            found=true
+        fi
+        [[ ${COMP_WORDS[i]} == -@(k|-kill-after|s|-signal) ]] && ((i++))
+    done
+
+    case $prev in
+        --help|--version|-k|--kill-after)
+            return
+            ;;
+        -s|--signal)
+            _signals
+            return
+            ;;
+    esac
+
+    $split && return
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+        [[ $COMPREPLY == *= ]] && compopt -o nospace
+    fi
+} &&
+complete -F _timeout timeout
+
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/test/completion/timeout.exp b/test/completion/timeout.exp
new file mode 100644
index 0000000..434a291
--- /dev/null
+++ b/test/completion/timeout.exp
@@ -0,0 +1 @@
+assert_source_completions timeout
diff --git a/test/lib/completions/timeout.exp b/test/lib/completions/timeout.exp
new file mode 100644
index 0000000..f56c80f
--- /dev/null
+++ b/test/lib/completions/timeout.exp
@@ -0,0 +1,21 @@
+proc setup {} {
+    save_env
+}
+
+
+proc teardown {} {
+    assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "timeout -"
+sync_after_int
+
+assert_no_complete "timeout " "1st non-option arg=timeout, shouldn't complete"
+sync_after_int
+
+
+teardown

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git



More information about the Bash-completion-commits mailing list