Bash:Variables

From wiki
Revision as of 16:29, 18 August 2018 by Hdridder (talk | contribs) (Created page with "Bash is a *nix shell To check within a startup script (like .bashrc) whether or not Bash is running interactively. Test if $- has an 'i' in it or if $PS1 (the prompt) exists....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Bash is a *nix shell

To check within a startup script (like .bashrc) whether or not Bash is running interactively. Test if $- has an 'i' in it or if $PS1 (the prompt) exists.

case "$-" in
*i*)	echo This shell is interactive ;;
*)	echo This shell is not interactive ;;
esac

if [ -z "$PS1" ]; then
        echo This shell is not interactive
else
        echo This shell is interactive