Re:A nice, little known C feature: Static array indices in p...
by nitrogen on Tuesday February 19, 2013 @09:09AM
(#5244310)
User-defined functions basically eliminate this (may not be POSIX compliant, but supported in all shells I know of),
User-defined functions are part of POSIX, but the function keyword is not. This bit me when I was porting a script from bash to dash (worth the effort on slower devices, as dash is significantly faster loading).
On bash you could do something like this:
function foo()
{
echo "Foo"
}
In POSIX shell (and, thus, also bash) you do this: bar()
{
echo "Bar"
}
Reference: https://wiki.ubuntu.com/DashAsBinSh#function
Honestly, it might be Stockholm syndrome, but I don't find bash hard to parse at all. The only real problem I see is that people get in trouble when they try to nest quoting styles. But there's basically never any reason to do that. User-defined functions basically eliminate this (may not be POSIX compliant, but supported in all shells I know of),
I factor all my shell scripts into 2 to 10 line functions and they are super easy to maintain and are 5-10x shorter than any alternative.
[1] http://tiswww.case.edu/php/chet/bash/bashtop.html