fix(sh): ${VAR:-val} and ${VAR-val} are different

Who would've thought?

`:` means or empty, so:

```sh
VAR=
echo "${VAR-default}" # prints 'default'

VAR=''
echo "${VAR-default}" # prints ''

VAR=''
echo "${VAR:-default}" # prints 'default'
```

;-; nothing wants to work
This commit is contained in:
Jalil David Salamé Messina 2024-12-19 23:12:40 +01:00
parent b0b4030759
commit cd38cd76fd
Signed by: jalil
GPG key ID: F016B9E770737A0B
3 changed files with 6 additions and 6 deletions

View file

@ -2,7 +2,7 @@
set -eu set -eu
util_path="${GITHUB_ACTION_PATH-.}/utils.sh" util_path="${GITHUB_ACTION_PATH:-.}/utils.sh"
# shellcheck source=utils.sh # shellcheck source=utils.sh
. "${util_path}" . "${util_path}"
@ -50,7 +50,7 @@ markdown_from_report() {
cat <<-"EOF" cat <<-"EOF"
- `[NAR] Size Change`: the amount changed compared to the main branch - `[NAR] Size Change`: the amount changed compared to the main branch
EOF EOF
compare=$(jq --slurp --from-file "${GITHUB_ACTION_PATH-.}/compare.jq" "$1" "$2") compare=$(jq --slurp --from-file "${GITHUB_ACTION_PATH:-.}/compare.jq" "$1" "$2")
if echo "$compare" | has_elements 'nixosConfigurations'; then if echo "$compare" | has_elements 'nixosConfigurations'; then
cat <<-"EOF" cat <<-"EOF"
# NixOS Configurations # NixOS Configurations
@ -96,14 +96,14 @@ markdown_from_report() {
} }
# Test outside CI # Test outside CI
if [ "${CI-false}" != 'true' ]; then if [ "${CI:-false}" != 'true' ]; then
markdown_from_report "$@" markdown_from_report "$@"
exit 0 exit 0
fi fi
log 'Determine head_ref' log 'Determine head_ref'
# For push & tag events it'll bet GITHUB_REF_NAME, for pull_request events it'll be GITHUB_HEAD_REF # For push & tag events it'll bet GITHUB_REF_NAME, for pull_request events it'll be GITHUB_HEAD_REF
head_ref=${GITHUB_REF_NAME-$GITHUB_HEAD_REF} head_ref=${GITHUB_REF_NAME:-$GITHUB_HEAD_REF}
log "Get PR number for $head_ref" log "Get PR number for $head_ref"
prs=$(curl -X 'GET' \ prs=$(curl -X 'GET' \

View file

@ -2,7 +2,7 @@
set -eu set -eu
util_path="${GITHUB_ACTION_PATH-.}/utils.sh" util_path="${GITHUB_ACTION_PATH:-.}/utils.sh"
# shellcheck source=utils.sh # shellcheck source=utils.sh
. "${util_path}" . "${util_path}"

View file

@ -38,7 +38,7 @@ has_report() {
} }
# If a base branch is not provided, use the default branch # If a base branch is not provided, use the default branch
base_branch=${BASE_BRANCH-$(default_branch)} base_branch=${BASE_BRANCH:-$(default_branch)}
if [ "$(in_private_repo)" != 'true' ] && [ "$JOB_NAME" ]; then if [ "$(in_private_repo)" != 'true' ] && [ "$JOB_NAME" ]; then
url=$(base_report_url "$base_branch") url=$(base_report_url "$base_branch")