Skip to content

Commit b3c54ca

Browse files
[Ubuntu] Improve errexit option handling (#8352)
1 parent 953177d commit b3c54ca

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

images/linux/scripts/helpers/install.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ download_with_retries() {
1919
local COMMAND="curl $URL -4 -sL -o '$DEST/$NAME' -w '%{http_code}'"
2020
fi
2121

22+
# Save current errexit state and disable it to prevent unexpected exit on error
23+
if echo $SHELLOPTS | grep '\(^\|:\)errexit\(:\|$\)' > /dev/null;
24+
then
25+
local ERR_EXIT_ENABLED=true
26+
else
27+
local ERR_EXIT_ENABLED=false
28+
fi
29+
set +e
30+
2231
echo "Downloading '$URL' to '${DEST}/${NAME}'..."
2332
retries=20
2433
interval=30
2534
while [ $retries -gt 0 ]; do
2635
((retries--))
27-
# Temporary disable exit on error to retry on non-zero exit code
28-
set +e
36+
test "$ERR_EXIT_ENABLED" = true && set +e
2937
http_code=$(eval $COMMAND)
3038
exit_code=$?
31-
set -e
39+
test "$ERR_EXIT_ENABLED" = true && set -e
3240
if [ $http_code -eq 200 ] && [ $exit_code -eq 0 ]; then
3341
echo "Download completed"
3442
return 0

images/linux/scripts/installers/firefox.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ echo 'pref("intl.locale.requested","en_US");' >> "/usr/lib/firefox/browser/defau
2626

2727
# Download and unpack latest release of geckodriver
2828
downloadUrl=$(get_github_package_download_url "mozilla/geckodriver" "test(\"linux64.tar.gz$\")")
29-
echo "Downloading geckodriver $downloadUrl"
3029
download_with_retries "$downloadUrl" "/tmp" geckodriver.tar.gz
3130

3231
GECKODRIVER_DIR="/usr/local/share/gecko_driver"

images/linux/scripts/installers/pypy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function InstallPyPy
1313
PACKAGE_URL=$1
1414

1515
PACKAGE_TAR_NAME=$(echo $PACKAGE_URL | awk -F/ '{print $NF}')
16-
echo "Downloading tar archive '$PACKAGE_TAR_NAME' - '$PACKAGE_URL'"
16+
echo "Downloading tar archive '$PACKAGE_TAR_NAME'"
1717
PACKAGE_TAR_TEMP_PATH="/tmp/$PACKAGE_TAR_NAME"
1818
download_with_retries $PACKAGE_URL "/tmp" $PACKAGE_TAR_NAME
1919

0 commit comments

Comments
 (0)