Variable assignment in sh

Roger Pate roger at
Wed Feb 1 15:50:11 UTC 2017

On Wed, Feb 1, 2017 at 10:23 AM, Manish Jain
<bourne.identity at> wrote:
> On 02/01/2017 08:36 PM, Roger Pate wrote:
>> Most often, but not always, if I need something bash has and /bin/sh
>> lacks, it's time to write that script in a different language. :P
> Generally, FreeBSD community is averse to bash scritpting. But then sh
> lacks array support, which is where bash and zsh do wonderfully well.

Not just FreeBSD community, but I won't belabor the point.

In particular about arrays, remember that sh does support one array
well: $@, both global and per-function.  If two arrays are needed, but
one can be setup in a for loop (useful for globbing files) or list of
lines/NUL-terminated-items (pipe into a while loop or process
xargs-like), then you are also good to go.

> Generally again, I am averse to most Linuxisms, but bash is simply way
> too much convenience to ignore.

I used to believe so too, but now I am happier writing more complex
scripts in Python.  Around the same time, I coincidentally switched my
interactive shell from bash to zsh (though I don't use zsh for
scripting), and also recommend that.

More information about the freebsd-questions mailing list