Skip to contentSkip to conversation

bash-completion: simplify pid listing

PATCH New Sami Kerola 1 participant 1 message Aug 26, 2017 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 bash-completion/nsenter | 2 +-
 bash-completion/prlimit | 2 +-
 bash-completion/renice  | 2 +-
 bash-completion/taskset | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
bash-completion/nsenter +1 -1
index ceea61001..ad56f06e4 100644
@@ -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
 			;;
bash-completion/prlimit +1 -1
index f5e00bb16..fc60c6461 100644
@@ -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
 			;;
bash-completion/renice +1 -1
index c3e9331b0..2495f3785 100644
@@ -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
 			;;
bash-completion/taskset +1 -1
index 8e62a3b67..453b17b4a 100644
@@ -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
 			;;
Signature · 1 line
2.14.1