barefoot icon indicating copy to clipboard operation
barefoot copied to clipboard

Simplify appending to env var JAVACMD_OPTIONS

Open aureliojargas opened this issue 6 years ago • 2 comments

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.

aureliojargas avatar Mar 13 '18 14:03 aureliojargas

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.

jongiddy avatar Mar 20 '18 07:03 jongiddy

@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.

aureliojargas avatar Mar 22 '18 05:03 aureliojargas