From c3ea47e581b3262a07c28aea861836d0ac7fb538 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Fri, 17 Jan 2020 09:31:04 -0700 Subject: [PATCH] Fix removing trailing whitespaces --- contrib/utilities/indent_common.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/utilities/indent_common.sh b/contrib/utilities/indent_common.sh index d9c82e72d9..8861f659c7 100644 --- a/contrib/utilities/indent_common.sh +++ b/contrib/utilities/indent_common.sh @@ -163,12 +163,16 @@ format_file() export -f format_file # -# Remove trailing whitespace +# Remove trailiing whitespace. Mac OSX requires an extension for a backup file +# for in-place replacements. So we need to provide something before the regex. +# Using '-e' avoids creating these files on GNU platforms at least. +# For Mac OSX, we still need to delete the created file. # remove_trailing_whitespace() { - sed -i 's/\s\+$//g' $1 + sed -i -e 's/\s\+$//g' "$1" + rm -f "$1-e" } export -f remove_trailing_whitespace -- 2.39.5