Skip to content

Commit

Permalink
printenv - handle env variable being set to blank (#126)
Browse files Browse the repository at this point in the history
* Handle env variable being set to blank

* v fmt printenv
  • Loading branch information
syrmel authored Jan 27, 2024
1 parent a953144 commit 1d5d64c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/printenv/printenv.v
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ fn main() {
}
} else {
for k in args {
mut v := os.getenv(k)
if v == '' {
// Use getenv_opt because it is possible for the environment variable
// to be set to the empty string which should not return an error code.
mut v := os.getenv_opt(k) or {
exit_code = 1 // at least one specified variable was not found
continue
}
Expand Down

0 comments on commit 1d5d64c

Please sign in to comment.