From ed148ab69d74d4b45006423b002ff1d9d4d721af Mon Sep 17 00:00:00 2001 From: tersec Date: Sat, 8 Apr 2023 00:18:29 +0000 Subject: [PATCH] fix false positive getopt failure with multiple getopt matches in searched path (#4797) * fix false positive getopt failure with multiple getopt matches in searched path * also get launch_local_testnet * also make_prometheus_config, called from launch_local_testnet --- scripts/launch_local_testnet.sh | 5 +++-- scripts/make_prometheus_config.sh | 5 +++-- tests/simulation/restapi.sh | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index 669a342bc..98dec664d 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020-2022 Status Research & Development GmbH. Licensed under +# Copyright (c) 2020-2023 Status Research & Development GmbH. Licensed under # either of: # - Apache License, version 2.0 # - MIT license @@ -35,7 +35,8 @@ PIDS="" GETOPT_BINARY="getopt" if [[ "${OS}" == "macos" ]]; then - GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null || true) + # Without the head -n1 constraint, it gets confused by multiple matches + GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true) [[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; } fi diff --git a/scripts/make_prometheus_config.sh b/scripts/make_prometheus_config.sh index defcf2a6e..cf152d9cf 100755 --- a/scripts/make_prometheus_config.sh +++ b/scripts/make_prometheus_config.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2020 Status Research & Development GmbH. Licensed under +# Copyright (c) 2020-2023 Status Research & Development GmbH. Licensed under # either of: # - Apache License, version 2.0 # - MIT license @@ -16,7 +16,8 @@ set -e GETOPT_BINARY="getopt" if uname | grep -qi darwin; then # macOS - GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null || true) + # Without the head -n1 constraint, it gets confused by multiple matches + GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true) [[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; } fi diff --git a/tests/simulation/restapi.sh b/tests/simulation/restapi.sh index e2fbcbc3a..aaac05a2a 100755 --- a/tests/simulation/restapi.sh +++ b/tests/simulation/restapi.sh @@ -17,7 +17,8 @@ KILL_OLD_PROCESSES="0" GETOPT_BINARY="getopt" if uname | grep -qi darwin; then # macOS - GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null || true) + # Without the head -n1 constraint, it gets confused by multiple matches + GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true) [[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; } fi