As I previously blogged about it, the appending operator bashism is only useful when programming for the bash shell.
Whenever you want to append a string to a variable, repeating the name of the variable is the portable way. I.e.
foo=foo foo="${foo} bar" # Instead of foo+=" bar", which is a bashism
See? Replacing the += operator is not rocket science.
Note: One should be aware that makefiles do have a += operator which is safe to use when appending to a make variable. But don't let this "exception" fool you: code in configure.ac and similar files is executed by the shell interpreter. So don't use the appending operator there.
Recent mksh versions and AT&T ksh93 also implement += but the maxime is still: check what you’re using is actually supported!
ReplyDelete