From 96d1616b70de68779f57b2c3a55bd2f2ffce8341 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 21 Sep 2022 12:22:21 +1000 Subject: [PATCH] Update for compatibility with macOS (BSD grep) The --max-count option tells grep to stop reading lines after the first matching line. We're looking for the line AFTER the first matching line. --- script/install-bundler | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/install-bundler b/script/install-bundler index a5c994c311..f018f7c734 100755 --- a/script/install-bundler +++ b/script/install-bundler @@ -14,12 +14,12 @@ # Fail if a single command fails. set -e -# `grep -m 1`: find the first occurrence of "BUNDLED WITH" +# `grep`: find the occurrences of "BUNDLED WITH" (-m is unnecessary and behaves different on macOS) # `-A`: print the next line after "BUNDLED WITH" as well # `-x -F`: find exactly that string without interpreting regex # `tail -n 1`: take the last line, the version line # `tr -d`: delete all spaces, the indent before the version -version="$(grep -m 1 -A 1 -x -F "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d '[:space:]')" +version="$(grep -A 1 -x -F "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d '[:space:]')" # if the length of $version is zero if [ -z "$version" ]; then