-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: incorrect variable name display in must_get_env
error msg
#22615
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,17 @@ | |
# Needed to fail on must_get_env() | ||
set -e | ||
|
||
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) | ||
GIT_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && git rev-parse --show-toplevel) | ||
source "${GIT_ROOT}/scripts/colors.sh" | ||
|
||
function must_get_env() { | ||
declare -n VAR_VALUE="$1" | ||
local VAR_NAME="$1" | ||
declare -n VAR_VALUE="$VAR_NAME" | ||
if [[ -n "${VAR_VALUE}" ]]; then | ||
echo "${VAR_VALUE}" | ||
return | ||
fi | ||
echo -e "${RED}No required env variable:${RST} ${BLD}${!VAR_VALUE}${RST}" 1>&2 | ||
echo -e "${RED}No required env variable:${RST} ${BLD}${VAR_NAME}${RST}" 1>&2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Which means that > TEST=something
> VAR_NAME=TEST
> declare -n VAR_REF=$VAR_NAME
> echo $VAR_REF
something
> echo ${!VAR_REF}
TEST Your version is clearer, but the result is the same. What I would like to understand is why for you it doesn't expand into the name of variable from the |
||
exit 1 | ||
} | ||
|
||
|
@@ -25,7 +26,7 @@ nixOpts=() | |
|
||
# We create if now so the trap knows its location | ||
export SECRETS_FILE_PATH=$(mktemp) | ||
chmod 644 ${SECRETS_FILE_PATH} | ||
chmod 644 "${SECRETS_FILE_PATH}" | ||
# If secrets file was created we want to remove it. | ||
trap "rm -vf ${SECRETS_FILE_PATH}" EXIT ERR INT QUIT | ||
|
||
|
@@ -77,5 +78,4 @@ else | |
nixOpts+=("--option" "build-use-sandbox" "true") | ||
fi | ||
|
||
|
||
"${GIT_ROOT}/nix/scripts/build.sh" targets.mobile.android.build "${nixOpts[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is that better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is better in terms of clarity, correctness, and consistency, especially in more complex scripts or when the script could be sourced.