11 ms·
My feeling is that it is about convenience when typing at the terminal. Having a unified language for both scripting and entering commands is quite convenient.
by sodapopcan 5y ago
My feeling is that it is about convenience when typing at the terminal. Having a unified language for both scripting and entering commands is quite convenient. Also, bare strings while typing at the terminal is very convenient! It would be really annoying if we always had to add quotes for string args when we're typing at the terminal:
$ cat "file.txt"
...and I don't even know what options would look like... maybe:
$ ls "*.txt", ["l", "a"]
I dunno... this would mean we'd probably need parens now for precedent-type concerns:
$ ls("*.txt", ["l", "a"]) > "file.txt"
Anyway, that is why I understood that it's this way. I can't point to a resource about it, though.
- jandrese 5y agoYou look like you are just about to discover Powershell.
- psyclobe 5y agoPowershell is how I instrument cross platform CI scripting, with the power of the module concept and manifess now you can write real powerful type safe apis that can run anywhere. It has its quirks though...
- joombaga 5y agoAny gotchas with running the same scripts on Windows and Linux? I've been thinking about switching to PowerShell. Love it on Windows. Never tried it on Linux but I did try it on macOS a few years ago and remember some quirks. Currently a bash (over)user.
- psyclobe 5y agoOne gotcha is powershell core has some different apis then the 'windows powershell', best to deploy core on both systems to unify the api. Also powershell has no support for automatically handling external shell commands that error, you must manually check $LASTEXITCODE (easily done with a custom invoke api that you use for everything). Also well, some of the escaping in strings is really odd...
- pajko 5y agoYou have to add quotes in bash if the filename contains a space. Variables should also be quoted for the same reason, because their values might contain spaces. "${var}"
- fstrthnscnd 5y ago> It would be really annoying if we always had to add quotes for string args when we're typing at the terminal With bash (and I suspect with every other popular shells out there), it actually means something different. In your second example, if you don't use quotes, the shell will do the extensions, but if you do, the process will have to do it (and in the case of ls, it cannot). In some case it's good to have the shell taking care of it, but sometimes (eg, when using 'find') it's not.
- sodapopcan 5y agoMy examples are a made-up idea of what a “real” programming language would look like in a shell, not actual bash.
- fstrthnscnd 5y agoSorry, clearly my comment wasn't very helpful. I was trying to point out that quoting parameters or not could bring a different meaning for a shell (as one could see it with Bash), with the implied consequence that one would have to carry over that nuance somehow to a shell where all parameters would have to be quoted.
- fooofw 5y agoI feel like this comment is almost a kind of inverse of https://news.ycombinator.com/item?id=23424853 https://news.ycombinator.com/item?id=23424853 (which I remember to have found interesting).