Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

"return" is an always block



Hiya,

I noticed that

f() { {} always {return}; echo here }

did output "here", that is, the "return" statement doesn't
return from the function. Is this the intended behavior?

So, if one wants to return from a function without setting the
error condition, is the only way to do something like:

f() { 
  err=0
  { TRY-BLOCK } always {
    if ((TRY_BLOCK_ERROR)) {
      err=1
      TRY_BLOCK_ERROR=0
    }
  }
  if ((err)) return 1
  ...
}

-- 
Stéphane



Messages sorted by: Reverse Date, Date, Thread, Author