mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-22 20:31:15 -03:00
Make argparse error message deterministic
Recent changes to switch to unordered sets/maps can cause the order in which items are returned to be non-deterministic. This change ensures that the argparse "Mutually exclusive flags" error message to be deterministic with respect to the order of the interpolated values.
This commit is contained in:
@@ -118,6 +118,13 @@ static int check_for_mutually_exclusive_flags(argparse_cmd_opts_t &opts, io_stre
|
||||
if (xopt_spec->short_flag_valid) flag2 += L"/";
|
||||
flag2 += xopt_spec->long_flag;
|
||||
}
|
||||
// We want the flag order to be deterministic. Primarily to make unit
|
||||
// testing easier.
|
||||
if (flag1 > flag2) {
|
||||
wcstring tmp(flag1);
|
||||
flag2 = flag1;
|
||||
flag1 = tmp;
|
||||
}
|
||||
streams.err.append_format(
|
||||
_(L"%ls: Mutually exclusive flags '%ls' and `%ls` seen\n"),
|
||||
opts.name.c_str(), flag1.c_str(), flag2.c_str());
|
||||
|
||||
Reference in New Issue
Block a user