Skip to content

Commit 100b3b0

Browse files
authored
v.pref: fix regression of command flags not working, when there is a subfolder, named after the command, in the current working folder (#21647)
1 parent 53ac41f commit 100b3b0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

vlib/v/pref/pref.v

+5-6
Original file line numberDiff line numberDiff line change
@@ -962,12 +962,11 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
962962
// arguments for e.g. fmt should be checked elsewhere
963963
continue
964964
}
965-
if res.is_vsh && command_idx < i {
966-
// Allow for `script.vsh abc 123 -option`, because -option is for the .vsh program, not for v
967-
continue
968-
}
969-
if command == 'doc' {
970-
// Allow for `v doc -comments file.v`
965+
if command_idx < i && (res.is_vsh || (is_source_file(command)
966+
&& command in known_external_commands)) {
967+
// When running programs, let them be responsible for the arguments passed to them.
968+
// E.g.: `script.vsh cmd -opt` or `v run hello_world.v -opt`.
969+
// But detect unknown arguments when building them. E.g.: `v hello_world.v -opt`.
971970
continue
972971
}
973972
err_detail := if command == '' { '' } else { ' for command `${command}`' }

0 commit comments

Comments
 (0)