I would like to call a tool via command line. I need to generate the parameters to be used for calling dynamically. Furthermore there is a number of parameters which needs to be given to the tool.
COMMAND=""
for i in $VERSIONS; do
COMMAND+=" '../apache-maven-$i/bin/mvn clean'"
done
So now I want to call the tool with the generated list of parameters (from above) like this:
hyperfine --export-markdown ../results.md -w 5 $COMMAND
But unfortunately that produces the following result:
Benchmark #1: '../apache-maven-3.0.5/bin/mvn
Error: Command terminated with non-zero exit code. Use the '-i'/'--ignore-failure'
option if you want to ignore this. Alternatively,
use the '--show-output' option to debug what went wrong.
My assumption is that the created parameters $COMMAND
is not identified as multiple parameters. It's taken as a single parameter which is wrong. If I printout the whole command line and copy that into the bash line manually the execution works perfectly.
hyperfine --export-markdown ../results.md -w 5 '~/tools/apache-maven-3.8.2/bin/mvn clean' '~/tools/apache-maven-3.8.1/bin/mvn clean' '~/tools/apache-maven-4.0.0-alpha-1-SNAPSHOT/bin/mvn clean'
Is there something special to be taken into account while generating multiple parameters for calling other tools in Bash?
Benchmark #1: '../apache-maven-3.0.5/bin/mvn
; hyperfine probably tries to run that as a command, with the single quote and all. Perhaps the--show-output
option would clarify that. – ilkkachu Oct 02 '21 at 17:45