Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt
-fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection -fno-omit-frame-pointer
-mno-omit-leaf-frame-pointer -flto=auto
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin'
-DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc'
-DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
-std=gnu17
uname output: Linux svelte 6.18.38-1-MANJARO #1 SMP PREEMPT_DYNAMIC Sat, 04 Jul
2026 20:51:33 +0000 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.3
Patch Level: 15
Release Status: release
Documentation inaccuracy in the manual's description of the `-n`
(noexec) option as it applies to interactive shells.
The bash manual, section 4.3.1 `The Set Builtin`, says:
-n
Read commands but do not execute them. This may be used to
check a script for syntax errors. This option is ignored by
interactive shells.
This wording is misleading. In practice:
* `set -n` at runtime in an interactive shell is ignored, matching
the manual.
* `bash -n` on the command line is honored even when the shell is
interactive: on a tty it prints the interactive prompt but does
not execute any commands.
Recipe:
$ bash --norc -n
bash-5.3$ echo hello
bash-5.3$ exit
The prompt appears, but `echo hello` is never executed. Per the
manual's wording, an interactive shell should have ignored `-n` and
run the command.
The manual's `ignored by interactive shells` does not distinguish
launch-time `-n` from runtime `set -n`. I suggest clarifying the
wording, for example:
-n
Read commands but do not execute them. This may be used to
check a script for syntax errors. This option is ignored by
interactive shells, except when supplied on the command line
at startup, in which case it applies even to interactive
shells.
Prior discussion on this list: the August 2024 thread `[PATCH]
Correct error message when using -n and -o ignoreeof in interactive
mode`, where it was noted that `It is however possible to run an
interactive noexec bash if it is set on launch.`
--
Tom Hale