-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
Verify latest release
- I verified that the issue exists in the latest pnpm release
pnpm version
8.15.1
Which area(s) of pnpm are affected? (leave empty if unsure)
CLI
Link to the code that reproduces this issue or a replay of the bug
No response
Reproduction steps
Create a package.json with the following content:
{
"scripts": {
"go": "node -e 'console.log(process.argv[1])'"
}
}Then invoke it with a multi-line arg using all the major package managers:
npm run go $'foo\nbar'yarn run go $'foo\nbar'pnpm run go $'foo\nbar'
Describe the Bug
Observe that npm and yarn both correctly preserve the newline in the input arg, and therefore output it across two lines. pnpm, on the other hand, appears to be encoding the output as a javascript string literal and forwarding it with the \n escape sequence instead of a literal newline.
Expected Behavior
npm and yarn are both doing the expected behavior:
$ npm run go $'foo\nbar'
> go
> node -e 'console.log(process.argv[1])' foo
bar
foo
bar
The bug only manifests when using a script inside the package.json. That is, this variation, which bypasses package.json, does not have the bug: pnpm node -e 'console.log(process.argv[1])' $'foo\nbar'
Which Node.js version are you using?
v20.11.0
Which operating systems have you used?
- macOS
- Windows
- Linux
If your OS is a Linux based, which one it is? (Include the version if relevant)
No response
Reactions are currently unavailable