shopt-option
restricted_shell — restricted shell state
Reports whether Bash was started in restricted mode. This is a startup state, not a switch for imposing restrictions on an existing ordinary shell. Restricted Bash is not a secure sandbox. Compare ordinary and restricted disposable child shells. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): ordinary; restricted.
Formal Syntax & Structure
bash syntaxbash
shopt -q restricted_shellReturn Value
exit status
Query returns zero when restricted mode is active, one otherwise.
Working Example
Example Snippetbash
if shopt -q restricted_shell; then exit 1; fiprintf 'ordinary\n'bash --noprofile --norc --restricted -c 'shopt -q restricted_shell || exit 1; printf "restricted\n"'