[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 74128a73ce3448574ca886c568d9c7f3e2c1c3e9

Ville Skyttä ville.skytta at iki.fi
Sun Jan 23 22:20:39 UTC 2011


The following commit has been merged in the master branch:
commit 74128a73ce3448574ca886c568d9c7f3e2c1c3e9
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Mon Jan 24 00:20:32 2011 +0200

    Add mktemp(1) completion.

diff --git a/CHANGES b/CHANGES
index 6d756ed..2cc0dc2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -13,9 +13,9 @@ bash-completion (2.x)
   [ Ville Skyttä ]
   * Activate hping2 completion also for hping and hping3.
   * Add badblocks, compgen, crontab, dumpe2fs, e2freefrag, e2label, ether-wake,
-    filefrag, growisofs, iftop, ip (Debian: #600617), lrzip, lsof, portecle,
-    POSIX sh, sha{,224,256,384,512}sum, sysbench, tune2fs, xmodmap, and xrdb
-    completions.
+    filefrag, growisofs, iftop, ip (Debian: #600617), lrzip, lsof, mktemp,
+    portecle, POSIX sh, sha{,224,256,384,512}sum, sysbench, tune2fs, xmodmap,
+    and xrdb completions.
   * Add *.gif (Alioth: #312512), *.m2t (Alioth: #312770), *.3gpp, *.3gpp2,
     *.awb, and *.iso (Alioth: #311420) to mplayer filename completions.
   * Add "short" tarball extensions to unxz, unlzma etc completions.
diff --git a/completions/coreutils b/completions/coreutils
index 299aabe..33d58cf 100644
--- a/completions/coreutils
+++ b/completions/coreutils
@@ -112,6 +112,34 @@ _id()
 } &&
 complete -F _id id
 
+# mktemp(1) completion
+#
+have mktemp &&
+_mktemp()
+{
+    COMPREPLY=()
+    local cur prev split=false
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        --help|--version|--suffix)
+            return 0
+            ;;
+        --tmpdir|-p)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    [[ "$cur" == -* ]] && \
+        COMPREPLY=( $( compgen -W '-d -u -q -p -t' -- "$cur" ) )
+} &&
+complete -F _mktemp mktemp
+
 # Local variables:
 # mode: shell-script
 # sh-basic-offset: 4
diff --git a/test/completion/mktemp.exp b/test/completion/mktemp.exp
new file mode 100644
index 0000000..b829686
--- /dev/null
+++ b/test/completion/mktemp.exp
@@ -0,0 +1 @@
+assert_source_completions mktemp
diff --git a/test/lib/completions/a2ps.exp b/test/lib/completions/mktemp.exp
similarity index 79%
copy from test/lib/completions/a2ps.exp
copy to test/lib/completions/mktemp.exp
index 77cd07f..8b0a3be 100644
--- a/test/lib/completions/a2ps.exp
+++ b/test/lib/completions/mktemp.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "a2ps "
+assert_complete_any "mktemp -"
 
 
 sync_after_int

-- 
bash-completion



More information about the Bash-completion-commits mailing list