2011/04/27: Setting defaults in shell scripts

In Makefiles (at least those inspired by the BSD ports collection), you often want to inherit values from the environment, but set defaults, if the value is not provided. The way to do this, is the ?= operator.


FOO ?= bar

In shell scripts, you sometimes want to do the same. The syntax is slightly different.


: ${FOO:=bar}