Skip to content

Commit 33c18ce

Browse files
committed
fix(_mock,rpm): avoid icase flag s/reg/rep/i of GNU sed
Flag i for the case-insensitive matching is a GNU extension and thus should be avoided. The mock completion contains s/.../.../i while the rpm completion also contains a similar code but without flag i. The related sed code in the rpm completion was introduced in commit 14c9f5b (2009-05-23), and that in the mock completion was introduced in commit 508a88e (2009-05-31). The former did not have flag i while the latter had flag i from the beginning. In this patch, we assume the case-insensitive flag was intended for both cases and update the regular expression so that it matches in a case-insensitive manner also in the rpm completion.
1 parent 1989ba9 commit 33c18ce

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

completions/_mock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ _comp_cmd_mock()
4040
return
4141
;;
4242
--target)
43+
# Case-insensitive BRE to match "compatible archs"
44+
local regex_header='[cC][oO][mM][pP][aA][tT][iI][bB][lL][eE][[:space:]]\{1,\}[aA][rR][cC][hH][sS]'
45+
4346
# Yep, compatible archs, not compatible build archs
4447
# (e.g. ix86 chroot builds in x86_64 mock host)
4548
# This would actually depend on what the target root
4649
# can be used to build for...
4750
_comp_compgen_split -- "$(command rpm --showrc | command sed -ne \
48-
's/^[[:space:]]*compatible[[:space:]]\{1,\}archs[[:space:]]*:[[:space:]]*\(.*\)/\1/i p')"
51+
"s/^[[:space:]]*${regex_header}[[:space:]]*:[[:space:]]*\(.*\)/\1/p")"
4952
return
5053
;;
5154
--enable-plugin | --disable-plugin)

completions/rpm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ _comp_cmd_rpm__macros()
4444
# shellcheck disable=SC2120
4545
_comp_cmd_rpm__buildarchs()
4646
{
47+
# Case-insensitive BRE to match "compatible build archs"
48+
local regex_header='[cC][oO][mM][pP][aA][tT][iI][bB][lL][eE][[:space:]]\{1,\}[bB][uU][iI][lL][dD][[:space:]]\{1,\}[aA][rR][cC][hH][sS]'
4749
_comp_compgen_split -- "$("${1:-rpm}" --showrc | command sed -ne \
48-
's/^[[:space:]]*compatible[[:space:]]\{1,\}build[[:space:]]\{1,\}archs[[:space:]]*:[[:space:]]*\(.*\)/\1/ p')"
50+
"s/^[[:space:]]*${regex_header}[[:space:]]*:[[:space:]]*\(.*\)/\1/p")"
4951
}
5052

5153
# shellcheck disable=SC2120

0 commit comments

Comments
 (0)