From 7a3e0924e085ce92160bdc89a931afa5cda0d6a5 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Fri, 6 Jan 2017 21:03:16 -0800 Subject: [PATCH] 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 --- src/builtin_complete.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/builtin_complete.cpp b/src/builtin_complete.cpp index bca0d85d9..286c09aa9 100644 --- a/src/builtin_complete.cpp +++ b/src/builtin_complete.cpp @@ -21,6 +21,9 @@ #include "wgetopt.h" #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 // 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 @@ -184,13 +187,23 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) { break; } case 'u': { - streams.err.append_format( - _(L"%ls: -u / --unauthoritative flags have been removed\n"), cmd); + if (!authoritative_flag_warning) { + 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; } case 'A': { - streams.err.append_format(_(L"%ls: -A / --authoritative flags have been removed\n"), - cmd); + if (!authoritative_flag_warning) { + 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; } case 's': {