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
util_path="${GITHUB_ACTION_PATH-.}/utils.sh"
util_path="${GITHUB_ACTION_PATH:-.}/utils.sh"
# shellcheck source=utils.sh
. "${util_path}"
@ -50,7 +50,7 @@ markdown_from_report() {
cat <<-"EOF"
- `[NAR] Size Change`: the amount changed compared to the main branch
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
cat <<-"EOF"
# NixOS Configurations
@ -96,14 +96,14 @@ markdown_from_report() {
}
# Test outside CI
if [ "${CI-false}" != 'true' ]; then
if [ "${CI:-false}" != 'true' ]; then
markdown_from_report "$@"
exit 0
fi
log 'Determine 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"
prs=$(curl -X 'GET' \

View file

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

View file

@ -38,7 +38,7 @@ has_report() {
}
# 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
url=$(base_report_url "$base_branch")