Severity: Medium
Expected real-world likelihood: Medium for future maintenance; none in the current source
Problem
rollup.rb removes text from any unprotected # through the end of the line. Valid Bash parameter expansions use the same character for length and prefix removal, so adding an ordinary construct such as ${#array[@]} or ${value#prefix} to the readable source can silently corrupt generated scripts.
The current bj.sh does not contain an affected core construct, and current generated files reproduce byte-for-byte. This is a guardrail issue for future compact parser work rather than a current runtime regression.
Reproduction
printf '%s\n' 'x=${#a[@]}' 'y=${value#prefix}' | ./rollup.rb
Actual compact code after the copyright header:
The source lines are valid Bash but are truncated at each #.
Suspected cause
The transformation list includes:
Quoted string literals are protected before transformations, but unquoted parameter expansions are not.
Possible fixes (suggestions only)
These are possible approaches, not prescribed implementations:
- Protect the small set of Bash parameter-expansion forms containing
# before comment stripping and restore them afterward.
- Narrow comment recognition so
# inside a parameter expansion is not treated as a comment.
- Add focused generator fixtures for the supported compact Bash constructs.
The solution should remain small and auditable; this issue does not suggest turning rollup.rb or linebreak.rb into a general Bash parser.
Suggested regression coverage
${#name} and ${#array[@]};
${value#prefix} and ${value##prefix};
- real inline comments still being removed;
- hashes inside single- and double-quoted strings remaining unchanged;
- generated output passing
bash -n;
- current
bj.sh still regenerating byte-for-byte.
Severity: Medium
Expected real-world likelihood: Medium for future maintenance; none in the current source
Problem
rollup.rbremoves text from any unprotected#through the end of the line. Valid Bash parameter expansions use the same character for length and prefix removal, so adding an ordinary construct such as${#array[@]}or${value#prefix}to the readable source can silently corrupt generated scripts.The current
bj.shdoes not contain an affected core construct, and current generated files reproduce byte-for-byte. This is a guardrail issue for future compact parser work rather than a current runtime regression.Reproduction
Actual compact code after the copyright header:
The source lines are valid Bash but are truncated at each
#.Suspected cause
The transformation list includes:
Quoted string literals are protected before transformations, but unquoted parameter expansions are not.
Possible fixes (suggestions only)
These are possible approaches, not prescribed implementations:
#before comment stripping and restore them afterward.#inside a parameter expansion is not treated as a comment.The solution should remain small and auditable; this issue does not suggest turning
rollup.rborlinebreak.rbinto a general Bash parser.Suggested regression coverage
${#name}and${#array[@]};${value#prefix}and${value##prefix};bash -n;bj.shstill regenerating byte-for-byte.