Skip to content

Commit fa54f57

Browse files
committed
support gnu sed
Signed-off-by: Tin Lai <[email protected]>
1 parent 6f2c118 commit fa54f57

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libexec/shsh-_utils

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ parse_hooks_and_setvar() {
659659
shshrc_get_all_existing_install_cmd() {
660660
set +e
661661
if [ -e "$SHSHRC" ]; then
662-
existing="$(sed -n 's/^\s*shsh install \(.*\)$/\1/p' "$SHSHRC")"
662+
existing="$(sed -n 's/^[[:space:]]*shsh install \(.*\)$/\1/p' "$SHSHRC")"
663663
echo "$existing"
664664
fi
665665
}
@@ -670,14 +670,14 @@ shshrc_get_existing_install_cmd() {
670670
# given $1 as the package name, return the existing line in SHSHRC that installs
671671
# that package
672672
if [ -e "$SHSHRC" ]; then
673-
existing="$(grep -E "^\s*shsh install (.*\s+)?$1(\s.*)?$" "$SHSHRC")"
673+
existing="$(grep -E "^[[:space:]]*shsh install (.*[[:space:]]+)?$1([[:space:]].*)?$" "$SHSHRC")"
674674
# extract suffix if any (e.g. '&& \' or '|| \')
675-
_ending_pattern='\s+([&][&]|[|][|])\s*[\]\s*$'
675+
_ending_pattern='[[:space:]]+([&][&]|[|][|])[[:space:]]*[\][[:space:]]*$'
676676
existing_suffix="$(echo "$existing" | grep -oE "$_ending_pattern")"
677677
# extract prefix if any (i.e. white spaces)
678-
existing_prefix="$(echo "$existing" | grep -oE "^\s*")"
678+
existing_prefix="$(echo "$existing" | grep -oE "^[[:space:]]*")"
679679
# remove these from the statement for comparison
680-
existing="$(echo "$existing" | sed -E "s/$_ending_pattern//; s/^(\s*)//")"
680+
existing="$(echo "$existing" | sed -E "s/$_ending_pattern//; s/^([[:space:]]*)//")"
681681
fi
682682
export existing
683683
export existing_prefix

0 commit comments

Comments
 (0)