shx icon indicating copy to clipboard operation
shx copied to clipboard

Executing paths should be supported

Open niieani opened this issue 9 years ago • 7 comments

I'd like a cross-platform way of executing local executables, e.g. under *nix I can currently:

./local/path/executable

this doesn't work under windows because of the path representation ./.

I was hoping I could run:

shx ./local/path/executable

But that doesn't seem to be supported.

Thanks! Otherwise awesome job!

niieani avatar Jun 15 '16 19:06 niieani

@niieani Could you give an example of how to run a command under Windows?

Case 1: same directory
$ ./foo
Case 2: Subdirectory
$ path/to/dir/foo # or
$ ./path/to/dir/foo

nfischer avatar Jun 15 '16 22:06 nfischer

@nfischer not sure what's the proper way under Windows, but I've found a workaround - it seems cross-env (https://github.com/kentcdodds/cross-env) makes it possible to run executables in a cross-platform way. Perhaps dissecting that package might point to a solution.

niieani avatar Jun 16 '16 11:06 niieani

I think that's really about setting environmental variables. If you only want a cross-platform way to run commands, I think you can use path/to/binary (assuming it has one or more directories). I'm surprised that ./binary doesn't work on Windows.

This is all without the shx prefix of course.

nfischer avatar Jun 17 '16 00:06 nfischer

Well yeah, cross-env normally is used for setting environmental variables, but I found the other use to be a cross-platform way to run commands. :) Indeed ./binary doesn't work on Windows. I believe .\binary does though.

niieani avatar Jun 17 '16 13:06 niieani

Hmmm interesting. I'll investigate when I boot up my Windows machine.

We may also want to consider modifying the PATH to allow for executing binaries installed from local node module (or perhaps as an extension to shx).

nfischer avatar Jun 17 '16 21:06 nfischer

@nfischer any update on this? Looks like this issue is over 6 years old. Maybe it's time to either close this issue as wouldn't do?

ktalebian avatar Apr 28 '21 07:04 ktalebian

This feature will allow to run commands silently, which is impossible to do cross-platform.

# cmd
command > nul 2>&1
# powershell
command *> $null
# bash
command > /dev/null 2>&1

shx --silent command

ftoh avatar Apr 14 '22 13:04 ftoh