About
An Interactive shell 1) is created when bash is:
- started:
- without non-option arguments
- without the -c option
- or started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state. See testing_for_interactive_mode
Management
Argument
When invoking an interactive shell, you can set the positional parameters with the -s option of bash. See Bash - Bash cli
Testing for Interactive mode
- Testing for Interactive mode
if [[ $- == *i* ]]
then
echo "Interactive"
fi
where
- - is a special parameter representing the option of the shell