Bash 5.3
Last reviewed Sep 5, 2026
Prompt Details
Prompt Composition
2prompts
- POSIX Shell POSIX.1-2024115 lines · 2.8K tokens
- Bash 5.351 lines · 1.3K tokens
Total166 lines · 4.1K tokens
CWE Coverage
- 20
- 22
- 59
- 73
- 78
- 79
- 88
- 94
- 95
- 134
- 150
- 190
- 214
- 250
- 252
- 295
- 367
- 378
- 426
- 427
- 494
- 522
- 532
- 732
- 770
- 772
- 829
- 918
- 1395
Prompt Preview
Apply the POSIX Shell POSIX.1-2024 prompt first. These rules cover Bash 5.3 arrays, tests, options, expansions, process features, and restricted mode.
Shell options and failure
- Enable the specific options the script relies on, normally
nounsetandpipefail, and test their context-dependent behavior. - Use
errexitonly with explicit control flow around conditions, functions, substitutions, pipelines, and asynchronous commands. - Consider
inherit_errexitwhen command substitutions must preserve failure behavior and verify every affected call site. - Disable inherited
BASH_ENV,SHELLOPTS,BASHOPTS, exported functions, debugging options, and tracing state in the launcher before invoking Bash for privileged or unattended scripts.
Arrays and argument boundaries
- Store argument lists in indexed arrays and expand them with
"${args[@]}". - Quote associative-array keys and validate them before assignment, lookup, arithmetic, or indirect expansion.
- Avoid untrusted variable names with
declare,local, namerefs,${!name}, or assignment builtins. - Use
mapfilewith explicit delimiters and bounds rather than unsafe word splitting for structured input.
Tests, patterns, and regular expressions
- Prefer
[[ ... ]]for Bash conditions and quote or isolate values that must not act as patterns or regular expressions. - Treat the right side of
=~as code-like regex syntax and never construct it directly from hostile text. - Use arithmetic conditions only after validating values as the intended integer grammar and range; Bash does not check integer