What's the actual usecase of := in parameter replacement?
What's the actual usecase of := in parameter replacement?
cross-posted from: https://lemmy.zip/post/74048002
I've seen
: "${DB_HOST:=localhost}"because it assigns the variable if not set (: $…is just to run assignments standalone). But that has the same effect likeDB_HOST="${DB_HOST:-localhost}(use the string if not set). While something likeecho "${DB_HOST:=localhost}"smells from a mile, because it has output with side-effects.
Comments