]> https://gitweb.dealii.org/ - dealii.git/commitdiff
make remove_trailing_whitespace() works in both MAC OS and Linux system 11796/head
authorLei Qiao <qiaol618@gmail.com>
Tue, 23 Feb 2021 03:34:07 +0000 (11:34 +0800)
committerLei Qiao <qiaol618@gmail.com>
Tue, 23 Feb 2021 03:52:55 +0000 (11:52 +0800)
contrib/utilities/indent_common.sh

index 52071b0bac3d3e07b9b58493f8f78f66826937d2..bddad8366a8a63aab54f8833533f920803008eb0 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.