Fix Spelling: Support BSD version of `sed`
-#!/bin/sh
+#!/bin/bash
#
# @author Markus Raab <elektra@markus-raab.org>
# @brief Fix spelling error in most files
@@ -10,4 +10,16 @@ SCRIPTS_DIR=$(dirname "$0")
cd "$SOURCE"
-$(sed -i -E -f scripts/sed `find . -type f -name '*.md' | egrep -v "^./(.git|tests/gtest-1.7.0|scripts/sed|scripts/fix-spelling|doc/images|doc/AUTHORS.md|doc/news)"`)
+sed --version >& /dev/null
+if [ $? -eq 0 ]; then
+ # GNU sed
+ script="scripts/sed"
+ inplace=(-i)
+else
+ # BSD sed
+ sed -e 's/\\</[[:<:]]/' -e 's/\\>/[[:>:]]/' scripts/sed > /tmp/sed
+ script="/tmp/sed"
+ inplace=(-i '')
+fi
+
+$(sed "${inplace[@]}" -E -f "$script" `find . -type f -name '*.md' | egrep -v "^./(.git|tests/gtest-1.7.0|scripts/sed|scripts/fix-spelling|doc/images|doc/AUTHORS.md|doc/news)"`)
