3 ms·
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,
by nitrogen 14y ago
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 https://wiki.ubuntu.com/DashAsBinSh#function