Log in



Posted on 2016.09.13 at 15:48
Current Location: 67114

Korn shell no longer ships with SLES 12 SP1.

It does however, ship with something called legacy ksh - lksh (symlinked to ksh) but which behaves differently than actual ksh, and reports itself as mksh - which incidentally also behaves differently. By "differently" of course I mean so fundamentally modified, our DBA's thought their scripts had been possessed by demons - I was asked to look into an online ordination as to perform exorcisms on our newly installed servers during the next maintenance window. But I digress. The point is, we'll need to use ksh93, which requires installation of the Legacy Add-On Module.

sles12sp1:/ # cnf ksh93

The program 'ksh93' can be found in following packages:
* ksh [ path: /bin/ksh93, repository: zypp (Legacy_Module_12_x86_64:SLE-Module-Legacy12-Updates) ]
* ksh [ path: /bin/ksh93, repository: zypp (Legacy_Module_12_x86_64:SLE-Module-Legacy12-Pool) ]

Try installing with:
zypper install ksh

From the official release notes:

With SLE 12 SP1, we release KSH 93u, which is more stable version 93v. In order to provide a regular update path from 93v to 93u, a higher version number (93vu) has been used for this update.

This is the point at which I learned system administrators apparently struggle with sequential $PATH variables, (dot).[profile] variables, or both, as SLES 12 has solved this manufactured problem by creating an overly complex "alternatives" hierarchical solution in which well-known binaries can be symbolically linked to any number of derivative binaries.

Which might be awesome if it worked right out of the box. Here we see that ksh is actually lksh

sles12sp1:/ # update-alternatives --query ksh

Name: ksh
Link: /bin/ksh
ksh.1.gz /usr/share/man/man1/ksh.1.gz
usr-bin-ksh /usr/bin/ksh
Status: auto
Best: /usr/bin/lksh
Value: /usr/bin/lksh

Alternative: /usr/bin/lksh
Priority: 15
ksh.1.gz /usr/share/man/man1/lksh.1.gz
usr-bin-ksh /usr/bin/lksh

No problemo; man-page says --config name will show available alternatives for a link group and allow the user (me) to interactively select which one to use. Easy as pie. Everyone likes pie. So let's check out our options since we've already installed the Legacy Add-On Module, and choose ksh93 as our our back-end symlink:

sles12sp1:/ # update-alternatives --config ksh

There is only one alternative in link group ksh (providing /bin/ksh): /usr/bin/lksh
Nothing to configure.

Huh. Well let's go ahead and install one, k? Should be easy according to the man-page:

--install link name path priority [--slave link name path]...

sles12sp1:/ # update-alternatives --verbose --install /usr/bin/ksh ksh /bin/ksh93 20
update-alternatives: renaming ksh link from /bin/ksh to /usr/bin/ksh
update-alternatives: using /bin/ksh93 to provide /usr/bin/ksh (ksh) in auto mode

Its important to note you can't just choose to not have a slave in this configuration, because though it exited without error, we now get:

sles12sp1:/ # update-alternatives --query ksh
update-alternatives: error: /var/lib/rpm//alternatives/ksh corrupt: slave link same as main link /usr/bin/ksh

Therefore we MUST provide a slave link, which has to be in a very specific order, apparently, because mine failed with an inaccurate error message before I swapped the /bin/ksh and /usr/bin/ksh in the command below:

sles12sp1:/ # update-alternatives --verbose --install /usr/bin/ksh usr-bin-ksh /bin/ksh93 20 --slave /bin/ksh ksh /bin/ksh93
update-alternatives: setting up automatic selection of usr-bin-ksh
update-alternatives: using /bin/ksh93 to provide /usr/bin/ksh (usr-bin-ksh) in auto mode

Now, this worked, but still gives me a slave-link error in --query, but we can see it worked here, following all the symlinks:

sles12sp1:/ # which ksh
sles12sp1:/ # ls -al /usr/bin/ksh
lrwxrwxrwx 1 root root 29 Sep 13 13:26 /usr/bin/ksh -> /etc/alternatives/usr-bin-ksh
sles12sp1:/ # ls -al /etc/alternatives/usr-bin-ksh
lrwxrwxrwx 1 root root 10 Sep 13 13:26 /etc/alternatives/usr-bin-ksh -> /bin/ksh93

Previous Entry  Next Entry