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

Re: Do local functions exist in Zsh?



On Tue, May 13, 2025 at 7:51 AM Joachim Ansorg <mail@xxxxxxxxxxxxxxx> wrote:
>
> A user requested support for "local functions" at
> https://github.com/BashSupport-Pro/bashsupport-pro/issues/200

In the forthcoming 5.10, you can simulate a local function with the
"mkshadow" utility.

          {
            mkshadow fname
            function fname {
              # Do your new thing
            }
            # Invoke callers of fname
          } always {
            rmshadow
          }

It's called "shadow" because the intention is to conceal a global
function with the same name, but it doesn't have to be used that way.




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