-
Notifications
You must be signed in to change notification settings - Fork 391
refactor: adjust to util/xfunc primary command convention #965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
case $prev in | ||
--buildroot | --root | --dbpath | -${noargopts}r) | ||
_comp_compgen filedir -d | ||
return | ||
;; | ||
--target | --eval | -${noargopts}E | --buildpolicy) | ||
local pathcmd | ||
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The benefit of prepending to $PATH
as opposed to trying to figure out the exact command is that we don't need to poke into the internals of the utility function even for file-local use, and the utility function's default command basename persists.
In some cases we may want to pass the full path, that's still possible, but I suppose the $PATH
modification use case would be a more common one for cases like this. When the utility command's command is the same as the one being completed, passing "$1"
is the way to go.
a3095ea
to
be8229c
Compare
be8229c
to
6a55150
Compare
50bc8b6
to
898926c
Compare
There are some cases where we should be using |
@@ -3,7 +3,7 @@ | |||
_comp_cmd_perl__helper() | |||
{ | |||
COMPREPLY=($(compgen -P "$prefix" -W \ | |||
"$("${2:-perl}" "${BASH_SOURCE[0]%/*}/../helpers/perl" "$1" "$cur")" \ | |||
"$("${1:-perl}" "${BASH_SOURCE[0]%/*}/../helpers/perl" "$2" "$cur")" \ | |||
-- "$cur")) | |||
[[ $1 == functions ]] || _comp_ltrim_colon_completions "$prefix$cur" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think this line should have also been updated as [[ $2 == functions ]]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, good catch, done in b85263a.
#965 (comment) Thanks-to: Koichi Murase <myoga.murase@gmail.com>
#959