On Fri, Jan 31, 2020 at 02:29:08AM +0100, Nicolas Braud-Santoni wrote:
> Please find enclosed a patch that fixes the issue,
> using pgrep(1) instead of ps(1).

This works better if I recall to attach the patch  >_>'
Subject: gparted: Use pgrep(1) instead of ps(1) and grep(1)

Unlike ps(1), pgrep(1) is not affected by environment variables such as
PS_FORMAT, so it is safe to use without assuming PS_FORMAT is similar-enough
to the default.

Moreover, this is more efficient and less error-prone.
---
 gparted.in | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gparted.in b/gparted.in
index 3f9b0f1..a4e71ff 100755
Origin: vendor
Bug-Debian: https://bugs.debian.org/864932
From: Nicolas Braud-Santoni <ni...@debian.org>
Forwarded: no
Applied-Upstream: no
Last-Update: 2020-01-31

--- a/gparted.in
+++ b/gparted.in
@@ -30,7 +30,7 @@
 #
 #  Only permit one instance of GParted to execute at a time
 #
-if test "z`ps -e | grep gpartedbin`" != "z"; then
+if test -n "$(pgrep gpartedbin)"; then
 	echo "The process gpartedbin is already running."
 	echo "Only one gpartedbin process is permitted."
 	exit 1
@@ -94,7 +94,7 @@ fi
 HAVE_SYSTEMCTL=no
 for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
 	if test -x "$k/systemctl"; then
-		if test "z`ps -e | grep systemd`" != "z"; then
+		if test -n "$(pgrep systemd)"; then
 			HAVE_SYSTEMCTL=yes
 			break
 		fi
@@ -107,7 +107,7 @@ done
 #
 HAVE_UDISKS2_INHIBIT=no
 if test -x "/usr/lib/udisks2/udisks2-inhibit"; then
-	if test "z`ps -e | grep 'udisksd'`" != "z"; then
+	if test -n "$(pgrep udisksd)"; then
 		HAVE_UDISKS2_INHIBIT=yes
 	fi
 fi
@@ -119,7 +119,7 @@ fi
 HAVE_UDISKS=no
 for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
 	if test -x "$k/udisks"; then
-		if test "z`ps -e | grep udisks-daemon`" != "z"; then
+		if test -n "$(pgrep udisks-daemon)"; then
 			HAVE_UDISKS=yes
 			break
 		fi
@@ -133,7 +133,7 @@ done
 HAVE_HAL_LOCK=no
 for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
 	if test -x "$k/hal-lock"; then
-		if test "z`ps -e | grep hald`" != "z"; then
+		if test -n "$(pgrep hald)"; then
 			HAVE_HAL_LOCK=yes
 			break
 		fi

Attachment: signature.asc
Description: PGP signature

Reply via email to