shelljs / shx

Portable Shell Commands for Node
MIT License
1.72k stars 44 forks source link

pipes #201

Closed its-dibo closed 2 years ago

its-dibo commented 2 years ago

does shx support piping in windows?

I run this command in windows and got sh not a recognized command

shx curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
nfischer commented 2 years ago

Shx doesn't itself support pipes, however it should be compatible with your operating system shell's pipe support. So if you're running a command on MacOS, Linux, or a shell that supports piping, then you could expect the following to work:

# Ex. Use only shx commands and OS pipe support
$ shx ls *.txt | shx sort | shx tail -n 1

# Ex. Mix shx commands and non-shx commands (on a unix machine):
$ ls *.txt | shx sort | tail -n 1

I don't think Windows cmd.exe has pipe support, however I think Windows powershell does. If you're using Windows Subsystem for Linux (WSL) then that would also support pipes since it runs bash as if it were a Linux machine.

I run this command in windows and got sh not a recognized command

shx curl -fsSL https://code-server.dev/install.sh[](https://code-server.dev/install.sh) | sh -s -- --dry-run

shx curl is not supported; we haven't implemented curl support in shx, so that should have printed Error: Invalid ShellJS command: curl to stderr. I'm not sure why sh -s ... failed; perhaps you're running this on a Windows machine which doesn't have the sh shell installed? Regardless, that second command is executed outside of shx so the error message is not related to this project.