---
name: "pdksh"
section: "1"
platform: "linux"
package: "pdksh"
version: "50d-5"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/lksh"
---

# pdksh(1)

Legacy Korn shell built on mksh

Part of [lksh(1)](/lksh/1.md).

## NAME

**lksh** – Legacy Korn shell built on mksh

## SYNOPSIS

**lksh** \[**N+abCefhiklmnprUuvXx**\] \[**N+o** *opt*\]\[ **Nc** *string* **Ns** *file* \[*args* *...*\]\]

## DESCRIPTION

**lksh** is a command interpreter intended exclusively for running legacy shell scripts. It is built on **mksh**; refer to its manual page for details on the scripting language. It is recommended to port scripts to **mksh** instead of relying on legacy or idiotic POSIXNmandated behaviour, since the MirBSD Korn Shell scripting language is much more consistent.

## LEGACY MODE

**lksh** has the following differences from **mksh**:

- There is no explicit support for interactive use, nor any command line editing or history code. Hence, **lksh** is not suitable as a user4s login shell, either; use **mksh** instead.

- The KSH\_VERSION string identifies **lksh** as “LEGACY KSH” instead of “MIRBSD KSH”.

- **lksh** only offers the traditional ten file descriptors to scripts.

- **lksh** uses POSIX arithmetics, which has quite a few implications: The data type for arithmetics is the host ISO C *long* data type. Signed integer wraparound is Undefined Behaviour. The sign of the result of a modulo operation with at least one negative operand is unspecified. Shift operations on negative numbers are unspecified. Division of the largest negative number by N1 is Undefined Behaviour. The compiler is permitted to delete all data and crash the system if Undefined Behaviour occurs.

- The rotation arithmetic operators are not available.

- The shift arithmetic operators take all bits of the second operand into account; if they exceed permitted precision, the result is unspecified.

- The GNU **bash** extension & to redirect stdout and stderr in one go is not parsed.

- The **mksh** command line option **NT** is not available.

- Unless **set** **No** **posix** is active, **lksh** always uses traditional mode for constructs like:

  ```
  $ set NN $(getopt ab:c "$@")
  $ echo $?
  ```

  POSIX mandates this to show 0, but traditional mode passes through the errorlevel from the [getopt(1)](/getopt/1.md) command.

- **lksh**, unlike AT&T UNIX **ksh**, does not keep file descriptors  2 private.

## SEE ALSO

[mksh(1)](/mksh/1.md)

*https://www.mirbsd.org/mksh.htm*

*https://www.mirbsd.org/kshNchan.htm*

## CAVEATS

To use **lksh** as */bin/sh*, compilation to enable **set** **No** **posix** by default is highly recommended for better standards compliance.

**lksh** tries to make a cross between a legacy bourne/posix compatiblNish shell and a legacy pdkshNalike but “legacy” is not exactly specified.

The **set** builtNin command does not have all options one would expect from a fullNblown **mksh** or **pdksh**.

Talk to the MirOS development team using the mailing list at  mirosNmksh@mirbsd.org  or the #!/bin/mksh (or #ksh) IRC channel at *irc.freenode.net* (Port 6697 SSL, 6667 unencrypted) if you need any further quirks or assistance, and consider migrating your legacy scripts to work with **mksh** instead of requiring **lksh**.
