]> arthur.ath.cx Git - ngircd.git/blobdiff - src/testsuite/getpid.sh
Test suite: Don't use "pgrep -u" when LOGNAME and USER are not set
[ngircd.git] / 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