only warn about obsolete complete flags once

It was pointed out that the previous change to alert people to the fact
their completion scripts were using flags that are no longer valid
resulted in way too many warnings. This limits the warning to one per
session.

Fixes #3640
This commit is contained in:
Kurtis Rader 2017-01-06 21:03:16 -08:00
parent fc81fa6abf
commit 7a3e0924e0

View file

@ -21,6 +21,9 @@
#include "wgetopt.h" #include "wgetopt.h"
#include "wutil.h" // IWYU pragma: keep #include "wutil.h" // IWYU pragma: keep
// This boolean ensures we only issue the warning about using the -A/--authoritative flag one time.
static bool authoritative_flag_warning = false;
// builtin_complete_* are a set of rather silly looping functions that make sure that all the proper // builtin_complete_* are a set of rather silly looping functions that make sure that all the proper
// combinations of complete_add or complete_remove get called. This is needed since complete allows // combinations of complete_add or complete_remove get called. This is needed since complete allows
// you to specify multiple switches on a single commandline, like 'complete -s a -s b -s c', but the // you to specify multiple switches on a single commandline, like 'complete -s a -s b -s c', but the
@ -184,13 +187,23 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
break; break;
} }
case 'u': { case 'u': {
streams.err.append_format( if (!authoritative_flag_warning) {
_(L"%ls: -u / --unauthoritative flags have been removed\n"), cmd); streams.err.append_format(
_(L"%ls: Please update your completion scripts by removing "
L"-u / --unauthoritative / -A / --authoritative flags."),
cmd);
authoritative_flag_warning = true;
}
break; break;
} }
case 'A': { case 'A': {
streams.err.append_format(_(L"%ls: -A / --authoritative flags have been removed\n"), if (!authoritative_flag_warning) {
cmd); streams.err.append_format(
_(L"%ls: Please update your completion scripts by removing "
L"-u / --unauthoritative / -A / --authoritative flags."),
cmd);
authoritative_flag_warning = true;
}
break; break;
} }
case 's': { case 's': {