#2529

scripts/lint-shell.sh --help output is cut off mid-sentence (usage sed range stops one line early)

Openrahul05ranjanopened 14d ago

What happens

scripts/lint-shell.sh --help (and -h) prints its usage block truncated in the middle of the last sentence:

$ bash scripts/lint-shell.sh --help
Lint shell scripts in this repository.

Usage:
  scripts/lint-shell.sh [--all] [--format] [--strict] [file ...]

By default, runs ShellCheck and shell syntax checks on changed shell scripts.
Use --format to format with shfmt before linting. Use --all for the full tracked

The final line of the header comment block, "baseline, or pass files explicitly to lint a smaller set.", is missing, so the help ends with a dangling "for the full tracked".

Cause

The usage() helper hardcodes a line range that ends one line short of the comment block:

scripts/lint-shell.sh lines 12-14:

usage() {
  sed -n '2,9p' "$0" | sed 's/^# \{0,1\}//'
}

The header comment runs through line 10 (verified on current main), so 2,9p drops exactly the last line. Sibling scripts avoid this by anchoring the range on markers instead of a fixed count, e.g. bump-version.sh uses /^# Usage:/ to end-of-block, and render-antigravity-logo.sh's range happens to cover its whole comment.

Suggested fix

Either extend the range:

sed -n '2,10p' "$0" | sed 's/^# \{0,1\}//'

or anchor it to the end of the comment block (e.g. print until the first non-# line, as bump-version.sh does with /^# Usage:/,/^# Requires:/-style markers), so adding a line to the header can't silently truncate the help again.

Activity

0

No activity yet.