[Bug 296207] bin/sh: Don't inherit variables declared local by default
Date: Fri, 26 Jun 2026 04:11:40 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296207
pprocacci@gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pprocacci@gmail.com
--- Comment #1 from pprocacci@gmail.com ---
"The vast majority of shells don't do that." -- This simply isn't true.
- sh (ash-derived)
- dash (Debian/Ubuntu default sh)
- BusyBox ash
- mksh (MirBSD Korn shell)
- pdksh (Public Domain Korn Shell)
- zsh
All the above shells do exactly as you describe. They inherit the callers
variable stack. Outside of bash I don't know of a single shell that does this.
If you want portability, the answer is 'local myvar=""'. That works
everywhere.
--
You are receiving this mail because:
You are the assignee for the bug.