Skip to content

Commit 8d8b318

Browse files
authored
Fix parser stringify subshell brackets (#6254)
## What's the problem this PR addresses? With `@yarnpkg/parsers`, stringifying a subshell (e.g. `echo $(echo a)`) uses the wrong brackets (e.g. `echo ${echo a}`) ## How did you fix it? Change to use the correct brackets. ## Checklist <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
1 parent c7c0767 commit 8d8b318

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

.yarn/versions/d497ae00.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/parsers": patch
4+
"@yarnpkg/shell": patch
5+
6+
declined:
7+
- "@yarnpkg/plugin-compat"
8+
- "@yarnpkg/plugin-constraints"
9+
- "@yarnpkg/plugin-dlx"
10+
- "@yarnpkg/plugin-essentials"
11+
- "@yarnpkg/plugin-init"
12+
- "@yarnpkg/plugin-interactive-tools"
13+
- "@yarnpkg/plugin-nm"
14+
- "@yarnpkg/plugin-npm-cli"
15+
- "@yarnpkg/plugin-pack"
16+
- "@yarnpkg/plugin-patch"
17+
- "@yarnpkg/plugin-pnp"
18+
- "@yarnpkg/plugin-pnpm"
19+
- "@yarnpkg/plugin-stage"
20+
- "@yarnpkg/plugin-typescript"
21+
- "@yarnpkg/plugin-version"
22+
- "@yarnpkg/plugin-workspace-tools"
23+
- "@yarnpkg/builder"
24+
- "@yarnpkg/core"
25+
- "@yarnpkg/doctor"
26+
- "@yarnpkg/sdks"

packages/yarnpkg-parsers/sources/shell.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export function stringifyArgumentSegment(argumentSegment: ArgumentSegment): stri
138138
return argumentSegment.pattern;
139139

140140
case `shell`:
141-
return doubleQuoteIfRequested(`\${${stringifyShellLine(argumentSegment.shell)}}`, argumentSegment.quoted);
141+
return doubleQuoteIfRequested(`$(${stringifyShellLine(argumentSegment.shell)})`, argumentSegment.quoted);
142142

143143
case `variable`:
144144
return doubleQuoteIfRequested(

packages/yarnpkg-parsers/tests/shell.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ const STRINGIFIER_TESTS: Array<[string, string]> = [
186186
[`echo foo > bar`, `echo foo > bar`],
187187
[`echo a$B"c"'d'`, `echo a\${B}cd`],
188188
[`echo a$B"c"'d'`, `echo a\${B}cd`],
189+
[`echo $(echo a)`, `echo $(echo a)`],
189190
[`echo $(( 1 + 2 * 3 - 4 / 5 ))`, `echo $(( ( 1 + ( 2 * 3 ) ) - ( 4 / 5 ) ))`],
190191
[`echo $(( 7 - 2 - 3 * 5 / 6 ))`, `echo $(( ( 7 - 2 ) - ( ( 3 * 5 ) / 6 ) ))`],
191192
[`(echo foo && echo bar)`, `(echo foo && echo bar)`],

0 commit comments

Comments
 (0)