]> git.madduck.net Git - code/molly-guard.git/blobdiff - shutdown

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

* Prevent set -u from falling over unset SSH_CONNECTION variable
[code/molly-guard.git] / shutdown
index 24898273d6fc6ab41691583bbe716e8c84048118..0c52d92803e65b8e7615b918e9910e7ea55102b6 100755 (executable)
--- a/shutdown
+++ b/shutdown
@@ -90,12 +90,13 @@ test -t 0                    || do_real_cmd
 # only run if we are being called over SSH, that is if the current terminal
 # was created by sshd.
 PTS=$(readlink /proc/$$/fd/0)
 # only run if we are being called over SSH, that is if the current terminal
 # was created by sshd.
 PTS=$(readlink /proc/$$/fd/0)
-if ! pgrep -f "^sshd.+${PTS#/dev/}[[:space:]]*$" >/dev/null; then
-  if [ $PRETEND_SSH -eq 1 ]; then
-    echo "I: this is not an SSH session, but --pretend-ssh was given..."
-  else
-    do_real_cmd
-  fi
+if ! pgrep -f "^sshd.+${PTS#/dev/}[[:space:]]*$" >/dev/null \
+  && [ -z "${SSH_CONNECTION:-}" ]; then
+    if [ $PRETEND_SSH -eq 1 ]; then
+      echo "I: this is not an SSH session, but --pretend-ssh was given..."
+    else
+      do_real_cmd
+    fi
 else
   echo "W: $ME: SSH session detected!"
 fi
 else
   echo "W: $ME: SSH session detected!"
 fi