summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-05-14 17:03:32 +0100
committerLeah Rowe <leah@libreboot.org>2025-05-14 17:03:32 +0100
commitf29aa9c8d5983f39166d00997364a47f126ae401 (patch)
tree72b41ecbb91f063124c104d2a8a1f093f522f2e3 /include
parente62886dedae26f49822350daeb7cfe83bb9a3931 (diff)
get.sh: use subshells on try_ functions
This way, we can use x_ which will then print the command that failed, if we need to debug future errors. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r--include/get.sh16
1 files changed, 8 insertions, 8 deletions
diff --git a/include/get.sh b/include/get.sh
index 69cc1a4a..e2aaf70b 100644
--- a/include/get.sh
+++ b/include/get.sh
@@ -121,15 +121,15 @@ try_file()
try_curl()
{
_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
- curl --location --retry 3 -A "$_ua" "$2" -o "$1" || \
- wget --tries 3 -U "$_ua" "$2" -O "$1" || return 1; :
+ ( x_ curl --location --retry 3 -A "$_ua" "$2" -o "$1" ) || \
+ ( x_ wget --tries 3 -U "$_ua" "$2" -O "$1" ) || return 1; :
}
try_copy()
{
[ -L "$2" ] && printf "symlink %s (try_cp %s)\n" "$2" "$*" && return 1
[ ! -f "$2" ] && "no such file %s (try_cp %s)\n" "$2" "$*" && return 1
- cp "$2" "$1" || return 1; :
+ ( x_ cp "$2" "$1" ) || return 1; :
}
try_git()
@@ -137,14 +137,14 @@ try_git()
gitdest="`findpath "$1"`" || err "Can't get readpath for '$1'"
x_ rm -Rf "$tmpgitcache"
- [ -d "$gitdest" ] || git clone "$2" "$tmpgitcache" || return 1
+ [ -d "$gitdest" ] || ( x_ git clone "$2" "$tmpgitcache" ) || return 1
[ -d "$gitdest" ] || x_ mkdir -p "${gitdest##*/}"
[ -d "$gitdest" ] || x_ mv "$tmpgitcache" "$gitdest"
- git -C "$gitdest" remote add main "$4" 2>/dev/null || :
- git -C "$gitdest" remote add backup "$5" 2>/dev/null || :
- git -C "$gitdest" fetch --all || :
- git -C "$gitdest" pull --all || :
+ ( x_ git -C "$gitdest" remote add main "$4" 2>/dev/null ) || :
+ ( x_ git -C "$gitdest" remote add backup "$5" 2>/dev/null ) || :
+ ( x_ git -C "$gitdest" fetch --all ) || :
+ ( x_ git -C "$gitdest" pull --all ) || :; :
}
bad_checksum()