From bb7bb64845c80854ba4c54e13773f4fad23f5712 Mon Sep 17 00:00:00 2001 From: Haowei Cai Date: Mon, 10 May 2021 08:36:44 -0700 Subject: [PATCH] add OS X sed check to update-submodule.sh --- scripts/update-submodule.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/update-submodule.sh b/scripts/update-submodule.sh index 86aa5a4b5..3891b557a 100755 --- a/scripts/update-submodule.sh +++ b/scripts/update-submodule.sh @@ -31,6 +31,22 @@ set -o errexit set -o nounset set -o pipefail +# OS X sed doesn't support "--version". This way we can tell if OS X sed is +# used. +if ! sed --version &>/dev/null; then + # OS X sed and GNU sed aren't compatible with backup flag "-i". Namely + # sed -i ... - does not work on OS X + # sed -i'' ... - does not work on certain OS X versions + # sed -i '' ... - does not work on GNU + echo ">>> OS X sed detected, which may be incompatible with this script. Please install and use GNU sed instead: + $ brew install gnu-sed + $ brew info gnu-sed + # Find the path to the installed gnu-sed and add it to your PATH. The default + # is: + # PATH=\"/Users/\$USER/homebrew/opt/gnu-sed/libexec/gnubin:\$PATH\"" + exit 1 +fi + repo_root="$(git rev-parse --show-toplevel)" declare -r repo_root cd "${repo_root}"