3 ms·
what kind of circumstance are people in where they can use posix sh but not bash? in the year 2022? I don't understand it. fucking everything has bash nowadays.
by _dain_ 4y ago
what kind of circumstance are people in where they can use posix sh but not bash? in the year 2022? I don't understand it. fucking everything has bash nowadays. and if you're on some machine that unaccountably doesn't have bash, then why can't you just sudo apt install bash, or scp the binary over and chmod +x it?
if you can't even do that, maybe reevaluate what life choices got you to this place. life is too short to write strictly posix sh.
- quesera 4y ago> posix sh but not bash? Many non-Linuxes, and some Linuxes too. > why can't you just sudo apt install bash Linux is not the whole world. Debian is not the whole Linux. Interactive shells on servers are not guaranteed to be available. Control over the installation image is not guaranteed, or always desirable. > life is too short to write strictly posix sh Alas. Life is too short for writing or responding to uninformed rants. Yet here we both are. POSIX shell scripting has its place. It's not as difficult or complicated as you imagine. The portability tradeoff is valuable or essential in many real-world cases.
- _dain_ 4y ago>Many non-Linuxes, and some Linuxes too. which ones can't run bash? >Linux is not the whole world. Debian is not the whole Linux. Interactive shells on servers are not guaranteed to be available. Control over the installation image is not guaranteed, or always desirable. I didn't literally mean "sudo apt install", I meant "install the thing by whatever means is appropriate to the platform". if you can't install anything then what are you actually doing with it? you have to get your software onto it somehow. and at any rate, the article is literally called "the Linux Command Line" >The portability tradeoff is valuable or essential in many real-world cases. like what? seriously, what? I don't get it. I understand software that has weird/harsh requirements because it's on a super constrained embedded platform. that's a real limitation. but being able to run posix sh but not bash seems like an entirely artificial problem. there's no rigorously conceivable resource constraint that would do that. if your unix is so fucking degenerate that it can't run bash then that's a problem of your own choosing. anyway if it's so easy, you can take on the burden of porting scripts from bash to sh yourself, instead of annoying the rest of us with the "bashisms" whining.
- quesera 4y agoNo whining here. I just think you're thinking too small. bash is usually convenient. When it's not convenient, it might be impossible. Shell scripts with long lives or broad usefulness should be portable. POSIX sh is just not that scary. It just takes a little extra discipline. It's an appropriate choice, more often than not.
- chasil 4y agoAndroid as policy does not allow GPL software in userspace. The MirBSD Korn shell, mksh, is used there as the system shell. That footprint is huge. Some utilities that I have used on Android bring a copy of Bash along, but it's not standard. I also mentioned above that I do some shell scripting with Busybox-win64. I can't use arrays in the "bash" that it implements. I've also worked on routers that use the Busybox shell, same problem. Dash is also far smaller and advertised as 4x faster than Bash. Anything I write that targets dash will run on all the others, so this skill is quite useful.
- _dain_ 4y agoOkay yes, I forgot about the GPL problem. That's a fair reason.