mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 01:51:14 -03:00
Make argparse reject supplying a validator for boolean flags
Specifically, this commit simply makes argparse issue an error if you use the ! syntax to define a validation script on an option that does not take any arguments. For example, "argparse foo!exit -- --foo" is now an error. This was previously accepted, despite that fact that the code after ! would never be executed (the ! code is only executed when an option is given a value). Alternatively, ! validation scripts could be made to execute even when no value was provided, but this break existing code that uses them with flags that take optional values.
This commit is contained in:
@@ -678,6 +678,11 @@ begin
|
||||
#CHECKERR: (Type 'help argparse' for related documentation)
|
||||
end
|
||||
|
||||
begin
|
||||
argparse f!echo hello -- -f
|
||||
#CHECKERR: argparse: Invalid option spec 'f!echo' at char '!'
|
||||
end
|
||||
|
||||
begin
|
||||
argparse --ignore-unknown h i -- -hoa -oia
|
||||
echo -- $argv
|
||||
|
||||
Reference in New Issue
Block a user