Comment by garethrowlands
2 days ago
> System shell, however, isn't meant for writing entire applications.
Programmable shells are, in fact, for programming. That posix shell syntax makes it impractical for meaningfully large scripts is something you just accept. And, realistically, it is something you have to accept.
Minimalism isn't why posix shell syntax is bad. For example, awk and jq are minimal but don't make the same mistakes.
Powershell was never designed to be your system shell (Windows doesn't really rely on one) but the main reason it can't be the shell is startup time, which rules it out of wrapper scripts. Its having lots of features might contribute to that but it's not the problem per se (being built on .net is the reason - that and startup time not really mattering on windows). Its lacking the syntax problems of posix shells is very much not a problem. Powershell's error handling is just fine, by the way.
The startup time of even pwsh is too slow to be usable in many scenarios.
PowerShell's not going to be the system shell on your *nix box but it wasn't designed to be. But your posix shell isn't the system shell because it's better. It's pretty much the ultimate expression of worse is better.
That's why there's an industry of alternatives without the faults, such as oil, elvish, fish, nushell. And why awk is so popular.
There are many programs that aren't applications. For example, databases. You wouldn't argue that because you can program in eg. SQL it should be able to make applications with a robust command-line interface, right? Same idea applies to system Shell. Its purpose is to expose the operating system functionality interactively and for ad hoc automation. It is deliberately made simple and therefore incapable of more advanced system programming because complexity creates problems in this particular domain.
For instance, consider that Unix Shell only has one data-type: strings. I believe this was a deliberate decision by its creators (or a stroke of luck). Compare this to languages s.a. original JavaScript with a handful of built-in types, or, even worse, modern JavaScript with user-defined types. Even though the language tries hard to supply default "solutions" to type mismatch errors, it doesn't work well, and sometimes, at all. Unix Shell is inherently incapable of type errors.
While in statically checked programs, or even dynamically checked ones with robust debugging tools types could prevent certain kinds of programming errors, in the mostly interactive programs types make no sense. There simply isn't enough code to generate the kinds of problems types are supposed to solve.
> Minimalism isn't why posix shell syntax is bad.
I never said that.
> Powershell was never designed to be your system shell
Parent wants to replace Linux system shell with PowerShell, that was the reason I replied in the way I did.