a8m / a8m/envsubst

envsubst -no-unset blows up on ${FOO:=}

Open Beginner friendly
#61 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
907
Forks
96
PR merge metrics
No merged PRs in 30d

Description

It seems that an empty default value is treated as if a default value has not been provided.

Expected:

```console
~ $ go install github.com/a8m/envsubst/cmd/envsubst@v1.4.2
~ $ go/bin/envsubst -no-unset <<< 'value: ${FOO:=}'
value:
~ $ echo $?
0
~ $
```

Got:

```console
~ $ go install github.com/a8m/envsubst/cmd/envsubst@v1.4.2
~ $ go/bin/envsubst -no-unset <<< 'value: ${FOO:=}'
variable ${FOO} not set

~ $ echo $?
1
~ $
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Look at the parsing logic for variable substitution in the source code, likely in a file like parse.go or subst.go. The bug is that ${FOO:=} with an empty default is incorrectly flagged as unset when -no-unset is used. Run the existing tests to see how defaults are handled, then add a test case for this scenario and fix the parsing to treat empty defaults as valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, shell
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.