aaronriekenberg / rust-parallel

Fast command line app in rust/tokio to run commands in parallel. Similar interface to GNU parallel or xargs plus useful features. Listed in Awesome Rust utilities.
MIT License
146 stars 7 forks source link

Winodws compatibility and feature enhancements #8

Closed QiWei closed 8 months ago

QiWei commented 1 year ago

Winodws compatibility: The default shell under Winodws is cmd, and the default parameter is /c instead of -c.

Feature request: When not in regular mode (without the parameter -p), {1}, {2} refer to the parameter of the corresponding number.

aaronriekenberg commented 1 year ago

On Windows compatibility: I can try to detect the OS at build-time using something like this: https://stackoverflow.com/questions/43292357/how-can-one-detect-the-os-type-using-rust

And then the defaults for shell_path and -c argument can be different from other platforms (mac, linux).

Will work on this.

Let me give the feature request some more thought.

Thanks @QiWei !

aaronriekenberg commented 12 months ago

@QiWei in version 1.9.0 have added windows support to default shell command to cmd and shell argument to /c on windows. Also added a windows release build to github actions.

I do not have a way to test this on windows - could you please try this and let me know if it works?

Still considering above feature request.

Thanks!

QiWei commented 12 months ago

It has been tested and functions correctly.

funnbot commented 8 months ago

This needs to be configurable, as there are still situations where a unix like shell is used on windows, in my case in Git Bash. While I can set the --shell-path, this change forces /c instead of -c when invoking the shell.

I modified it as a compile time feature for my use case, as I don't plan on using it in a cmd.exe environment, however it would probably be better as a runtime option. Most user friendly would probably be detecting the shell rust-parallel is invoked from, and then selecting the /c or -c based on that. Although I don't know if there's a better way to detect a shell type beyond name == "cmd".

aaronriekenberg commented 8 months ago

@funnbot Added a --shell-argument command line argument here: https://github.com/aaronriekenberg/rust-parallel/commit/52c31b4d77be895e6c44376e67976322fffad5f6

--shell-path defaults to /bin/bash on unix and cmd on windows --shell-argument defaults to -c on unix and /c on windows

Will consider if there is a feasible more user friendly way to do this but for now I think this will allow your use case to work without changing the code.

thanks!

aaronriekenberg commented 8 months ago

Above changes to add --shell-argument option are in releases 1.12.0 and 1.13.0

Closing this issue, please write additional issues if you find limitations or bugs with this.

Thanks!