Hacker News new | ask | show | jobs
by mzvkxlcvd 1552 days ago
is ksh still relevant today? at my first job i worked on IBM AIX systems that only supported ksh, and all the old timers were convinced that bash was inferior
5 comments

I use it, both interactively and for scripts.

One reason is that its `getopts` makes it very easy to provide full short and long option processing with help messages; script boilerplate is something like

    usage=$'
      [-1]
      [a:a-long-option?Help text]:[number]
      [b:bool-long-option?Helpful text]
    '
    while getopts "$usage" c
    do
        typeset opt_$c="${OPTARG:-1}"
    done
Another is that the final command of a pipeline runs in the shell environment, so that you can do things like

    bunch |
      of |
      commands |
      while read some stuff
      do
        RESULTS[$some]="$stuff"
      done
and then use the $RESULTS. That is fairly painful in bash; basically you have to wrap the entire rest of the script in { … }.
Yup, it's the default shell in OpenBSD ( see 4th-last bullet point at https://www.openbsd.org/faq/faq1.html#OtherUnixes )
I've worked at a shop with a lot of legacy code and a very fragile build environment. The myriad of scripts that source scripts that source other scripts to produce a working build were all written in KSH - as well as the majority of the tools to set up an environment to actually run the software. Since these scripts were intended to be sourced, adding a shebang doesn't solve the issue at all.

Fortunately, zsh can operate in ksh emulation mode [1] so I was able to leverage zsh while I was there to some extent.

The system I worked on there is still being actively used and developed today and still relies on a fragile set of ksh scripts to build and run in certain environments.

[1] https://zsh.sourceforge.io/Doc/Release/Invocation.html#Compa...

I was an avid reader of RHEL release notes during 6.x/7.x times and I was surprised to see ksh package not only being shipped but being actively maintained and getting several bug fixes at every point release.

So yes, somebody still must've been using it.

I can almost guarantee in some dark corner there is an organization still using ksh. I know because I have encountered this for different, otherwise defunct shells.