From b283ce78b5287f502b3204c51f8ec69be54c79db Mon Sep 17 00:00:00 2001 From: Lei Qiao Date: Tue, 23 Feb 2021 11:34:07 +0800 Subject: [PATCH] make remove_trailing_whitespace() works in both MAC OS and Linux system --- contrib/utilities/indent_common.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/utilities/indent_common.sh b/contrib/utilities/indent_common.sh index 52071b0bac..bddad8366a 100644 --- a/contrib/utilities/indent_common.sh +++ b/contrib/utilities/indent_common.sh @@ -171,7 +171,11 @@ remove_trailing_whitespace() file="${1}" tmpfile="$(mktemp "${TMPDIR}/$(basename "$1").tmp.XXXXXXXX")" - sed 's/\s\+$//g' "${file}" > "${tmpfile}" + # + # Mac OS uses BSD sed (other than GNU sed in Linux), + # so it doesn't recognize \s as 'spaces' or + as 'one or more'. + # + sed 's/[[:space:]]\{1,\}$//g' "${file}" > "${tmpfile}" if ! diff -q "${file}" "${tmpfile}" >/dev/null; then mv "${tmpfile}" "${file}" fi -- 2.39.5