5 ms·
It seems that shell scripting languages tend to be quite ugly out of necessity? I mean bash is not a looker.
by worldsayshi 7y ago
It seems that shell scripting languages tend to be quite ugly out of necessity? I mean bash is not a looker.
- SOLAR_FIELDS 7y agoPossibly, though bash is from a much earlier time when shell scripting language design probably wasn’t a very well known topic and bash evolved more naturally from open source. Powershell is much more recent plus had much more complete control over the language to prevent the kind of syntax warts bash has. Even then I would still probably take bash over Powershell for scripting but that’s probably more because of familiarity than anything else.
- asveikau 7y agoThe first release of bash was in 1989. Shell scripting was already a thing at that time. Csh and ksh were also around for roughly a decade at that time. I think you are confusing bash with sh with this kind of statement.
- mattmanser 7y agoThey had an opportunity to make a whole new, good, scripting language. And blew it spectacularly.
- Ididntdothis 7y agoThe decision to make the console output as the return value of a function alone almost destroys it for larger scripting projects. It’s a really bad decision and they could still fix it by adding some environment variable that disables this “feature” while staying compatible with old scripts.
- apalmer 7y agoPREACH But just so you are aware you can use the 'class' modifier To change this behavior. It is one of the most fundamentally bizarre language design choices I have seen in my career
- Ididntdothis 7y agoI have used classes too but this has all kinds of other weird behavior.
- ptx 7y agoThis behavior? https://devblogs.microsoft.com/powershell/suppressing-return-values-in-powershell-functions/ https://devblogs.microsoft.com/powershell/suppressing-return... It seems like it might make some kind of sense, since it doesn't output directly to the console but rather to a pipe. Bash functions sort of work the same way since they don't have complex return values (aside from exit codes) other than the function's output stream.
- Fr0styMatt88 7y agoYeah, keep in mind that the output is a fully-fledged object, it is not the text you see. The text is generated by the PowerShell host if the returned object makes it back there and the host is set up to present that object to the user that way. Take the following in PowerShell: ls | sort DateTime -d ls returns an array of objects, sort then sorts the array by each object’s DateTime field (and here I’m asking it to sort in descending order with -d). The point is that sort isn’t depending on any text output, so it works with any array of objects regardless of the command that returned them. The other cool thing this enables is auto-complete awareness in the shell. If I typed: ls | sort <Tab> then the shell knows what makes sense in auto-completion here as ls has an actual return type and in this case it will give me a list of available fields that I can sort on. For those unfamiliar: ls and sort here are shortened aliases to more wordy verb-noun commands. These (as well as a large bunch of others) are given to you by default.
- pjmlp 7y agoYeah, PowerShell is the only mainstream shell that behaves like the REPL environments from Xerox PARC workstations. Structured data with direct access to any OS API, regardless how it is provided, .NET, COM or straight C like DLL. UNIX world never had that, beyond trying to fit language repls as user shell, which on UNIX always feels like a leaky abstraction.
- samatman 7y agoIt isn't inevitable by any means, fish shell scripting is clean and pleasant. I use fish as my command line, but I still write scripts in bash, even personal ones I only expect to use on my own machine. Just out of a vague sense that I might reuse it, or it might escape confinement, or something.