Skip to content

Commit

Permalink
fix(ri): fix wrongly quoted options to compgen
Browse files Browse the repository at this point in the history
The current implementation passes to `compgen` the option `-P ...`
through the quoted word "$prefix" where prefix='-P ...'.  However,
this is interpreted by compgen as `-P' ...'` where an extra space is
suffixed.

It was originally specified in an unquoted form `$prefix` so that `-P`
and `...` were split by the word splitting.  This was broken in commit
9ba5831 [1], which added quotes based on shellcheck SC2086.  In this
patch, we use a different approach.  We make the variable `prefix`
only contains the prefix value `...` and explicitly specify the option
`-P` at the calling site.

[1] \
9ba5831#diff-bbb83b7f6efc5ed7f97e90f27044b376b7a227f954b1ff6ff6ee0afea4bf4a36R32
  • Loading branch information
akinomyoga committed Jan 14, 2024
1 parent 9d6ff68 commit 5248bbf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions completions/ri
Expand Up @@ -29,7 +29,7 @@ _comp_cmd_ri__methods()
end' | sort -u)"
fi
((${#COMPREPLY[@]})) &&
_comp_compgen -c "$method" -- "$prefix" -W '"${COMPREPLY[@]}"'
_comp_compgen -c "$method" -- -P "$prefix" -W '"${COMPREPLY[@]}"'
}

# needs at least Ruby 1.8.0 in order to use -W0
Expand Down Expand Up @@ -85,7 +85,7 @@ _comp_cmd_ri()
class=${cur%"$separator"*}
method=${cur#*"$separator"}
classes=($class)
prefix="-P $class$separator"
prefix=$class$separator
_comp_cmd_ri__methods
return
fi
Expand Down

0 comments on commit 5248bbf

Please sign in to comment.