4 ms·
BASH is not an appropriate standard to use in writing a script. ShellCheck recognizes three hashbangs, POSIX, BASH, and the Korn shell (as is explained in the
by chasil 6y ago
BASH is not an appropriate standard to use in writing a script.
ShellCheck recognizes three hashbangs, POSIX, BASH, and the Korn shell (as is explained in the manual page). I would argue and assert that BASH is the least relevant of the three.
I have occasionally needed to write to the POSIX standard, and remove advanced features from my scripts. This is most commonly needed for BusyBox (including Windows) and Ubuntu/Debian DASH. It is important to understand what is not in POSIX, for the time when an advanced shell isn't available. Please browse the POSIX definition, reported by a google of "POSIX shell":
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
The Korn shell lived and diverged for many years, beginning with ksh88 (issued before the first BASH release in 1989). David Korn retired, and AT&T was not pleased with ksh93 changes implemented by outsiders who impacted both compatibility and performance, and thus ksh93 was rewound.
Cygwin, notibly, only implements mksh for Windows. The mksh binary on all platforms is a fraction of the size of BASH (check the output of the "size" command if an "ls" does not persuade you).
However, the MirBSD Korn shell is one of the most lively shells for development activity, the latest release being in October of 2020. It is also on every Android phone (chosen as the system shell by Google), so its deployment is massive.
When I am purposely writing above the POSIX shell, I choose mksh from MirBSD as my standard. I do not think the BASH innovations to be well-thought.
- joshenders 6y agoThe authors of Bash don’t capitalize Bash
- chasil 6y agoIf only they had chosen a more reasonable improvement on coprocesses, I would have used whatever case they wanted.
- abathur 6y ago> However, the MirBSD Korn shell is one of the most lively shells for development activity, the latest release being in October of 2020. https://lists.gnu.org/archive/html/info-gnu/2020-12/msg00003.html https://lists.gnu.org/archive/html/info-gnu/2020-12/msg00003...
- chasil 6y agoAs said, far more active. bash 5.0: https://www.osnews.com/story/129062/bash-5-0-released/ https://www.osnews.com/story/129062/bash-5-0-released/ 2019-01-08 MirBSD Korn 2020: Oct 31, 2020 mksh-R59c May 16, 2020 mksh-R59b Apr 14, 2020 mksh-R59 Mar 27, 2020 mksh-R58 Mar 1, 2019 mksh-R57
- abathur 6y agoAs said: > the MirBSD Korn shell is one of the most lively shells for development activity, the latest release being in October of 2020 I.e., you suggested the measure is release recency, not cadence. And after I pointed out that bash (sorry, BASH) has a more-recent release, you're moving the goalposts. Anyways. It doesn't matter. Love the shell(s) you love; hate the shell(s) you hate. You don't need a quantitative basis. They can release as often or as rarely as they like with little impact on whether they're good shells or not. Also: https://github.com/oilshell/oil/branches/all?query=release%2F https://github.com/oilshell/oil/branches/all?query=release%2...
- chasil 6y agoAs much of the scripting that I am required to maintain emerged from HP-UX, the "POSIX" shell on my legacy platform emerged from Korn (and I have the manual page to prove it - the text of the HP-UX "POSIX" shell manual page includes arrays and a number of other Korn features). The reason that the POSIX shell is not Korn is the existence of Microsoft Xenix, where the maximum size of the code/text segment is 64k. Debian chose the POSIX standard for precisely this reason: a minimal text segment. One particular thing that I like about Korn is this: function getv { nameref var="$1"; shift; print "$@"; read var; } This cannot be done with (my versions of) "bash." ShellCheck flips a gasket over this (legal) syntax. I will post some of my scripting that uses this feature if you have interest.
- tssva 6y ago> However, the MirBSD Korn shell is one of the most lively shells for development activity, the latest release being in October of 2020. The OpenBSD Korn shell is actively developed and there is a portable version of it available. The latest version which reflects the shell as available in OpenBSD 6.9 was released 3 days ago. https://github.com/ibara/oksh https://github.com/ibara/oksh
- chasil 6y agoI prefer the MirBSD variant, as does Google. This is one question upon which we agree.
- yjftsjthsd-h 6y ago> ShellCheck recognizes three hashbangs, POSIX, BASH, and the Korn shell (as is explained in the manual page). I would argue and assert that BASH is the least relevant of the three. Depends on how you call "relevant", but I disagree regardless. If you're writing a shell script, you either need to be hard-core portable, in which case POSIX is your only option, or you don't, in which case you're almost certainly targeting a GNU/Linux system with BASH installed. Of course, if you know that you're targeting a specific system with a specific shell installed then by all means; if I were primarily an OpenBSD dev, I'd happily use ksh. But in general, the (unix) world is always going to give you POSIX, and BASH is the second most widely available option. And bluntly, for all that I love shell, if you're trying to argue for the most elegant or sophisticated language, sh/BASH/ksh is irrelevant because all of them kinda suck outside of their niche.
- chasil 6y agoOracle requires ksh93 when installing their database. For myself, I write to the ksh93 standard, but reduced to mksh, because I desire functionality, but portability. The question of s/BASH/bash is not relevant to me. The toolset is the question. Noted again is that Cygwin only implements mksh, not ksh93. Write for what you have. It would make me nothing but happy should "bash" adopt ksh syntax. Perhaps I should struggle to be sufficiently adept to submit patches.
- technion 6y agoOracle's list of "required packages" is annoyingly large but I cannot find a particular shell amongst them. The installation guide appears to have a paragraph devoted to each of bash, "bourne or korn", and C shells.
- chasil 6y agoYou also do not realize that my Oracle strobe script runs on Windows, with the cygwin mksh binary. I wrote it that way.
- chasil 6y agoAnyone who thinks that "bash" is modern should read my POSIX critique. https://news.ycombinator.com/item?id=26178257 https://news.ycombinator.com/item?id=26178257
- chasil 6y agoI also did not think anything but mksh to be appropriate for handling inotify. https://www.linuxjournal.com/content/linux-filesystem-events-inotify https://www.linuxjournal.com/content/linux-filesystem-events...
- chasil 6y agoWhat many of you do not realize is the writing of POSIX scripts, for Windows, and how this is done. This is the most direct method. https://frippery.org/busybox/ https://frippery.org/busybox/