Skip to content

Commit b5ae5fa

Browse files
committed
fix(mr): avoid ${var/pat/$'...'} for compat42 in bash >= 4.3
In bash >= 4.3 with `shopt -s compat42` enabled, ${var/pat/$'...'} would produce extra single quotations around the replacements. The mr completion uses $'\n' to insert delimiter, but the delimiter does not need to be the newline in this context. In this patch, we can instead insert a space.
1 parent 0afc2e4 commit b5ae5fa

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

completions/mr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ _comp_cmd_mr()
1616
done
1717
)"
1818
# Split [online|offline] and remove `action` placeholder.
19-
commands="${commands//@(action|[\[\|\]])/$'\n'}"
19+
commands="${commands//@(action|[\[\|\]])/ }"
2020
# Add standard aliases.
2121
commands="${commands} ci co ls"
2222
_comp_split commands "$commands"

test/runLint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ gitgrep "$cmdstart"'((set|shopt)\s+[+-][a-z]+\s+posix\b|(local\s+)?POSIXLY_CORRE
6767

6868
gitgrep '\$\{([^{}\n]|\{.*\})+/([^{}\n]|\{.*\})+/([^{}"\n]|\{.*\})*\$.*\}' \
6969
'$rep of ${var/pat/$rep} needs to be double-quoted for shopt -s patsub_replacement (bash >= 5.2)'
70+
71+
gitgrep '"([^"\n]|\\.)*\$\{([^{}\n]|\{.*\})+/([^{}\n]|\{.*\})+/([^{}"\n]|\{.*\})*"([^{}"\n]|\{.*\})*\$.*\}' \
72+
'$rep of "${var/pat/"$rep"}" should not be quoted for bash-4.2 or shopt -s compat42 (bash >= 4.3)'

0 commit comments

Comments
 (0)