| GNU Bash Reference Manual by Chet Ramey and Brian Fox Paperback (6"x9"), 180 pages ISBN 0954161777 RRP £19.95 ($29.95) "An essential resource .... the most detailed coverage available for all aspects of Bash" --- Linux User and Developer Magazine (Issue 37, Mar 2004) Get a printed copy>>> |
6.3.2 Is this Shell Interactive?
To determine within a startup script whether or not Bash is
running interactively,
test the value of the ‘-’ special parameter.
It contains i when the shell is interactive. For example:
case "$-" in *i*) echo This shell is interactive ;; *) echo This shell is not interactive ;; esac
Alternatively, startup scripts may examine the variable
PS1; it is unset in non-interactive shells, and set in
interactive shells. Thus:
if [ -z "$PS1" ]; then
echo This shell is not interactive
else
echo This shell is interactive
fi
| ISBN 0954161777 | GNU Bash Reference Manual | See the print edition |