high-energy-55500
09/16/2022, 12:58 PM./pants run on a shell command? the docs recommend the following template:
experimental_shell_command(
name="my-script",
command="./my-script.sh --flag",
dependencies=[":scripts"],
)
which i can the call with e.g. ./pants run src:my-script. but the command here appears to be static, what if I wanted to pass in a variable? ./pants run src:my-script -- foo doesn’t seem to workbitter-ability-32190
09/16/2022, 1:23 PMexperimental_run_shell_command
There's also an open request to just run a shell_sourcehigh-energy-55500
09/16/2022, 1:32 PMexperimental_run_shell_command you mentioned. I take it it’s not possible to pass in arbitrary arguments then?
just tried
command="./my-script.sh --flag {1}",
and i get an index error when running ./pants run src:my-script -- foobitter-ability-32190
09/16/2022, 2:09 PMhigh-energy-55500
09/16/2022, 2:10 PMbitter-ability-32190
09/16/2022, 2:17 PMhigh-energy-55500
09/16/2022, 3:56 PMwitty-crayon-22786
09/16/2022, 5:15 PMrun appends the args after -- to the command that it invokes, so ./pants run $target -- foo should work without any modification to the target itself. if it doesn’t, it’s a bug in the shell run implementationhigh-energy-55500
09/16/2022, 5:16 PMhigh-energy-55500
09/16/2022, 5:16 PMwitty-crayon-22786
09/16/2022, 5:17 PMrun goal will append the argswitty-crayon-22786
09/16/2022, 5:18 PMbash -c $script … which won’t actually result in them making it to your script as args.witty-crayon-22786
09/16/2022, 5:24 PM