Skip to content

Commit

Permalink
review: use set -euo pipefail
Browse files Browse the repository at this point in the history
Also removes the ability to set `DRY_RUN` due to `set -u`; instead, this
allows redefining the commands that remove and copy the headers.
  • Loading branch information
abrown committed Dec 2, 2024
1 parent d036a1c commit 9592abd
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions scripts/install-include-headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,19 @@
#
# Usage: SYSROOT_INC=... TARGET_TRIPLE=... ./install-include-headers.sh

set -e
set -euo pipefail

PARENT_DIR=$(dirname $(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd))
WASI_LIBC="${WASI_LIBC:-$PARENT_DIR}"
if [[ -z "${SYSROOT_INC}" || -z "${TARGET_TRIPLE}" ]]; then
echo "usage: SYSROOT_INC=... TARGET_TRIPLE=... ./install-include-headers.sh"
exit 1
fi

# If DRY_RUN is set, then don't actually touch any files.
if [[ -z "${DRY_RUN}" ]]; then
CP="cp -v"
RM="rm -v"
MKDIR="mkdir"
SED="sed"
else
CP="echo cp"
RM="echo rm"
MKDIR="echo mkdir"
SED="echo sed"
fi
# The commands are available for override to allow dry runs.
CP="${CP:-cp -v}"
RM="${RM:-rm -v}"
MKDIR="${MKDIR:-mkdir}"
SED="${SED:-sed}"

# Copy in the bottom half's public headers.
$MKDIR -p $SYSROOT_INC
Expand Down

0 comments on commit 9592abd

Please sign in to comment.