@@ -171,16 +171,16 @@ __tar_parse_old_opt()
171
171
172
172
# current word is the first word
173
173
[[ $cword -eq 1 && $cur && ${cur: 0: 1} != ' -' ]] &&
174
- old_opt_progress=1
174
+ old_opt_progress=set
175
175
176
176
# check that first argument does not begin with "-"
177
177
first_word=${words[1]}
178
178
[[ $first_word && ${first_word: 0: 1} != " -" ]] &&
179
- old_opt_used=1
179
+ old_opt_used=set
180
180
181
181
# parse the old option (if present) contents to allow later code expect
182
182
# corresponding arguments
183
- if (( old_opt_used == 1 )) ; then
183
+ if [[ $ old_opt_used ]] ; then
184
184
char=${first_word: 0: 1}
185
185
while [[ $char ]]; do
186
186
if __tar_is_argreq " $char " ; then
@@ -195,13 +195,12 @@ __tar_parse_old_opt()
195
195
# Make the analysis of whole command line.
196
196
__tar_preparse_cmdline ()
197
197
{
198
- local first_arg i modes=" ctxurdA"
198
+ local first_arg=set i modes=" ctxurdA"
199
199
200
200
shift # progname
201
201
202
202
__tar_parse_old_opt
203
203
204
- first_arg=1
205
204
for i in " $@ " ; do
206
205
case " $i " in
207
206
--delete | --test-label)
@@ -220,14 +219,14 @@ __tar_preparse_cmdline()
220
219
;;
221
220
* [$modes ]* )
222
221
# Only the first arg may be "MODE" without leading dash
223
- if (( first_arg == 1 )) ; then
222
+ if [[ $ first_arg ]] ; then
224
223
tar_mode=${i// [^$modes]/ }
225
224
tar_mode=${tar_mode: 0: 1}
226
225
tar_mode_arg=$i
227
226
fi
228
227
;;
229
228
esac
230
- first_arg=0
229
+ first_arg=" "
231
230
done
232
231
}
233
232
@@ -306,7 +305,7 @@ __tar_complete_mode()
306
305
307
306
# The last short option requires argument, like '-cf<TAB>'. Cut the
308
307
# completion here to enforce argument processing.
309
- if (( old_opt_progress == 0 )) &&
308
+ if [[ ! $old_opt_progress ]] &&
310
309
__tar_is_argreq " $( __tar_last_char " $cur " ) " ; then
311
310
COMPREPLY=(" $cur " ) && return 0
312
311
fi
@@ -383,7 +382,7 @@ __tar_adjust_PREV_from_old_option()
383
382
# deal with old style arguments here
384
383
# $ tar cfTC # expects this sequence of arguments:
385
384
# $ tar cfTC ARCHIVE_FILE PATTERNS_FILE CHANGE_DIR
386
- if (( old_opt_used == 1 && cword > 1 && cword < ${# old_opt_parsed[@]} + 2 )) ; then
385
+ if [[ $ old_opt_used ]] && (( cword > 1 && cword < ${# old_opt_parsed[@]} + 2 )) ; then
387
386
# make e.g. 'C' option from 'cffCT'
388
387
prev=" -${old_opt_parsed[cword - 2]} "
389
388
fi
@@ -488,8 +487,8 @@ _gtar()
488
487
local long_opts short_opts basic_tar=" " \
489
488
long_arg_none=" " long_arg_opt=" " long_arg_req=" " \
490
489
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=()
490
+ tar_mode tar_mode_arg old_opt_progress=" " \
491
+ old_opt_used=" " old_opt_parsed=()
493
492
494
493
# Main mode, e.g. -x or -c (extract/creation)
495
494
local tar_mode=none
@@ -678,8 +677,8 @@ _posix_tar()
678
677
local long_opts short_opts basic_tar=set \
679
678
long_arg_none=" " long_arg_opt long_arg_req=" " \
680
679
short_arg_none short_arg_opt short_arg_req \
681
- tar_mode tar_mode_arg old_opt_progress=0 \
682
- old_opt_used=1 old_opt_parsed=()
680
+ tar_mode tar_mode_arg old_opt_progress=" " \
681
+ old_opt_used=set old_opt_parsed=()
683
682
684
683
# Main mode, e.g. -x or -c (extract/creation)
685
684
local tar_mode=none
0 commit comments