3 ms·
Shell scripts are nicer than Python, though. There was a brief moment in time where Python nearly rivaled shell scripts in convenience and straightforwardness,
by caslon 5y ago
Shell scripts are nicer than Python, though. There was a brief moment in time where Python nearly rivaled shell scripts in convenience and straightforwardness, but November of 2008 was many years ago, now.
We should probably deprecate Bash, though. It doesn't offer enough over the standard for it to be worth it.
- rascul 5y ago> We should probably deprecate Bash, though. It doesn't offer enough over the standard for it to be worth it. Arrays make a world of a difference. Deprecate sh, keep bash.
- caslon 5y agoThat's a terrible idea. A shell scripting language doesn't need to do everything in the world. It just needs to tape together tools that can do everything. POSIX sh can pass arrays around just fine, and that's all it needs to do. Feature creep is the worst possible thing you could do to a shell scripting language.
- iforgotpassword 5y agoNo it can't. You have the argument array which is a horrible workaround. If you need to write scripts that interact with other tools a lot, bash is the language of choice. Starting and handling other processes is a messy thing in any other language.
- 1500100900 5y agoWhich POSIX sh do you have in mind and how does one pass arrays around in it?
- caslon 5y agoPOSIX sh. Pass it as a string, use standard programs to turn it into what you want. Voila. Not that hard. Just like you do everything else in UNIX.
- 1500100900 5y agoIf you mean a standard, it will be too abstract to be considered as something that can run anything. Sometimes it has to be too vague in order to not make existing Bourne-style shells non-compliant. This isn't, for example, a standard for the C programming language where you can throw some things into the UB bag or the ID bag. POSIX sh is more what you'd call "guidelines" than actual standard. Even if it were an implementation, how would you write a "POSIX sh" equivalent of these lines taken from a bash script? (My point isn't that it's impossible.) mkdir -p /tmp/nodes/{a,b,c,d,e} ; NODES=( /tmp/nodes/{a,b,c,d,e} ) ; echo ${NODES[$((`date +%-j` % ${#NODES[@]}))]}
- throwaway984393 5y agoBut POSIX sh doesn't have array support? 99% of my use case for Bash over POSIX sh is arrays, associative arrays, BASH_SOURCE, and PIPELINE (or whatever that array is that has positional pipe return status)
- iforgotpassword 5y agoThis. The problem most people have with bash scripts is that they are mostly writing sh scripts and occasionally throw in [[ ]] but still use 99% of the ugly workarounds and tricks you had to use in sh to get anywhere.