3 ms·
"Variables may be declared to be local to a function by using a 'local' command."
by m4r35n357 7y ago
"Variables may be declared to be local to a function by using a 'local' command."
- frou_dh 7y agoHere's the spec. Where is it? https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
- m4r35n357 7y agoIt is in both ash and dash, the shells I mentioned. Your attempt at point scoring is irrelevant but expected. ash & dash are about 100kB executables (POSIX plus a tiny number of non-interactive improvments like 'local'), bash is 1100kB. Every shell and subshell.
- frou_dh 7y agoMy point is that POSIX shell purity is masochism. Understanding how it's the core and other shells build on top of it is certainly valuable, but it's not inherently particularly good to use.
- m4r35n357 7y agoMaybe we are at cross purposes. My default shell is bash, but my default "sh" is dash. This is as it should be (and is default in Debian & Ubuntu I think). If you are talking about interactive use, of course bash is the one to use, but for writing shell scripts, it is a 10X interactivity overhead" over dash.
- frou_dh 7y agoIMO it's a big win for scripts to at least be able to use Arrays in that otherwise "stringly-typed" world.
- aidenn0 7y agoAs a POSIX shell masochist myself, Arrays are the single biggest missing feature. POSIX shells actually do have one array: $@. Having more would make my life so much easier. The amount of gyrations I go through to account for the lack of arrays is easily 1000x worse than accounting for not having local variables.