home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Learning the Korn Shell

Learning the Korn ShellSearch this book
Previous: A.5 bash Appendix A
Related Shells
Next: A.7 The Future of the Korn Shell
 

A.6 Workalikes on PC Platforms

The proliferation of the Korn shell has not stopped at the boundaries of UNIX-dom. Many programmers who got their initial experience on UNIX systems and subsequently crossed over into the PC world wished for a nice UNIX-like environment (especially when faced with the horrors of the MS-DOS command line!), so it's not surprising that several UNIX shell-style interfaces to small-computer operating systems have appeared, Korn shell emulations among them.

Shells that are called "Korn shell" exist for the Minix and Coherent operating systems, both of which are small, inexpensive UNIX-like systems for IBM PC-type machines. These shells are not very compatible with the 1988 UNIX Korn shell; they only have the most important Korn shell features, such as emacs and vi editing modes and shell functions.

Somewhat better is a version of pdksh for OS/2, which you can get in binary form (i.e., the executable, not the source code) from the USENET newsgroup comp.binaries.os2.

But far better than that is the MKS Toolkit, available from Mortice Kern Systems, Inc. The Toolkit is actually a complete UNIX-like environment for MS-DOS (version 2.0 and later) and OS/2 (version 1.2 and later). In addition to its shell, it comes with a vi editor and many UNIX-style utilities, including major ones like awk , uucp , and make .

The MKS shell itself is very much compatible with the 1988 UNIX Korn shell, and it has a well-written manual. Its only real syntactic difference is that it doesn't support the Korn shell's condition test syntax; you must use the old Bourne shell syntax instead.

The few other differences are due to limitations in the underlying operating systems rather than the shell itself. Most importantly, MS-DOS does not support multitasking or file permissions, so the MS-DOS version supports none of the relevant Korn shell features. The OS/2 version doesn't support file permissions either.

Specifically, the MKS shell for MS-DOS does not support the following:

  • Background jobs: & at the end of a command acts like ; , i.e., as a statement separator.

  • Job control: fg , bg , jobs , kill , and wait ; the options bgnice and monitor ; coroutines.

The MKS shells for both MS-DOS and OS/2 do not support the following:

  • File permission: umask , newgrp . The option privileged has been renamed to protected to reflect the lack of suid permission. Some test conditions have different meanings, as shown in Table A-1.

    Table A.1: File Permission Test Operators
    Operator UNIX Test MKS Toolkit Test
    -g setgid bit System attribute
    -k sticky (save text) bit Archive attribute
    -u setuid bit Hidden attribute
  • Filenames: all scripts must have names with the extension .ksh . Shell-related files have names that don't conform to MS-DOS file naming rules; Table A-2 shows MKS toolkit equivalents.

  • Environment variables that contain directory lists, such as PATH and MAILPATH , should use semicolons (; ) instead of colons (: ) to separate directories, because colons are used in DOS and OS/2 pathnames.

    Table A.2: MKS Toolkit Names for Shell Files
    UNIX Filename MKS Toolkit Filename
    .profile profile.ksh
    .sh_history sh_histo
    /etc/profile \etc\profile.ksh
    /etc/suid_profile \etc\suid_pro.ksh
  • Signals: the only ones supported are INT, ALRM, and STOP. The fake signals ERR and EXIT are supported, but DEBUG is not.

  • PPID is renamed PID .

  • Condition tests: -a (file existence) is renamed -e to avoid clashing with the -a operator (for logical "and") in the older test or [...] syntax. The > and < (lexicographic comparisons) aren't supported.

The MKS shell also supports a few features of its own. It uses $[ ...] (a la bash ) as an alternative syntax for arithmetic expressions, and it includes a few invocation and set options that are related to the underlying operating system.

Many UNIX users who have moved to DOS PCs swear by the MKS Toolkit; it's inexpensive ($299 at this writing), and it makes MS-DOS into a reasonable environment for advanced users and software developers. The Toolkit is available through most dealers that sell software tools, or through MKS itself. For more information, contact MKS, 35 King St. North, Waterloo, Ontario, Canada N2J 2W9, or electronically as follows:

Telephone (800) 265-2797 (US & Canada)
Fax (519) 884 8861
Internet toolkit@mks.com
CompuServe 73260,1043
BIX mks


Previous: A.5 bash Learning the Korn Shell Next: A.7 The Future of the Korn Shell
A.5 bash Book Index A.7 The Future of the Korn Shell

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System