@@ -170,17 +170,19 @@ __tar_parse_old_opt()
170170 local first_word char
171171
172172 # current word is the first word
173+ # shellcheck disable=SC2209
173174 [[ $cword -eq 1 && $cur && ${cur: 0: 1} != ' -' ]] &&
174- old_opt_progress=1
175+ old_opt_progress=set
175176
176177 # check that first argument does not begin with "-"
177178 first_word=${words[1]}
179+ # shellcheck disable=SC2209
178180 [[ $first_word && ${first_word: 0: 1} != " -" ]] &&
179- old_opt_used=1
181+ old_opt_used=set
180182
181183 # parse the old option (if present) contents to allow later code expect
182184 # corresponding arguments
183- if (( old_opt_used == 1 )) ; then
185+ if [[ $ old_opt_used ]] ; then
184186 char=${first_word: 0: 1}
185187 while [[ $char ]]; do
186188 if __tar_is_argreq " $char " ; then
@@ -195,13 +197,13 @@ __tar_parse_old_opt()
195197# Make the analysis of whole command line.
196198__tar_preparse_cmdline ()
197199{
198- local first_arg i modes=" ctxurdA"
200+ # shellcheck disable=SC2209
201+ local first_arg=set i modes=" ctxurdA"
199202
200203 shift # progname
201204
202205 __tar_parse_old_opt
203206
204- first_arg=1
205207 for i in " $@ " ; do
206208 case " $i " in
207209 --delete | --test-label)
@@ -220,14 +222,14 @@ __tar_preparse_cmdline()
220222 ;;
221223 * [$modes ]* )
222224 # Only the first arg may be "MODE" without leading dash
223- if (( first_arg == 1 )) ; then
225+ if [[ $ first_arg ]] ; then
224226 tar_mode=${i// [^$modes]/ }
225227 tar_mode=${tar_mode: 0: 1}
226228 tar_mode_arg=$i
227229 fi
228230 ;;
229231 esac
230- first_arg=0
232+ first_arg=" "
231233 done
232234}
233235
@@ -306,7 +308,7 @@ __tar_complete_mode()
306308
307309 # The last short option requires argument, like '-cf<TAB>'. Cut the
308310 # completion here to enforce argument processing.
309- if (( old_opt_progress == 0 )) &&
311+ if [[ ! $old_opt_progress ]] &&
310312 __tar_is_argreq " $( __tar_last_char " $cur " ) " ; then
311313 COMPREPLY=(" $cur " ) && return 0
312314 fi
@@ -383,7 +385,7 @@ __tar_adjust_PREV_from_old_option()
383385 # deal with old style arguments here
384386 # $ tar cfTC # expects this sequence of arguments:
385387 # $ tar cfTC ARCHIVE_FILE PATTERNS_FILE CHANGE_DIR
386- if (( old_opt_used == 1 && cword > 1 && cword < ${# old_opt_parsed[@]} + 2 )) ; then
388+ if [[ $ old_opt_used ]] && (( cword > 1 && cword < ${# old_opt_parsed[@]} + 2 )) ; then
387389 # make e.g. 'C' option from 'cffCT'
388390 prev=" -${old_opt_parsed[cword - 2]} "
389391 fi
@@ -488,8 +490,8 @@ _gtar()
488490 local long_opts short_opts basic_tar=" " \
489491 long_arg_none=" " long_arg_opt=" " long_arg_req=" " \
490492 short_arg_none=" " short_arg_opt=" " short_arg_req=" " \
491- tar_mode tar_mode_arg old_opt_progress=0 \
492- old_opt_used=0 old_opt_parsed=()
493+ tar_mode tar_mode_arg old_opt_progress=" " \
494+ old_opt_used=" " old_opt_parsed=()
493495
494496 # Main mode, e.g. -x or -c (extract/creation)
495497 local tar_mode=none
@@ -679,8 +681,8 @@ _posix_tar()
679681 local long_opts short_opts basic_tar=set \
680682 long_arg_none=" " long_arg_opt long_arg_req=" " \
681683 short_arg_none short_arg_opt short_arg_req \
682- tar_mode tar_mode_arg old_opt_progress=0 \
683- old_opt_used=1 old_opt_parsed=()
684+ tar_mode tar_mode_arg old_opt_progress=" " \
685+ old_opt_used=set old_opt_parsed=()
684686
685687 # Main mode, e.g. -x or -c (extract/creation)
686688 local tar_mode=none
0 commit comments