Skip to content

Commit 29e6278

Browse files
committed
_cargo: Fix some warnings caught by shellcheck
1 parent e3b286b commit 29e6278

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/etc/_cargo

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
autoload -U regexp-replace
44

55
_cargo() {
6-
local context state state_descr line
6+
local state
77
typeset -A opt_args
88

99
# leading items in parentheses are an exclusion list for the arguments following that arg
@@ -26,7 +26,7 @@ _cargo() {
2626

2727
case $state in
2828
args)
29-
case $words[1] in
29+
case ${words[1]} in
3030
bench)
3131
_arguments \
3232
'--features=[space separated feature list]' \
@@ -430,20 +430,20 @@ _cargo_cmds() {
430430
#FIXME: Disabled until fixed
431431
#gets package names from the manifest file
432432
_get_package_names() {
433+
:
433434
}
434435

435436
#TODO:see if it makes sense to have 'locate-project' to have non-json output.
436437
#strips package name from json stuff
437438
_locate_manifest() {
438439
local manifest=$(cargo locate-project 2>/dev/null)
439440
regexp-replace manifest '\{"root":"|"\}' ''
440-
echo $manifest
441+
echo "$manifest"
441442
}
442443

443444
# Extracts the values of "name" from the array given in $1 and shows them as
444445
# command line options for completion
445446
_get_names_from_array() {
446-
local -a filelist;
447447
local manifest=$(_locate_manifest)
448448
if [[ -z $manifest ]]; then
449449
return 0
@@ -454,26 +454,25 @@ _get_names_from_array() {
454454
local in_block=false
455455
local block_name=$1
456456
names=()
457-
while read line
458-
do
457+
while read -r line; do
459458
if [[ $last_line == "[[$block_name]]" ]]; then
460459
in_block=true
461460
else
462-
if [[ $last_line =~ '.*\[\[.*' ]]; then
461+
if [[ $last_line =~ '\s*\[\[.*' ]]; then
463462
in_block=false
464463
fi
465464
fi
466465

467466
if [[ $in_block == true ]]; then
468-
if [[ $line =~ '.*name.*=' ]]; then
469-
regexp-replace line '^.*name *= *|"' ""
470-
names+=$line
467+
if [[ $line =~ '\s*name\s*=' ]]; then
468+
regexp-replace line '^\s*name\s*=\s*|"' ''
469+
names+=( "$line" )
471470
fi
472471
fi
473472

474473
last_line=$line
475-
done < $manifest
476-
_describe $block_name names
474+
done < "$manifest"
475+
_describe "$block_name" names
477476

478477
}
479478

0 commit comments

Comments
 (0)