IMO,

the best and only reasonable way to address it is to specify
what all shells do: return works like exit when called in a
subshell.

In

f() (
  foo || return
  bar
)

that return should be guaranteed to exit the function (with
foo's exit status) if foo fails.

It's also important to keep the guarantee that nothing you do in
a subshell should affect the parent shell (except of course
explicit process killing or poweroff or other pathological
cases). in particular:

f() {
  (eval "$something"; foo); echo done
}

The $something evaluation might cause the subshell to exit, but
"done" should always be printed.


I don't think many would expect that in:

f() {
  return | cat
  echo "$(return)"
  return &
  (return)
  echo done
}

any of those returns would return from the function. I don't see
it desirable that it does. I'm ok for the first one to be left
unspecified but only on the ground that POSIX currently leaves
it unspecified which component of a pipeline may not be run in a
subshell environment (though in practice, shells run either all
components in subshells or only the rightmost one).

-- 
Stephane

Reply via email to