Skip to content
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

Add ability to avoid shell processing #428

Closed
hwittenborn opened this issue Sep 4, 2021 · 4 comments
Closed

Add ability to avoid shell processing #428

hwittenborn opened this issue Sep 4, 2021 · 4 comments

Comments

@hwittenborn
Copy link

I just got hyperfine installed on my system (sorry if I'm overlooking something obvious), but there doesn't seem to be any native way to avoid shell processing.

For example, I'd expect this to just print ${PWD}, but alas it prints the currently directory of my terminal:

hyperfine 'echo ${PWD}' --show-output

This also leads to another gripe with hyperfine I'm having: I'm not wanting to put the entire command I'm wanting to use inside of quotes. I'd much prefer to do something like this, and have the arguments get passed to the command in question without processing by a shell:

hyperfine --show-output -- echo '${PWD}'
@sharkdp
Copy link
Owner

sharkdp commented Sep 5, 2021

but there doesn't seem to be any native way to avoid shell processing.

Please see #336

not wanting to put the entire command I'm wanting to use inside of quotes. I'd much prefer to do something like this, and have the arguments get passed to the command in question without processing by a shell:

It would be a possibility, but how would you do a multi-command benchmark? we would need some sort of separator argument:

hyperfine --show-output -- command1 --with --some --options \; command2 --with --other --options

which - to me - is even worse. Once we implement #336, we will only do simple string splitting for the arguments. So if you run hyperfine 'echo ${PWD}', we will call echo with one argument ${PWD} (literal).

@hwittenborn
Copy link
Author

hwittenborn commented Sep 5, 2021

we would need some sort of separator argument
...
which - to me - is even worse

The only place I'd want the above approach is when you don't use shell processing, as you could otherwise just pass the ; via the command argument (inside the quotes).

The linked #336 issue would honestly solve all of my needs though. I would just need things like echo "hi me" to still just be the single hi me argument passed to echo.

@sharkdp
Copy link
Owner

sharkdp commented Sep 6, 2021

The only place I'd want the above approach is when you don't use shell processing, as you could otherwise just pass the ; via the command argument (inside the quotes).

Not sure if I explained it well. What I meant was: I want to compare the runtime of command1 with the runtime of command2. Right now, I can do it like this:

hyperfine --show-output 'command1 --with --some --options' 'command2 --with --other --options'

@sharkdp
Copy link
Owner

sharkdp commented Sep 6, 2021

The linked #336 issue would honestly solve all of my needs though. I would just need things like echo "hi me" to still just be the single hi me argument passed to echo.

Yes. We would probably use https://crates.io/crates/shell-words to do proper splitting of arguments.

@sharkdp sharkdp closed this as completed Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants