Skip to content

[BUG] npx pass ESCAPED multiline string argument to package #3337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
loynoir opened this issue May 30, 2021 · 6 comments · Fixed by npm/run-script#78
Closed
1 task done

[BUG] npx pass ESCAPED multiline string argument to package #3337

loynoir opened this issue May 30, 2021 · 6 comments · Fixed by npm/run-script#78
Labels
Bug thing that needs fixing cmd:exec related to `npx` Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@loynoir
Copy link

loynoir commented May 30, 2021

Brief

npx and npm exec pass ESCAPED multiline string, instead of original string.

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

$ npx cowsay -- "$(node --version; npm --version)"
 __________________
< v14.16.0\n7.15.0 >
 ------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Expected Behavior

cowsay "$(node --version; npm --version)"    
 __________
/ v14.16.0 \
\ 7.15.0   /
 ----------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Steps To Reproduce

  1. docker run -it node /bin/bash
  2. npx cowsay "$(node --version; npm --version)"

Environment

Docker: node

  • OS: Debian GNU/Linux 9 (stretch)
  • Node: v15.14.0 - v17.4.0
  • npm: 7.7.6 - 8.3.1
@loynoir loynoir added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels May 30, 2021
@loynoir
Copy link
Author

loynoir commented May 30, 2021

Comparison

$ docker run -it node /bin/bash
$ npx cowsay "$(node --version; npm --version)"
 ________________
< v17.4.0\n8.3.1 >
 ----------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

May 30, 2021

$ docker run -it node /bin/bash
$ npx cowsay "$(node --version; npm --version)"
 _________________
< v15.14.0\n7.7.6 >
 -----------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
$ docker run -it node:fermium /bin/bash
$ npx cowsay "$(node --version; npm --version)"
 __________
/ v14.16.1 \
\ 6.14.12  /
 ----------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
$ docker run -it node:erbium /bin/bash
$ npx cowsay "$(node --version; npm --version)"
 __________
/ v12.22.1 \
\ 6.14.12  /
 ----------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
$ docker run -it node:lts /bin/bash
$ npx cowsay "$(node --version; npm --version)"
 __________
/ v14.17.0 \
\ 6.14.13  /
 ----------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

@loynoir
Copy link
Author

loynoir commented May 31, 2021

Special character other than LF

$ npx cowsay $'1\f2'
 ______
< 1\f2 >
 ------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
$ cowsay $'1\f2'    
 ____
< 1
   2 >
 ----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

@loynoir loynoir changed the title [BUG] multiple line string is not passed to package correctly [BUG] npx pass ESCAPED multiline string argument to package May 31, 2021
@noway
Copy link

noway commented Jul 18, 2021

Hello, I've encountered this too! I was searching for "new line" in issues and haven't noticed this ticket.

For now I see the workaround is to use stdin instead of args.

@lxe
Copy link
Contributor

lxe commented Feb 1, 2022

A gentle bump on this one. It's breaking commently-cli when passing multi-line --message arguments.

@lxe
Copy link
Contributor

lxe commented Feb 1, 2022

Temporary workaround:

$(npx --package=cowsay which cowsay) "$(node --version; npm --version)"

@ruyadorno
Copy link
Contributor

Can confirm this is still happening in the current version of the npm cli ([email protected] at the time of writing).

Other possible workaround seems to be using the call config option, e.g:

  • npx -p cowsay -c 'cowsay "$(node --version; npm --version)"'
  • npm exec --package=cowsay -c 'cowsay "$(node --version; npm --version)"'

@ruyadorno ruyadorno added Release 8.x work is associated with a specific npm 8 release cmd:exec related to `npx` Priority 2 secondary priority issue and removed Release 7.x work is associated with a specific npm 7 release Needs Triage needs review for next steps labels Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing cmd:exec related to `npx` Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants