I just had a weird problem with sh’s syntax, the following function didn’t parse:
f() {
return { false; } | true
}
f
should return 0: a successful exit value. The problem is that using return
like that is invalid. Return expects a normal shell variable, not a list or
compound command according to the POSIX spec. The solution is simply to do
something like that:
f() {
{ false; } | true
}
This will return the last command’s exit code, in that case it’s true
: so the
value is zero. It’s still difficult to find good information about
shell-scripting on the net: that I though I’d throw that here.