Skip to content

Commit 281261a

Browse files
committed
refactor(tar): initialize the variables in parsers
1 parent 8bd337a commit 281261a

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

completions/tar

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ _comp_cmd_gtar__parse_help_line()
133133
# The parse results are returned in these variables.
134134
_comp_cmd_gtar__parse_help()
135135
{
136+
long_arg_none=""
137+
long_arg_opt=""
138+
long_arg_req=""
139+
short_arg_none=""
140+
short_arg_opt=""
141+
short_arg_req=""
142+
136143
local str line arg
137144
while IFS= read -r line; do
138145
# Ok, this requires some comment probably. The GNU help output prints
@@ -177,8 +184,15 @@ _comp_cmd_gtar__parse_warnings()
177184
_comp_compgen -- -W '"${warnings[@]}"'
178185
}
179186

187+
# @var[out] old_opt_progress
188+
# @var[out] old_opt_used
189+
# @var[out,array] old_opt_parsed
180190
_comp_cmd_tar__parse_old_opt()
181191
{
192+
old_opt_progress=""
193+
old_opt_used=""
194+
old_opt_parsed=()
195+
182196
local first_word char
183197

184198
# current word is the first word
@@ -544,11 +558,11 @@ _comp_cmd_tar__gnu()
544558

545559
# Fill the {long,short}_{opts,arg*}
546560
local long_opts short_opts \
547-
long_arg_none="" long_arg_opt="" long_arg_req="" \
548-
short_arg_none="" short_arg_opt="" short_arg_req=""
561+
long_arg_none long_arg_opt long_arg_req \
562+
short_arg_none short_arg_opt short_arg_req
549563
_comp_cmd_gtar__parse_help
550564

551-
local old_opt_progress="" old_opt_used="" old_opt_parsed=()
565+
local old_opt_progress old_opt_used old_opt_parsed
552566
_comp_cmd_tar__preparse_cmdline "${words[@]}"
553567

554568
local ext
@@ -726,15 +740,20 @@ _comp_cmd_tar__posix()
726740
# Initialize option variables:
727741
# relatively compatible modes are {c,t,x}
728742
# relatively compatible options {b,f,m,v,w}
729-
# Note: long_opts, long_arg_*, short_arg_opt are currently unused
743+
# Note: long_{opts,arg_{none,opt}} and short_arg_opt are currently unused
730744
local long_opts short_opts \
731-
long_arg_none="" long_arg_opt long_arg_req="" \
745+
long_arg_none long_arg_opt long_arg_req \
732746
short_arg_none short_arg_opt short_arg_req
747+
long_arg_none=""
748+
long_arg_opt=""
749+
long_arg_req=""
750+
long_opts=""
733751
short_arg_req="fb"
752+
short_arg_opt=""
734753
short_arg_none="wmv"
735754
short_opts="$short_arg_req$short_arg_none"
736755

737-
local old_opt_progress="" old_opt_used=set old_opt_parsed=()
756+
local old_opt_progress old_opt_used old_opt_parsed
738757
_comp_cmd_tar__preparse_cmdline "${words[@]}"
739758

740759
local ext

0 commit comments

Comments
 (0)