On 10/24/26 05:53, Janis Papanagnou wrote:
> On 2026-10-24 05:59, c186282 wrote:
>> >>    KSH and BASH are "mostly compatible". Minor diffs but >>    nothing hard to get around. Anything you can do in KSH >>    can be done in BASH.
> > This is not correct. While Bash has over time adopted quite > some features from Ksh - but sadly needed often far too many > years for that - there's still a lot substantial functions > in Ksh that Bash has not implemented (or substituted by some > equivalent feature). >
>> [...] >> >>    If KSH works for you then stick with it.
> > I use Ksh meanwhile for ~35 years, and since I use a lot of > Ksh features that Bash just doesn't support there's certainly > no reason to switch. (Also its speed is a criterion, BTW. And > back then there were no Bash versions on commercial Unixes; > but commercial Linuxes haven't the prevalence any more today, > and play no role now in my private systems context.) >
>>    Note however that MOST distros default to BASH now -
> > Yes, Linux often has Bash as its default. >
>>    so if you plan >>    to 'distribute' your work it'd be better to move your >>    stuff over to BASH.
> > Certainly not. > > And this is short-sighted. If _portability_ is an issue you'd > better stick with the POSIX subset of both, Ksh and Bash. > > (Sadly, as we observe, especially "Linux kiddies" often don't > know what that POSIX subset actually is; in their scripts they > are writing #!/bin/sh and using some bash-specific syntax not > realizing that there's a difference, and that Bash is not the > [portable] *standard*.)
Delay does not necessarily equate with 'ignorance'. Different developers ... everyone had their own idea of a 'perfect shell' - but then had to adapt and adapt again as the Real Needs became more obvious. Now, most WILL do the same things - just slightly different syntax. I rather liked the 'c-shell' long back because it, well, 'looked like C'. It was one of the things that attracted me to Unix/Linux in the first place. Now I'm happy (ok, that's not really the word) with BASH. Not much it can't do ... but the fudged-fudged-fudged syntax to add features over time CAN be a pain in the ass. If I want 'scripting' now, I do it with Python. BASH or whatever, maybe it just EVOKES the Python scripts, a one or two-liner. Wrote many rather long BASH scripts in the past, and while they worked they were, well, just TOO messy/cryptic. Last big BASH script I did was for backing up a bunch of on-network drives. Mount-checking (important), calls to rsync and openSSH and ftp, local AND 'cloud', all with some confirmation checks along the way. SEMI-repeating units but each was a bit 'special'. (ALWAYS pre-encrypt before sending to 'cloud' - I do NOT trust the providers one bit. Mine had an extension that 'suggested' some kind of ZIP, just to help them waste time) RE-did it in Python. MUCH shorter and more comprehensible and a nice easy CSV config file you could tweak in a text editor or spreadsheet. Python made it all BETTER. Had a 'C' version of that backup pgm earlier. Worked fine, but there was a lot of string checking/editing involved and 'C' is CLUNKY with string shit. Python stole the FORTRAN string-slicing stuff, good deal ! Won't ever use BASH or any other 'shell script' for that kind of task again. Those might be "trad -IX" but IMHO they're just OVER. "Solutions" MOVED ON.
>>    Most distros, users would have to >>    intentionally install KSH and scripts would need a >>    shebang at the top to specify which shell to use.
> > I don't recall to have ever "intentionally installed" Ksh on > Linux. Earlier Linuxes had just a (sub-optimal!) PD-ksh that > you could use out of the box. Later they provided also the > much better "original" [AT&T] Ksh, and meanwhile you find on > (some?) Linuxes ksh93u+m, Martijn Dekker's improved version.
Um ... these days, almost all distros, you do have to "intentionally install" KSH or any rivals. BASH rules by default.
> Of course you can call shell scripts with the executable-flag > set and with a she-bang line on top. Personally I run most > shell scripts with the interpreter explicitly provided, as in >   ksh my-script flags arguments > allowing easy debugging by adding '-x' without explicit 'set' > command in the script. Only if some script gets the status of > a "standard-command" I regularly use I set the shebang. YMMV.
Direct spec of the shell IS useful, however the 'shebang' trick works well too.
> (So you don't "need" a shebang line, but it's useful.) >
>>    (good practice, always add the shebang)
> > Yes, if you are running your scripts executable script (or if > you want to give your editor a hint for syntax highlighting, > what shell is actually used, or just for specification purpose; > but note, as said above, that we see many people have no clear > idea about what a "/bin/sh" is and where /bin/bash or /bin/ksh > differ from the standard.
I have, I think, FOUR shells on this machine. The shebang IS required/desired. Still kinda like 'tcsh', it's there in case I get a brain-worm and wanna fool around with olde-dayz stuff. Zsh ain't so bad either. But, as said, for 'scripting' now, Python is by far my #1 choice unless the script is like a simple little ten-liner. Tend to use those on my PIs. Fooled around a bit with Lua and Ruby for scripting, but, really, Python and the MASSIVE number of libs have them beat. Python will do ANYTHING these days, just not as fast as 'C'. However CPU speed is less of a thing these days - I/O ops drag things down more than the CPU - so Python and 'C' can usually compete pretty well. There are Python compilers too. The main issue there is all the sub-sub-versions of Python, so you always have to include the entire binaries into each compilation to ensure it'll work. But then space is also a minor issue now as well unless you're doing micro-controllers. Did my share of those - DO teach you how to really SQUEEZE shit in - all computer kiddies should learn MCs first. . . . ("Harry talks in his sleep, didn't you notice ?" Slight telling delay, then Hermonie says 'No' :-)