From: Sami Kerola Date: Sat, 26 Aug 2017 12:45:13 +0000 (+0100) Subject: bash-completion: simplify pid listing X-Git-Tag: v2.31-rc1~102 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=75c5f4a516079cf0ddc1896f80c2d56e211f1f50;p=thirdparty%2Futil-linux.git bash-completion: simplify pid listing Changing directory in subshell does not effect parent process, so this is better and possibly quicker way to list pids. Signed-off-by: Sami Kerola --- diff --git a/bash-completion/nsenter b/bash-completion/nsenter index ceea610016..ad56f06e48 100644 --- a/bash-completion/nsenter +++ b/bash-completion/nsenter @@ -15,7 +15,7 @@ _nsenter_module() ;; '-t'|'--target') local PIDS - PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) + PIDS=$(cd /proc && echo [0-9]*) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;; diff --git a/bash-completion/prlimit b/bash-completion/prlimit index f5e00bb167..fc60c64610 100644 --- a/bash-completion/prlimit +++ b/bash-completion/prlimit @@ -6,7 +6,7 @@ _prlimit_module() prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-p'|'--pid') - PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) + PIDS=$(cd /proc && echo [0-9]*) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;; diff --git a/bash-completion/renice b/bash-completion/renice index c3e9331b08..2495f37851 100644 --- a/bash-completion/renice +++ b/bash-completion/renice @@ -17,7 +17,7 @@ _renice_module() ;; '-p'|'--pid') local PIDS - PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) + PIDS=$(cd /proc && echo [0-9]*) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;; diff --git a/bash-completion/taskset b/bash-completion/taskset index 8e62a3b676..453b17b4ae 100644 --- a/bash-completion/taskset +++ b/bash-completion/taskset @@ -25,7 +25,7 @@ _taskset_module() # setting an affinity the optarg has to be cpu # mask. The following is good only for getting # affinity. - PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) + PIDS=$(cd /proc && echo [0-9]*) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;;