Skip to content

fix(parser): expand $'\\n' ANSI-C quoting in concatenated function args#865

Merged
chaliy merged 1 commit intomainfrom
fix/issue-862-ansi-c-quoting-concat
Mar 27, 2026
Merged

fix(parser): expand $'\\n' ANSI-C quoting in concatenated function args#865
chaliy merged 1 commit intomainfrom
fix/issue-862-ansi-c-quoting-concat

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 27, 2026

What

Fix ANSI-C quoting ($'\n', $'\t', etc.) expansion when concatenated with adjacent quoted strings in function argument position.

Why

In read_continuation_into(), $'...' sequences were not recognized as ANSI-C quoting. The $ was consumed as a regular word character and the following '...' was treated as a regular single-quoted string, producing literal $\n instead of an actual newline character.

This only affected concatenation in argument position (show "a"$'\n'"b"). Variable assignment (x="a"$'\n'"b") worked correctly because it went through read_word() which already had proper $' handling.

How

Added explicit $' detection in read_continuation_into() that uses lookahead to identify ANSI-C quoting and delegates to the existing read_dollar_single_quoted_content() for proper escape expansion.

Tests

Added 7 spec tests covering:

  • $'\n' and $'\t' concatenated between double-quoted strings as function args
  • $'\n' as sole argument
  • $'\n' at start and end of concatenation
  • Multiple ANSI-C segments in one word
  • Baseline: via variable assignment (confirms existing behavior)

Closes #862

In read_continuation_into(), $'...' sequences were not recognized as
ANSI-C quoting. The $ was consumed as a word character and the following
'...' was treated as a regular single-quoted string, producing literal
$\n instead of a newline.

Add explicit $' detection in read_continuation_into() that delegates
to read_dollar_single_quoted_content() for proper escape expansion.

Closes #862
@chaliy chaliy merged commit 97af431 into main Mar 27, 2026
23 checks passed
@chaliy chaliy deleted the fix/issue-862-ansi-c-quoting-concat branch March 27, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: $'\\n' not expanded when concatenated in function argument position

1 participant