From 853b82d19f4d6c4c09c3a82a8ddbdc1e048d8474 Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Fri, 29 Sep 2023 16:57:19 +0200 Subject: [PATCH] build: Use POSIX sh for shell scripts The scripts didn't really use any bash specific features. Convert them to POSIX shell scripts, so that the plugins can be built without requiring bash. Signed-off-by: Tom Wieczorek --- build_linux.sh | 4 ++-- build_windows.sh | 2 +- scripts/release.sh | 2 +- test_linux.sh | 8 ++++---- test_windows.sh | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build_linux.sh b/build_linux.sh index 6f8340b5..b6d054e7 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -1,8 +1,8 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -e cd "$(dirname "$0")" -if [ "$(uname)" == "Darwin" ]; then +if [ "$(uname)" = "Darwin" ]; then export GOOS="${GOOS:-linux}" fi diff --git a/build_windows.sh b/build_windows.sh index d71cf686..895909a5 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -e cd "$(dirname "$0")" diff --git a/scripts/release.sh b/scripts/release.sh index 5002428e..2b92d28a 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -xe SRC_DIR="${SRC_DIR:-$PWD}" diff --git a/test_linux.sh b/test_linux.sh index 9b29d74f..fd320d10 100755 --- a/test_linux.sh +++ b/test_linux.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # # Run CNI plugin tests. # @@ -10,12 +10,12 @@ set -e cd "$(dirname "$0")" # Build all plugins before testing -source ./build_linux.sh +. ./build_linux.sh echo "Running tests" -function testrun { - sudo -E bash -c "umask 0; PATH=${GOPATH}/bin:$(pwd)/bin:${PATH} go test -race $@" +testrun() { + sudo -E sh -c "umask 0; PATH=${GOPATH}/bin:$(pwd)/bin:${PATH} go test -race $*" } COVERALLS=${COVERALLS:-""} diff --git a/test_windows.sh b/test_windows.sh index b74fb570..22c2352a 100755 --- a/test_windows.sh +++ b/test_windows.sh @@ -1,11 +1,11 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # # Run CNI plugin tests. # set -e cd "$(dirname "$0")" -source ./build_windows.sh +. ./build_windows.sh echo "Running tests"