5 ms·
In a redesigned shell, ideally there would be a richer way to describe the result of a program. Maybe "return an integer and consult the manual to see what it m
by adamch 6y ago
In a redesigned shell, ideally there would be a richer way to describe the result of a program. Maybe "return an integer and consult the manual to see what it means" isn't the best way forward.
Personally, I think Result types from Rust/Haskell/Swift make a lot of sense -- a program either succeeds with some output, or fails with an explanation of why. By default, pipes stop piping if one command fails.
- moonchild 6y ago> Personally, I think Result types make a lot of sense -- a program either succeeds with some output, or fails with an explanation of why Usually, this is what happens. Usually, the error-signalling return is accompanied by a message (posted to stderr). > By default, pipes stop piping if one command fails set -o pipefail
- toastal 6y agopipefail is not available to POSIX shells like dash
- roryrjb 6y agoset -o pipefail is now part of POSIX[0] and I believe as soon as someone posts a patch to dash to implement it, it will get included[1]. [0]. https://www.austingroupbugs.net/view.php?id=789 https://www.austingroupbugs.net/view.php?id=789 [1]. https://lore.kernel.org/linux-dash/20200701015226.GA6839@gondor.apana.org.au/T/#t https://lore.kernel.org/linux-dash/20200701015226.GA6839@gon...
- toastal 6y agoThis is great! Thanks for posting it.
- karl42 6y agoPlan9 returns an error string instead of an error integer with the empty string signifying success. This seems like a simple and useful improvement to me.
- franga2000 6y ago> In a redesigned shell Correct me if I'm wrong, but aren't exit codes an OS-level thing? That would be one hell of a redesign! Not that I wouldn't absolutely love to have rich/structured return values, but that's already hard to do in a single-language system - even ignoring backwards compatibility, doing this in a traditional OS would require a level of cooperation I don't think the industry is capable of.
- majkinetor 6y ago> In a redesigned shell, ideally there would be a richer way to describe the result of a program And there is in PowerShell - you can return arbitrary complex object.
- codetrotter 6y agoDo people use PowerShell for interactive use a lot? As a Unix person my impression of PowerShell is that it’s more robust for scripting than the Unix shells, but that the Unix shells are more suitable for interactive use. And for anything of sufficient complexity and/or size I’d personally reach for either Python or I’d write a program in Rust. I guess in the end it comes down to personal preference and what you are familiar with. Incidentally, when I started at the university, when I was still using Windows, and PowerShell had recently come out I actually started with PowerShell and was getting comfortable with it. But we learned about Linux at the university and a friend I made at the university was showing me Linux stuff, and I started using Linux and FreeBSD instead of Windows. If it wasn’t for that then I’d probably have been a PowerShell person today.
- steveklabnik 6y agoI used PowerShell basically only in an interactive capacity for a few years, but have switched to nu full-time a few months back. There's enough aliases for bashisms that honestly, the largest hurdle to switching was "rm -r -Fo" rather than "rm -rf".
- cookiecaper 6y agoPowerShell is underrated, but it's its own worst enemy, stubbornly insisting on LongForm-VerbNoun syntax for all but the most common commands that anyone familiar with the shell would expect. A few UI touchups and it could go substantially further, especially as MS continues quietly gutting the NT heritage out of Win10 and integrating more and more nix-like features, including full Linux kernel emulation, all so you can run Docker without a VM! What a world. I continue to believe that within 10 years, Microsoft will have just switched entirely to Linux+WINE under the covers. :)