bash: $-

$- expands to the arguments that bash was executed with.

interactive.bash Interactive Session

#!/usr/local/bin/bash

echo "$-"

case "$-" in
  *i*)
    echo "Interactive shell";;
  *)
    echo "Non-Interactive shell";;
esac

bash#
bash#
bash# . ./interactive.bash
himBH
Interactive shell
bash#
bash# ./interactive.bash
hB
Non-Interactive shell
bash#
bash#


Roger
Roger Hall
COMPUSPEC
Google
 
Web Compuspec.net
Valid XHTML 1.0!
Valid CSS!