Re: What version of korn shell?

From: Lothar Paltins (lpnews001_at_onlinehome.de)
Date: 06/20/04


Date: Sun, 20 Jun 2004 15:03:05 +0200

Frank Slootweg wrote:

> I think that a more important question is why, in this day and age,
> anyone would be using/wanting a Korn shell while, for all intents and
> purposes (no, I haven't looked at this particular issue, i.e. array
> limits), the (standard, i.e. /usr/bin/sh) POSIX shell is a compatible
> superset of the Korn shell?

Compatible to ksh88. Take a look at /usr/dt/examples/dtksh/ksh93.memo and
the ksh93 man page for the advanced features of the ksh93. Some examples:

    Pathnames of the form /dev/tcp/host/port or /dev/udp/host/port for tcp
    or udp connection to the corresponding socket.

    Pathnames of the form /dev/fd/n for passing and testing open file
    descriptors.

    ${parameter:offset:length} for extracting substrings.

    ${parameter/pattern/string} for string replacements.

    Associative arrays

    Number of array elements increased to 4096

    Nameref variables to reference another variable.

    Integer and floating point arithmetic.

    Structured variables consisting of several words separated by a ".".

    Discipline Functions.

    C interface to add built-in commands.

    KEYBD trap that enables changing of key bindings.

    ENV variable is evaluated only for interactive shells, no need any more
    for cryptic constructs like
    ENVFILE=~/.kshrc;ENV='${ENVFILE[(_=1)+(_$-=0)-_${-%%*i*}]}'

    ...

I think, bash has similar extensions, but I prefere ksh93 because of the
better compatibility to old ksh88 scripts. So the question today isn't
posix-shell or ksh, but bash or ksh93. Using the restricted posix-shell
syntax is ok only for system scripts or for scripts that should be easily
portable between different systems, IMHO.

Lothar

-- 
Lothar Paltins                                     lpnews001@onlinehome.de


Relevant Pages

  • Re: KORN SHELL FLOATING-POINT VARIABLE
    ... > How to define a floating-point variable in korn shell. ... Only the ksh93 version of korn shell has floating point variables. ... Chisolm's First Corollary to Murphy's Second Law: ...
    (comp.unix.shell)
  • Re: ksh->bash and floating point arithmetic
    ... > I have a set of KornShell (ksh93) scripts, some fairly large, which I ... bash tends to be easier to compile and install than ...
    (comp.unix.shell)
  • ksh->bash and floating point arithmetic
    ... I have a set of KornShell (ksh93) scripts, some fairly large, which I ... wish to convert to GNU bash scripts for the following reasons: ... bash tends to be easier to compile and install than ...
    (comp.unix.shell)
  • Re: Sun may have Solaris for Itanium already ready
    ... > backwards compatibility for you again; ksh93 would break someone's old ... > scripts, although I wish they'd put ksh93 out in a different directory ... Since Solaris 8, ...
    (comp.unix.solaris)