]> arthur.barton.de Git - ngircd.git/commitdiff
Test suite: Don't use "pgrep -u" when LOGNAME and USER are not set
authorAlexander Barton <alex@barton.de>
Sat, 13 Apr 2024 13:52:33 +0000 (15:52 +0200)
committerAlexander Barton <alex@barton.de>
Sat, 13 Apr 2024 13:54:06 +0000 (15:54 +0200)
Thanks for reporting this on IRC, luca!

src/testsuite/getpid.sh

index 8505914208e68538013bd0777d40d380ccbe2fc7..3cc186e1c9b8ff3c1b02d38484614dffb20aeb20 100755 (executable)
@@ -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