Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(foundryup): actually make set -e work #6352

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions foundryup/foundryup
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -eo pipefail

BASE_DIR=${XDG_CONFIG_HOME:-$HOME}
FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"}
Expand All @@ -14,7 +14,7 @@ main() {
need_cmd git
need_cmd curl

while [[ $1 ]]; do
while [[ -n $1 ]]; do
case $1 in
--) shift; break;;

Expand Down Expand Up @@ -91,7 +91,8 @@ main() {

say "installing foundry (version ${FOUNDRYUP_VERSION}, tag ${FOUNDRYUP_TAG})"

PLATFORM=$(tolower "${FOUNDRYUP_PLATFORM:-$(uname -s)}")
uname_s=$(uname -s)
PLATFORM=$(tolower "${FOUNDRYUP_PLATFORM:-$uname_s}")
EXT="tar.gz"
case $PLATFORM in
linux) ;;
Expand All @@ -107,7 +108,8 @@ main() {
;;
esac

ARCHITECTURE=$(tolower "${FOUNDRYUP_ARCH:-$(uname -m)}")
uname_m=$(uname -m)
ARCHITECTURE=$(tolower "${FOUNDRYUP_ARCH:-$uname_m}")
if [ "${ARCHITECTURE}" = "x86_64" ]; then
# Redirect stderr to /dev/null to avoid printing errors if non Rosetta.
if [ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = "1" ]; then
Expand Down Expand Up @@ -266,15 +268,14 @@ check_cmd() {
}

# Run a command that should never fail. If the command fails execution
# will immediately terminate with an error showing the failing
# command.
# will immediately terminate with an error showing the failing command.
ensure() {
if ! "$@"; then err "command failed: $*"; fi
}

# Downloads $1 into $2 or stdout
download() {
if [ "$2" ]; then
if [ -n "$2" ]; then
# output into $2
if check_cmd curl; then
curl -#o "$2" -L "$1"
Expand Down Expand Up @@ -315,4 +316,4 @@ Contribute : https://github.com/orgs/foundry-rs/projects/2/
}


main "$@" || exit 1
main "$@"