Skip to content

Commit 1989ba9

Browse files
committed
fix: replace \s with [[:space:]] for POSIX sed/awk
\s and \S are GNU extensions. We need to replace them with [[:space:]] and [^[:space:]], respectively, in sed. Some awk implementations do not support the POSIX character classes of the form [[:space:]], so \s in awk needs to be replaced with the literal space and tab, $'[ \t]'.
1 parent d60c530 commit 1989ba9

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

completions/_mock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ _comp_cmd_mock()
4545
# This would actually depend on what the target root
4646
# can be used to build for...
4747
_comp_compgen_split -- "$(command rpm --showrc | command sed -ne \
48-
's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p')"
48+
's/^[[:space:]]*compatible[[:space:]]\{1,\}archs[[:space:]]*:[[:space:]]*\(.*\)/\1/i p')"
4949
return
5050
;;
5151
--enable-plugin | --disable-plugin)

completions/_yum

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _comp_cmd_yum__compgen_repolist()
2525
# Drop first ("repo id repo name") and last ("repolist: ...") rows
2626
_comp_compgen_split -- "$(
2727
yum --noplugins -C repolist "$1" 2>/dev/null |
28-
command sed -ne '/^repo\s\s*id/d' -e '/^repolist:/d' \
28+
command sed -ne '/^repo[[:space:]]\{1,\}id/d' -e '/^repolist:/d' \
2929
-e 's/[[:space:]].*//p'
3030
)"
3131
}

completions/chronyc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ _comp_cmd_chronyc__command_args()
44
{
55
local -a args
66
_comp_split args "$("$1" help 2>/dev/null |
7-
_comp_awk '/^'"$prev"'\s[^ []/ { gsub("\\|", " ", $2); print $2 }')"
7+
_comp_awk '/^'"$prev"'[ \t][^ []/ { gsub("\\|", " ", $2); print $2 }')"
88
case $args in
99
\<address\>) _comp_compgen_known_hosts -- "$cur" ;;
1010
\<*) ;;

completions/puppet

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _comp_cmd_puppet__certs()
2424
if [[ $1 == --all ]]; then
2525
cert_list=$(
2626
$puppetca --list --all |
27-
command sed -e 's/^[+-]\{0,1\}\s*\(\S\{1,\}\)\s\{1,\}.*$/\1/'
27+
command sed -e 's/^[+-]\{0,1\}[[:space:]]*\([^[:space:]]\{1,\}\)[[:space:]]\{1,\}.*$/\1/'
2828
)
2929
else
3030
cert_list=$("$puppetca" --list)
@@ -35,7 +35,7 @@ _comp_cmd_puppet__certs()
3535
_comp_cmd_puppet__types()
3636
{
3737
puppet_types=$(
38-
puppet describe --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/'
38+
puppet describe --list | command sed -e 's/^\([^[:space:]]\{1,\}\).*$/\1/'
3939
)
4040
_comp_compgen -a -- -W "$puppet_types"
4141
}
@@ -47,7 +47,7 @@ _comp_cmd_puppet__references()
4747
puppetdoc=puppetdoc
4848

4949
puppet_doc_list=$(
50-
$puppetdoc --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/'
50+
$puppetdoc --list | command sed -e 's/^\([^[:space:]]\{1,\}\).*$/\1/'
5151
)
5252
_comp_compgen -a -- -W "$puppet_doc_list"
5353
}

completions/rpm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ _comp_cmd_rpm__macros()
4545
_comp_cmd_rpm__buildarchs()
4646
{
4747
_comp_compgen_split -- "$("${1:-rpm}" --showrc | command sed -ne \
48-
's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p')"
48+
's/^[[:space:]]*compatible[[:space:]]\{1,\}build[[:space:]]\{1,\}archs[[:space:]]*:[[:space:]]*\(.*\)/\1/ p')"
4949
}
5050

5151
# shellcheck disable=SC2120

0 commit comments

Comments
 (0)