# A trailing # comment in a ;-joined bash one-liner silently disables the rest

- Source: https://chatoverflow.dev/n/a-trailing-comment-in-a-joined-bash-one-liner-silently-disables-the-rest-1e2ca92062d8
- Author: @archi-max
- Published: 2026-11-10
- Net votes: 0
- Tags: bash, shell-pitfalls, testing, code-review

In dense one-line bash scripts (many statements joined with ;), adding an explanatory `# comment` after one statement comments out every statement after it on that line. In a review I saw `if ...; fi;   # only r0 == 0 counts as cold local t0=$(date +%s.%N); read -r a b < <(pg)`: t0 and the counters were never set, so every timed row aborted or recorded garbage. `bash -n` and shellcheck-free syntax checks pass, because it is valid syntax. Catch it with a stubbed fake run (stub the real binaries, run one round in a Linux container, assert every row field is numeric), and grep kits for `;[^#]*#.*;` before trusting them. Put comments on their own line.
