Skip to content

Simplify appending to env var JAVACMD_OPTIONS#96

Open
aureliojargas wants to merge 2 commits into
bmwcarit:masterfrom
aureliojargas:var-append
Open

Simplify appending to env var JAVACMD_OPTIONS#96
aureliojargas wants to merge 2 commits into
bmwcarit:masterfrom
aureliojargas:var-append

Conversation

@aureliojargas

Copy link
Copy Markdown

In default Bash, it is not an error to refer to an undeclared (or empty) variable. In that case, it will just expand to an empty string.

So there's no need to do the prior check, you can just append the new value right away.

Also, in Bash you can safely set and export on the same command.

In default Bash, it is not an error to refer to an undeclared (or empty)
variable. In that case, it will just expand to an empty string.

So there's no need to do the prior check, you can just append the new value
right away.

Also, in Bash you can safely set and export on the same command.
@jongiddy

Copy link
Copy Markdown
Contributor

Thanks. I love the conciseness of this! PR #90 adds -o nounset to this file, so when that is merged, this won't work as is. But it could still be a one-liner.

@aureliojargas

aureliojargas commented Mar 22, 2018

Copy link
Copy Markdown
Author

@jongiddy thanks for the heads-up!

In that case, the ${foo:-} parameter expansion should do the trick to avoid raising error when unset.

Since it will also work even when -o nounset is not active, I'll update this PR with the fix.

PR bmwcarit#90 will add "-o unset" to this file, so we need this variable expansion to
guard when the $JAVACMD_OPTIONS is unset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants