Bash 5.3

Last reviewed Sep 5, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. POSIX Shell POSIX.1-2024115 lines · 2.8K tokens
  2. 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 nounset and pipefail, and test their context-dependent behavior.
  • Use errexit only with explicit control flow around conditions, functions, substitutions, pipelines, and asynchronous commands.
  • Consider inherit_errexit when 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 mapfile with 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