From 5506fbfba0c9cdf5d525f86fd2aa829e32c4c960 Mon Sep 17 00:00:00 2001 From: Sylvain Defresne Date: Thu, 15 Apr 2021 15:42:10 +0000 Subject: [PATCH] Fix "expr: syntax error" on macOS The version of expr shipped on macOS does not support `substr` command and prints `expr: syntax error`. Change the invocation of `expr` to use the `:` operator which match rhs regexp into lhs string and return the length of the match. This should be supported by all versions of `expr` that are POSIX compliant. Bug: 1199260 Change-Id: Ib932702fedbbbc772d65086ebc371dc0a9023c0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2827931 Reviewed-by: Jamie Madill Reviewed-by: Dirk Pranke Commit-Queue: Sylvain Defresne --- autoninja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoninja b/autoninja index 4c10c48e6e..b9990ee8aa 100755 --- a/autoninja +++ b/autoninja @@ -5,7 +5,7 @@ # found in the LICENSE file. # In git bash on Windows, invoke the batch file. -if [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then +if [ "$(expr "$(uname -s)" : "^MINGW64_NT")" == "10" ]; then autoninja.bat "$@" exit fi