4 ms·
I meant POSIX shell or more specifically a loosely defined subset of all these shell dialects that is reasonably portable in practice. I'm not saying that it's
by simias 4y ago
I meant POSIX shell or more specifically a loosely defined subset of all these shell dialects that is reasonably portable in practice.
I'm not saying that it's impossible to do, I'm saying that it's very difficult, requires every contributor to be extremely well versed into shell coding and the particular convention of the codebase, and small issues can easily snowball out of control. It's doable, but it's almost never worth it IMO. One notable exception is when you need max portability with effectively zero dependencies.
>In the 2000s, people used to say that it was impossible to write large stuff in JavaScript, and it was not a real language.
They were partly right, which is why modern web development bears very little resemblance with early 2000's JS hacking. Remember that even JQuery only appeared in 2006. And those were the dark days of IE6...
But IMO that's not exactly the same thing: the issue with Javascript was less with its syntax and more with the very poor Javascript API and standard lib (or lack thereof), shell scripting is the other way around in a sense: you have access to all the power of the OS and all the programs in it, but it's the actual programming language that's lacking.
Actually a decent language that would transpile to POSIX sh would be interesting, now that I think about it.
- alganet 4y agoThe POSIX standard for sh is broken, it was born broken. For example, all moderns shells support some form of `local` for declaring local variables. There are some small subtleties but consistent behavior can be achieved across interpreters. It's not on POSIX though. Shellspec complaints about it (but it shouldn't). It sounds small, but it's a huge thing to have local variables instead of a huge global scope. There are many other features that are widely available but with slightly different interfaces. Kind of what happened with ActiveX/XmlHttpRequest in JavaScript. What is missing is precisely documentation on the subset of stuff that _can_ be portable with coding standards, polyfills and adapters. I'm not talking about core utilities here. No `cat` or `grep` or nothing like it. Basially, `PATH=''`, only builtins are allowed. Even with this constraint, the shell is usable and powerful. Unfortunatelly, most people are well versed in bash+coreutils, not raw portable shell. It requires learning a few things that are not straightforward at first (variable substitution, how the shell forks processes, making evals without making a mess, nested quoting, etc). > Actually a decent language that would transpile to POSIX sh would be interesting, now that I think about it. That would be nice. I believe it can be written in shell itself, self-hosted and portable. It's hard work though (on the same level of writing babel from scratch).
- lmz 4y ago> Actually a decent language that would transpile to POSIX sh would be interesting, now that I think about it. Isn't this how we got the ultraportable monster configure scripts? Not sure about "decent" though...