You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When executing cargo make foo_create test, ${@} expands to "test" and "touch" "test.out" is executed. However, when executing cargo make foo create test, ${@} expands to "create" "test" and "touch" "create.out" "test.out" is executed, causing inconsistent behavior.
To align the behavior (or rather, because I want to exclude create from the arguments when executing foo create test), I would like to retrieve only the last argument. However, it seems that bash syntax like ${@: -1} doesn’t work in this case.
Given this situation, what would be the best way to process the arguments? I think it’s possible by writing a script, but as the number of commands increases, it becomes cumbersome to write argument handling for each command. If there is a better solution, please let me know.
$ cargo make foo_create test[cargo-make] INFO - cargo make 0.37.24[cargo-make] INFO - [cargo-make] INFO - Build File: Makefile.toml[cargo-make] INFO - Task: foo_create[cargo-make] INFO - Profile: development[cargo-make] INFO - Execute Command: "touch" "test.out"[cargo-make] INFO - Build Done in 0.23 seconds.
$ cargo make foo create test[cargo-make] INFO - cargo make 0.37.24[cargo-make] INFO - [cargo-make] INFO - Build File: Makefile.toml[cargo-make] INFO - Task: foo[cargo-make] INFO - Profile: development[cargo-make] INFO - Running Task: foo[cargo-make] INFO - Execute Command: "touch" "create.out" "test.out"[cargo-make] INFO - Build Done in 0.25 seconds.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Setup
Question
When executing
cargo make foo_create test,${@}expands to"test"and"touch" "test.out"is executed. However, when executingcargo make foo create test,${@}expands to"create" "test"and"touch" "create.out" "test.out"is executed, causing inconsistent behavior.To align the behavior (or rather, because I want to exclude
createfrom the arguments when executingfoo create test), I would like to retrieve only the last argument. However, it seems that bash syntax like${@: -1}doesn’t work in this case.Given this situation, what would be the best way to process the arguments? I think it’s possible by writing a script, but as the number of commands increases, it becomes cumbersome to write argument handling for each command. If there is a better solution, please let me know.
Beta Was this translation helpful? Give feedback.
All reactions