From 0452fe69a0ce3d2c674be869a0d4d3c452d4f32c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 18 Nov 2024 15:51:05 -0500 Subject: [PATCH] ci: Fix cases where unset variables cause errors --- ci/install-rust.sh | 17 +++++++---------- ci/run.sh | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/ci/install-rust.sh b/ci/install-rust.sh index 0438ee4f9f6fe..7ca649c347e1c 100644 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -4,14 +4,11 @@ set -eux echo "Setup toolchain" -toolchain= -if [ -n "$TOOLCHAIN" ]; then - toolchain=$TOOLCHAIN -else - toolchain=nightly -fi -if [ "$OS" = "windows" ]; then +toolchain="${TOOLCHAIN:-nightly}" +os="${OS:-}" + +if [ "$os" = "windows" ]; then : "${TARGET?The TARGET environment variable must be set.}" rustup set profile minimal rustup update --force "$toolchain-$TARGET" @@ -22,17 +19,17 @@ else rustup default "$toolchain" fi -if [ -n "$TARGET" ]; then +if [ -n "${TARGET:-}" ]; then echo "Install target" rustup target add "$TARGET" fi -if [ -n "$INSTALL_RUST_SRC" ]; then +if [ -n "${INSTALL_RUST_SRC:-}" ]; then echo "Install rust-src" rustup component add rust-src fi -if [ "$OS" = "windows" ]; then +if [ "$os" = "windows" ]; then if [ "$ARCH_BITS" = "i686" ]; then echo "Install MinGW32" choco install mingw --x86 --force diff --git a/ci/run.sh b/ci/run.sh index caf4eb4333281..f4fef82fcdc2d 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -15,7 +15,7 @@ target="$1" # # It's assume that all images, when run with two disks, will run the `run.sh` # script from the second which we place inside. -if [ "$QEMU" != "" ]; then +if [ -n "${QEMU:-}" ]; then tmpdir=/tmp/qemu-img-creation mkdir -p "${tmpdir}"