util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>
Subject: [PATCH] bash-completion: simplify pid listing
Date: Sat, 26 Aug 2017 13:45:13 +0100	[thread overview]
Message-ID: <20170826124513.7823-1-kerolasa@iki.fi> (raw)

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 <kerolasa@iki.fi>
---
 bash-completion/nsenter | 2 +-
 bash-completion/prlimit | 2 +-
 bash-completion/renice  | 2 +-
 bash-completion/taskset | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bash-completion/nsenter b/bash-completion/nsenter
index ceea61001..ad56f06e4 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 f5e00bb16..fc60c6461 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 c3e9331b0..2495f3785 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 8e62a3b67..453b17b4a 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
 			;;
-- 
2.14.1


                 reply	other threads:[~2017-08-26 12:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170826124513.7823-1-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).