Skip to content

Commit 800b103

Browse files
committed
fix(mr): exactly match command names
1 parent 584e567 commit 800b103

File tree

1 file changed

+7
-2
lines changed
  • completions

1 file changed

+7
-2
lines changed

completions/mr

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ _comp_cmd_mr()
1919
commands="${commands//@(action|[\[\|\]])/$'\n'}"
2020
# Add standard aliases.
2121
commands="${commands} ci co ls"
22+
_comp_split commands "$commands"
23+
local IFS='|'
24+
local glob_commands="@(${commands[*]})"
25+
_comp_unlocal IFS
2226

2327
# Determine if user has entered an `mr` command. Used to block top-level
2428
# (option and command) completions.
2529
local cmd has_cmd="" i
2630
for ((i = 1; i < ${#words[@]} - 1; i++)); do
27-
if [[ $commands == *"${words[i]}"* ]]; then
31+
# shellcheck disable=SC2053
32+
if [[ ${words[i]} == $glob_commands ]]; then
2833
cmd="${words[i]}"
2934
has_cmd=set
3035
break
@@ -85,7 +90,7 @@ _comp_cmd_mr()
8590
# -X '--path': Remove deprecated options.
8691
_comp_compgen -- -W '"${options[@]}"' -X '@(-[a-z]|--path)'
8792
else
88-
_comp_compgen -- -W "${commands}"
93+
_comp_compgen -- -W '"${commands[@]}"'
8994
fi
9095
} &&
9196
complete -F _comp_cmd_mr mr

0 commit comments

Comments
 (0)