On Fri, 2024-11-01 at 04:01 +0000, Andrew via austin-group-l at The
Open Group wrote:
> What's the progress looking like for support of local, function
> scoped variables in POSIX sh?

There used to be a request[0] which as however rejected.

Given that different shells already implement `local` with different
semantics, it seems unlikely this will ever get resolved (as that might
break tons of code).


Maybe the best chance would be if another special built-in / attribute
would be implemented by shells, where all agree in advance on the exact
semantics (while keeping their own `local`), but even that seems rather
unlikely to me.


> Are subshells an effective workaround meanwhile?

Depends probably on what one wants to do, but you couldn't change
"global" variables from such functions (not outside the subshell)...
and it's probably not very efficient (if that matters).


Cheers,
Chris.


[0] https://austingroupbugs.net/view.php?id=767

  • status of lo... Andrew via austin-group-l at The Open Group
    • Re: sta... Lawrence Velázquez via austin-group-l at The Open Group
    • Re: sta... Christoph Anton Mitterer via austin-group-l at The Open Group
      • Re:... Andrew via austin-group-l at The Open Group
        • ... Lawrence Velázquez via austin-group-l at The Open Group
        • ... Stephane Chazelas via austin-group-l at The Open Group
          • ... Andrew via austin-group-l at The Open Group
          • ... Steffen Nurpmeso via austin-group-l at The Open Group
            • ... Stephane Chazelas via austin-group-l at The Open Group
              • ... Christoph Anton Mitterer via austin-group-l at The Open Group
                • ... David A. Wheeler via austin-group-l at The Open Group
                • ... Steffen Nurpmeso via austin-group-l at The Open Group
                • ... Stephane Chazelas via austin-group-l at The Open Group

Reply via email to