5 ms·
Are you writing your scripts in sh instead of bash, perl, python, JavaScript?
by v_lisivka 9y ago
Are you writing your scripts in sh instead of bash, perl, python, JavaScript?
- Sir_Cmpwn 9y agoI prefer sh over bash for most of my scripts, but I will sometimes use Python instead.
- v_lisivka 9y agoSo you use python instead of sh, but you argue that we should use sh instead of bash, perl, or python. I'm not convinced. IMHO, we should use proper tool for the job instead of making artificial limitations. Bash is proper tool in lot of cases, unless old proprietary OS or very limited embedded OS are targeted.
- Sir_Cmpwn 9y ago>So you use python instead of sh That's not what I said >we should use proper tool for the job This is the implication of what I said. I do not think that bash is the proper tool in most cases.
- v_lisivka 9y agoSo it boils down to your personal taste.
- Sir_Cmpwn 9y agoFor most workloads where bash is suited, so is sh. For workloads where sh is insufficient, bash probably is too and you should just use a higher level language. Chill. You don't have to hold bash so close to your heart.
- v_lisivka 9y agoI'm author of bash-modules project. It's my attempt to create set of libraries for easier scripting on bash in strict mode. Most bash libraries are not designed for strict mode, so I created my own. If you prefer sh over bash so much, you can help me to make it compatible with sh, or just fork it. See https://github.com/vlisivka/bash-modules https://github.com/vlisivka/bash-modules
- Sir_Cmpwn 9y agoOr option three: not care about your project because bash sucks and continue to write sh without it.
- gkya 9y ago> old proprietary OS or very limited embedded OS i.e. all the *BSDs? Many Linux distros that ship with BusyBox only or FreeBSD/Linux type systems (AFAIK Debian and also maybe Gentoo allowed FreeBSD userlands)? POSIX Sh is quite capable. I maintain even my bashrc POSIX compatible, in order to not have any problems when I want to run my config on some remote machine, or on some local BSD installation (and I did run FreeBSD for more than a year, quite feasible option for a workstation IMO).
- sedachv 9y agoI see so many #!/bin/sh scripts with bashisms in them. These scripts are broken and will cause errors. /bin/sh is not always Bash even on Linux systems. It definitely is not on BSDs. There is no reason to use Bash for shell scripts when you can do the same thing portably.
- v_lisivka 9y agoYour example shows that advise to "use /bin/sh" doesn't help but creates problem. If someone wants to write portable script, then he must test it on significant subset of target systems.