[Bash-completion-commits] [bash-completion] 01/01: _pnames: Add -s for producing (possibly) truncated names (RedHat: #744406)

Ville Skyttä scop-guest at moszumanska.debian.org
Mon Nov 10 20:38:39 UTC 2014


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 52d8316c5ce4060cf86154eea3ba6fa51447760a
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Mon Nov 10 22:36:49 2014 +0200

    _pnames: Add -s for producing (possibly) truncated names (RedHat: #744406)
    
    pgrep and pkill actually expect these instead of the full names.
---
 bash_completion   | 26 +++++++++++++++-----------
 completions/pgrep |  2 +-
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/bash_completion b/bash_completion
index 24bd2ea..388c5d5 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1051,6 +1051,7 @@ _pgids()
 
 # This function completes on process names.
 # AIX and SunOS prefer X/Open, all else should be BSD.
+# @param $1 if -s, don't try to avoid truncated command names
 [[ $OSTYPE == *@(solaris|aix)* ]] &&
 _pnames()
 {
@@ -1059,17 +1060,20 @@ _pnames()
 } ||
 _pnames()
 {
-    # FIXME: completes "[kblockd/0]" to "0". Previously it was completed
-    # to "kblockd" which isn't correct either. "kblockd/0" would be
-    # arguably most correct, but killall from psmisc 22 treats arguments
-    # containing "/" specially unless -r is given so that wouldn't quite
-    # work either. Perhaps it'd be best to not complete these to anything
-    # for now.
-    # Not using "ps axo comm" because under some Linux kernels, it
-    # truncates command names (see e.g. http://bugs.debian.org/497540#19)
-    COMPREPLY=( $( compgen -X '<defunct>' -W '$( command ps axo command= | \
-        sed -e "s/ .*//" -e "s:.*/::" -e "s/:$//" -e "s/^[[(-]//" \
-            -e "s/[])]$//" | sort -u )' -- "$cur" ) )
+    if [[ "$1" == -s ]]; then
+        COMPREPLY=( $( compgen -X '<defunct>' \
+            -W '$( command ps axo comm | sed -e 1d )' -- "$cur" ) )
+    else
+        # FIXME: completes "[kblockd/0]" to "0". Previously it was completed
+        # to "kblockd" which isn't correct either. "kblockd/0" would be
+        # arguably most correct, but killall from psmisc 22 treats arguments
+        # containing "/" specially unless -r is given so that wouldn't quite
+        # work either. Perhaps it'd be best to not complete these to anything
+        # for now.
+        COMPREPLY=( $( compgen -X '<defunct>' -W '$( command ps axo command= | \
+            sed -e "s/ .*//" -e "s:.*/::" -e "s/:$//" -e "s/^[[(-]//" \
+                -e "s/[])]$//" | sort -u )' -- "$cur" ) )
+    fi
 }
 
 # This function completes on user IDs
diff --git a/completions/pgrep b/completions/pgrep
index 0a1c862..d98ead1 100644
--- a/completions/pgrep
+++ b/completions/pgrep
@@ -39,7 +39,7 @@ _pgrep()
         return
     fi
 
-    _pnames
+    _pnames -s
 } &&
 complete -F _pgrep pgrep pkill
 

-- 
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