Skip to content

Commit d6cd693

Browse files
authored
fix: correct flag handling in commands run by asdf exec (#2115)
1 parent 9b49276 commit d6cd693

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

internal/cli/cli.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ func Execute(version string) {
104104
},
105105
{
106106
Name: "exec",
107+
// We want all arguments to exec to remain unparsed so we can pass them
108+
// directly to the command asdf whill exec on behalf of the shim/user.
109+
// SkipFlagParsing tells urfave/cli to do this.
110+
SkipFlagParsing: true,
107111
Action: func(_ context.Context, cmd *cli.Command) error {
108112
command := cmd.Args().Get(0)
109113
args := cmd.Args().Slice()

test/shim_exec.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ teardown() {
3434
[ "$status" -eq 0 ]
3535
}
3636

37+
@test "asdf exec should pass all arguments including flags to executable" {
38+
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
39+
run asdf install
40+
41+
run asdf exec dummy --mytestflag hello
42+
[ "$output" = "This is Dummy 1.0! hello --mytestflag" ]
43+
[ "$status" -eq 0 ]
44+
}
45+
3746
@test "asdf exec should pass all arguments to executable even if shim is not in PATH" {
3847
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
3948
run asdf install

0 commit comments

Comments
 (0)