Skip to content

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

Merged
merged 17 commits into from
May 23, 2023

Conversation

scop
Copy link
Owner

@scop scop commented May 7, 2023

@scop scop marked this pull request as draft May 7, 2023 11:00
@scop scop changed the title refactor(rpm): adjust to util/xfunc primary command convention refactor: adjust to util/xfunc primary command convention May 7, 2023
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
Copy link
Owner Author

@scop scop May 7, 2023

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.

@scop scop force-pushed the refactor/util-func-cmds branch 2 times, most recently from a3095ea to be8229c Compare May 10, 2023 17:43
@scop scop force-pushed the refactor/util-func-cmds branch from be8229c to 6a55150 Compare May 21, 2023 19:59
@scop scop force-pushed the refactor/util-func-cmds branch from 50bc8b6 to 898926c Compare May 22, 2023 10:26
@scop scop marked this pull request as ready for review May 23, 2023 03:46
@scop
Copy link
Owner Author

scop commented May 23, 2023

There are some cases where we should be using $1 rather than a hardcoded one in the tree still, as well as others that could make use of the $PATH prepending as here, but I'll leave them for another followup MR. So I think this one's ready to roll, FYI @akinomyoga

@scop scop merged commit 9b443a9 into master May 23, 2023
@scop scop deleted the refactor/util-func-cmds branch May 23, 2023 10:54
@@ -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"
Copy link
Collaborator

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 ]].

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scop Can you include it in #988?

Copy link
Owner Author

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.

scop added a commit that referenced this pull request May 23, 2023
#965 (comment)

Thanks-to: Koichi Murase <myoga.murase@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants