From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/bash/is-this-shell-interactive_003f.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 devdocs/bash/is-this-shell-interactive_003f.html (limited to 'devdocs/bash/is-this-shell-interactive_003f.html') diff --git a/devdocs/bash/is-this-shell-interactive_003f.html b/devdocs/bash/is-this-shell-interactive_003f.html new file mode 100644 index 00000000..d01a311e --- /dev/null +++ b/devdocs/bash/is-this-shell-interactive_003f.html @@ -0,0 +1,17 @@ +

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
+
+
+

+ Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
Licensed under the GNU Free Documentation License.
+ https://www.gnu.org/software/bash/manual/html_node/Is-this-Shell-Interactive_003f.html +

+
-- cgit v1.2.3