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.
   3 # shutdown -- wrapper script to prevent erroneous shutdowns via SSH
 
   5 # Copyright © martin f. krafft <madduck@madduck.net>
 
   6 # Released under the terms of the Artistic Licence 2.0
 
   8 # $Id: shutdown 299 2006-10-16 14:40:47Z madduck $
 
  19     if [ ! -f $EXEC ]; then
 
  20       echo "E: $ME: not a regular file: $EXEC" >&2
 
  23     if [ ! -x $EXEC ]; then
 
  24       echo "E: $ME: not an executable: $EXEC" >&2
 
  29     echo "E: $ME: unsupported command: $CMD" >&2
 
  38     (*--molly-guard-do-nothing*)
 
  39       ARGS0="${ARGS%%--molly-guard-do-nothing*}"
 
  40       ARGS1="${ARGS##*--molly-guard-do-nothing}"
 
  41       echo "$ME: would run: $EXEC $ARGS0 $ARGS1"
 
  43     *) exec $EXEC "$ARGS";;
 
  47 # require $SSH_CONNECTION to be set, indicates an SSH session
 
  48 [ -n "${SSH_CONNECTION:-}" ] || do_real_cmd
 
  49 # require an interactive terminal connected to stdin
 
  50 test -t 0                    || do_real_cmd
 
  51 # pass through help commands
 
  53   (shutdown\ *-c*) do_real_cmd;;
 
  58 HOSTNAME="$(hostname)"
 
  62   echo "Good thing I asked; I won't $CMD $HOSTNAME ..."
 
  66 trap 'echo;sigh' 1 2 3 9 10 12 15
 
  68 echo "$ME: SSH session detected!"
 
  69 echo -n "Please type in hostname of the machine to $CMD: "
 
  70 read HOSTNAME_USER || :
 
  72 [ "$HOSTNAME_USER" = "$HOSTNAME" ] || sigh
 
  74 trap - 1 2 3 9 10 12 15