Ksh features incorporated into Zsh?

Here's the Wikipedia article on command shell comparison.

According to that, the only feature ksh has that zsh doesn't is Named parameters for user defined "types". There may be others as that article is not an exhaustive list, especially for obscure features.

Going in the other direction, the answer to your question could fill a book (possibly this one).

Zsh has many features that ksh doesn't. A few popular ones are command stack, directory stack, history sharing and rprompt.

  • Command Stack is when you're typing a command and you realize that you should run another command first. Just send the current line to the command stack, run the other command then pop the command off the stack. You can do this multiple times. (zsh is the only shell I know of that provides this).
  • Directory Stack (aka pushd/popd) is when you want to change to directories in succession then cd back in reverse order. (Many shells provide this, including bash).
  • History Sharing is where every open shell shares a single common history. Execute a command in one window, switch to another and it will be available in your history.
  • rprompt is just like your prompt, except it's right justified. Many people like to put the cwd or date in the rprompt.

Here are some discussions on Stack Exchange sites about zsh:

  • What zsh features do you use?
  • Unique features of bash compared to zsh

ksh88, the most famous variant as it was included in SVR4, the language bash is mostly based on, the one pdksh partly cloned, and whose subset is the basis for the POSIX specification of sh has not evolved much (apart from some bug fixes and POSIX alignments by some vendors) since its last release in May 1993 (ksh88i).

However, ksh93, a rewrite by David Korn, first released in December 1993 has been in active development until around 2014 and its source code was freed in 2000. The last official release, ksh93u+, was made in August 2012 (only a few weeks after you asked that question), and there was a "beta" release (ksh93v-) made in 2014 by the original authors after they were made redundant by AT&T with many new features.

There has been a community effort to carry on development and modernise the code, based on ksh93v- which led to a ksh2020, but that effort has now been abandoned. A separate effort to maintain ksh93u+ after that seems to be going the same way. While a new one (ksh93u+m) looks a bit more promising at the moment.

ksh93 is/was more than a shell. It was developed alongside a fleet of utilities reusing some of the same code and that could be made builtin in ksh93, a bit like busybox.

Note that it was more a research effort, is often considered experimental and is very under-documented.

While zsh was first and foremost developed to be a powerful interactive shell, ksh93's focus was more as a programming language. There have been a lot of effort on the language and on optimisation with a goal to be in a similar category as perl or python for instance.

There are many many features of ksh93 that zsh hasn't, like there are many many features of zsh that ksh93 hasn't, and both have borrowed feature from each other. There is a large set of common features, and there are things that both can do but in very different ways.

Among the things ksh93 has but zsh doesn't:

  • all the builtins of ast-open: ksh93 when built as part of ast-open has a lot of builtins that zsh doesn't have including improved versions of some standard utilities like date, join, head, tr, uniq, wc... (though zsh has some of the functionality of those in its own builtins or language features). That's the optimisation side of things. You can't be perl-like if you need to fork a process to do anything.
  • non-forking command substitutions ($(...)), and command substitutions that don't create a subshell environment ${ ...; }.
  • multidimensional arrays: a=((a b) (c d))
  • object-oriented programming features (types, structures, disciplines, methods...).
  • static scoping for variables and options (zsh has private for variables, but no static scoping for options).
  • name references (essential for a shell with static scoping and object programming structures, not so much with those with dynamic scoping like zsh or bash)
  • date/time manipulation including with natural language, crontab, iso formats in its printf and date builtins (zsh's strftime is very limited compared to that).
  • a few useful redirection operators (<#((...)) for seeking, <>; to overwrite and truncate...).
  • namespaces
  • job pools and coshells.
  • CSV/URI/HTML-entities/base64 encoding/decoding.
  • json encoding/decoding in ksh93v- to (de-)serialise its advanced data structures in a format that other tools can understand (very buggy, removed in ksh2020).
  • $"..." for message localisation
  • /dev/tcp, /dev/udp (zsh has ztcp, zsocket for UNIX domain sockets, but no UDP)
  • there also was a dtksh shell that add X toolkit functionality to ksh93 included in CDE in the 90s.
  • there's a shcomp to compile ksh code.

Tags:

Shell

Ksh

Zsh