Skip to content

Commit

Permalink
_upvar, _upvars, _variables, rpm: address shellcheck SC1083
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Apr 10, 2020
1 parent 49ac2d9 commit e043fac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ _upvar()
if (( $# == 2 )); then
eval $1=\"\$2\" # Return single value
else
eval $1=\(\"\${@:2}\"\) # Return array
eval $1=\(\"\$"{@:2}"\"\) # Return array
fi
fi
}
Expand Down Expand Up @@ -199,7 +199,7 @@ _upvars()
"$FUNCNAME: \`$1': invalid number specifier" >&2
return 1; }
# Assign array of -aN elements
[[ "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) &&
[[ "$2" ]] && unset -v "$2" && eval $2=\(\"\$"{@:3:${1#-a}}"\"\) &&
shift $((${1#-a} + 2)) || { echo bash_completion: \
"$FUNCNAME: \`$1${2+ }$2': missing argument(s)" \
>&2; return 1; }
Expand Down Expand Up @@ -626,7 +626,7 @@ _variables()
{
if [[ $cur =~ ^(\$(\{[!#]?)?)([A-Za-z0-9_]*)$ ]]; then
# Completing $var / ${var / ${!var / ${#var
if [[ $cur == \${* ]]; then
if [[ $cur == "\${"* ]]; then
local arrs vars
vars=( $(compgen -A variable -P ${BASH_REMATCH[1]} -S '}' -- ${BASH_REMATCH[3]}) ) && \
arrs=( $(compgen -A arrayvar -P ${BASH_REMATCH[1]} -S '[' -- ${BASH_REMATCH[3]}) )
Expand Down
14 changes: 7 additions & 7 deletions completions/rpm
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ _rpm()
# complete on capabilities
local IFS=$'\n' fmt
case $prev in
*enhances) fmt=ENHANCENAME ;;
*provides) fmt=PROVIDENAME ;;
*recommends) fmt=RECOMMENDNAME ;;
*requires) fmt=REQUIRENAME ;;
*suggests) fmt=SUGGESTNAME ;;
*supplements) fmt=SUPPLEMENTNAME ;;
*enhances) fmt="%{ENHANCENAME}" ;;
*provides) fmt="%{PROVIDENAME}" ;;
*recommends) fmt="%{RECOMMENDNAME}" ;;
*requires) fmt="%{REQUIRENAME}" ;;
*suggests) fmt="%{SUGGESTNAME}" ;;
*supplements) fmt="%{SUPPLEMENTNAME}" ;;
esac
COMPREPLY=( $(compgen -W "$($1 -qa --nodigest --nosignature \
--queryformat=\"%{$fmt}\\n\" 2>/dev/null |
--queryformat=\"$fmt\\n\" 2>/dev/null |
command grep -vF '(none)')" -- "$cur") )
fi
return
Expand Down

0 comments on commit e043fac

Please sign in to comment.