about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2024-04-13 15:52:33 +0200
committerAlexander Barton <alex@barton.de>2024-04-13 15:54:06 +0200
commita33d15751b3e3910bd06125efbeae6569844f313 (patch)
tree18539c34266ff2d433fb6473d73537f7da6c3b64 /src
parentb362b5a94554a3f4818c90bf54f8715b58ab923b (diff)
downloadngircd-a33d15751b3e3910bd06125efbeae6569844f313.tar.gz
ngircd-a33d15751b3e3910bd06125efbeae6569844f313.zip
Test suite: Don't use "pgrep -u" when LOGNAME and USER are not set
Thanks for reporting this on IRC, luca!
Diffstat (limited to 'src')
-rwxr-xr-xsrc/testsuite/getpid.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/testsuite/getpid.sh b/src/testsuite/getpid.sh
index 85059142..3cc186e1 100755
--- a/src/testsuite/getpid.sh
+++ b/src/testsuite/getpid.sh
@@ -23,7 +23,13 @@ if [ -x /usr/bin/pgrep ]; then
 		*)
 			PGREP_FLAGS=""
 	esac
-	exec /usr/bin/pgrep $PGREP_FLAGS -n -u "${LOGNAME:-$USER}" "$1"
+	if [ -n "$LOGNAME" ] || [ -n "$USER" ]; then
+		# Try to narrow the search down to the current user ...
+		exec /usr/bin/pgrep $PGREP_FLAGS -n -u "${LOGNAME:-$USER}" "$1"
+	else
+		# ... but neither LOGNAME nor USER were set!
+		exec /usr/bin/pgrep $PGREP_FLAGS -n "$1"
+	fi
 fi
 
 # pidof(1) could be a good alternative on elder Linux systems