fix: resolve unbound variable error for tmp_phar and tmp_checksum under set -u#43
Merged
Merged
Conversation
…er set -u When the installer runs under a strict shell environment with 'set -u' (treat unbound variables as errors), the two-line pattern of: local tmp_phar tmp_phar="$(mktemp ...)" causes a 'tmp_phar: unbound variable' error if the RETURN trap or any early exit fires between the 'local' declaration and the assignment. This manifested as a failed Ansible play at helper-functions line 313. Fix: combine the declaration and mktemp assignment onto a single line using the semicolon idiom: local tmp_phar; tmp_phar="$(mktemp ...)" This ensures the variable is always bound the moment it is declared, eliminating the race window. The inline form 'local var=$(cmd)' is intentionally avoided because bash's 'local' built-in masks the exit code of the subshell, making mktemp failures invisible. Applied the same fix to tmp_checksum for consistency.
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts the EasyEngine installer helper script to avoid “unbound variable” failures when run under strict bash settings (set -u), specifically around temp file variables used during the phar download/install flow.
Changes:
- Updates temp file variable initialization for
tmp_pharandtmp_checksumindownload_and_install_easyengine().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Quote $LOG_FILE in touch call to be safe against paths with spaces - Separate 'export EE_LINUX_DISTRO=$(...)' into assignment then export; the combined form masks the exit code of the subshell under set -e - Fix long-standing typo: check_depdendencies -> check_dependencies in both the function definition (functions) and the call site (setup.sh)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extends the rename from check_depdendencies -> check_dependencies to the migration scripts that were missed in the previous commit: - migration/migrate.sh: call site at line 100 - migration/remote-migrate: function definition check_depdendencies_remote renamed to check_dependencies_remote, and its call site at line 81 No remaining occurrences of the misspelled name exist in the codebase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the installer runs in a strict shell environment with
set -u(treat unbound variables as errors), the Ansible play failed athelper-functions:313with:Root cause
The two-line pattern used to declare and assign temp file variables:
creates a narrow window where
tmp_pharis declared (vialocal) but still unset. If theRETURNtrap or any early exit fires in that gap, bash sees an unbound variable and aborts with the error above.