@@ -119,6 +119,9 @@ _comp_cmd_gtar__parse_help_line()
119
119
done <<< " $1"
120
120
}
121
121
122
+ # Cache of _comp_cmd_gtar__parse_help()
123
+ _comp_cmd_gtar__parse_help__mut_cache=
124
+
122
125
# Parse the output of "tar --help" with GNU tar and store the parse results
123
126
# into variables.
124
127
#
@@ -131,8 +134,18 @@ _comp_cmd_gtar__parse_help_line()
131
134
# @var[out] short_arg_opt
132
135
# @var[out] short_arg_req
133
136
# The parse results are returned in these variables.
137
+ #
138
+ # @var[in,out] _comp_cmd_gtar__parse_help__mut_cache
139
+ # The parse results are cached in this global variable. If this variable
140
+ # is non-empty, this variable is used to obtain the parse results instead
141
+ # of parsing the output of "tar --help" again.
134
142
_comp_cmd_gtar__parse_help ()
135
143
{
144
+ if [[ $_comp_cmd_gtar__parse_help__mut_cache ]]; then
145
+ eval -- " $_comp_cmd_gtar__parse_help__mut_cache "
146
+ return
147
+ fi
148
+
136
149
long_arg_none=" "
137
150
long_arg_opt=" "
138
151
long_arg_req=" "
@@ -168,6 +181,16 @@ _comp_cmd_gtar__parse_help()
168
181
$long_arg_none $long_arg_opt $long_arg_req "
169
182
170
183
short_opts=" $short_arg_none$short_arg_opt$short_arg_req "
184
+
185
+ printf -v _comp_cmd_gtar__parse_help__mut_cache ' %s=%q ' \
186
+ long_opts " $long_opts " \
187
+ short_opts " $short_opts " \
188
+ long_arg_none " $long_arg_none " \
189
+ long_arg_opt " $long_arg_opt " \
190
+ long_arg_req " $long_arg_req " \
191
+ short_arg_none " $short_arg_none " \
192
+ short_arg_opt " $short_arg_opt " \
193
+ short_arg_req " $short_arg_req "
171
194
}
172
195
173
196
# Hack: parse --warning keywords from tar's error output
0 commit comments