1da2e3ebdSchin.H 1 ksh93 2da2e3ebdSchinKSH-93 is the most recent version of the KornShell Language 3da2e3ebdSchindescribed in 4da2e3ebdSchin"The KornShell Command and Programming Language," 5da2e3ebdSchinby Morris Bolsky and David Korn of AT&T Bell Laboratories, ISBN 0-13-182700-6. 6da2e3ebdSchinThe KornShell is a shell programming language, 7da2e3ebdSchinwhich is upward compatible with "sh" (the Bourne Shell), 8da2e3ebdSchinand is intended to conform to the IEEE P1003.2/ISO 9945.2 Shell and 9da2e3ebdSchinUtilities standard. 10da2e3ebdSchinKSH-93 provides an enhanced programming environment in 11da2e3ebdSchinaddition to the major command-entry features of the BSD 12da2e3ebdSchinshell "csh". With KSH-93, medium-sized programming tasks can be 13da2e3ebdSchinperformed at shell-level without a significant loss in performance. 14da2e3ebdSchinIn addition, "sh" scripts can be run on KSH-93 without modification. 15da2e3ebdSchin.P 16da2e3ebdSchinThe code should conform to the IEEE POSIX 1003.1 standard and to the 17da2e3ebdSchinproposed ANSI-C standard so that it should be portable to all 18da2e3ebdSchinsuch systems. Like the previous version, KSH-88, 19da2e3ebdSchinit is designed to accept eight bit character sets 20da2e3ebdSchintransparently, thereby making it internationally compatible. 21da2e3ebdSchinIt can support multi-byte characters sets with some characteristics 22da2e3ebdSchinof the character set given at run time. 23da2e3ebdSchin.P 24da2e3ebdSchinKSH-93 provides the following features, many of which were also inherent 25da2e3ebdSchinin KSH-88: 26da2e3ebdSchin.BL 27da2e3ebdSchin.LI 28da2e3ebdSchinEnhanced Command Re-entry Capability: The KSH-93 history 29da2e3ebdSchinfunction records commands entered at any shell level and stores 30da2e3ebdSchinthem, up to a user-specified limit, even after you log off. 31da2e3ebdSchinThis allows you to re-enter long commands with a few keystrokes 32da2e3ebdSchin- even those commands you entered yesterday. 33da2e3ebdSchinThe history file allows for eight bit characters in 34da2e3ebdSchincommands and supports essentially unlimited size histories. 35da2e3ebdSchin.LI 36da2e3ebdSchinIn-line Editing: In "sh", the only way to fix mistyped 37da2e3ebdSchincommands is to backspace or retype the line. KSH-93 allows you 38da2e3ebdSchinto edit a command line using a choice of EMACS-TC or "vi" 39da2e3ebdSchinfunctions. 40da2e3ebdSchinYou can use the in-line editors to complete filenames as 41da2e3ebdSchinyou type them. 42da2e3ebdSchinYou may also use this editing feature when entering 43da2e3ebdSchincommand lines from your history file. 44da2e3ebdSchinA user can capture keystrokes and rebind keys to customize the 45da2e3ebdSchinediting interface. 46da2e3ebdSchin.LI 47da2e3ebdSchinExtended I/O Capabilities: KSH-93 provides several I/O 48da2e3ebdSchincapabilities not available in "sh", including the ability to: 49da2e3ebdSchin.BL 50da2e3ebdSchin.LI 51da2e3ebdSchinspecify a file descriptor for input and output 52da2e3ebdSchin.LI 53da2e3ebdSchinstart up and run co-processes 54da2e3ebdSchin.LI 55da2e3ebdSchinproduce a prompt at the terminal before a read 56da2e3ebdSchin.LI 57da2e3ebdSchineasily format and interpret responses to a menu 58da2e3ebdSchin.LI 59da2e3ebdSchinecho lines exactly as output without escape processing 60da2e3ebdSchin.LI 61da2e3ebdSchinformat output using printf formats. 62da2e3ebdSchin.LI 63da2e3ebdSchinread and echo lines ending in "\e". 64da2e3ebdSchin.LE 65da2e3ebdSchin.LI 66da2e3ebdSchinImproved performance: KSH-93 executes many scripts faster 67da2e3ebdSchinthan the System V Bourne shell. A major reason for this is 68da2e3ebdSchinthat many of the standard utilities are built-in. 69da2e3ebdSchinTo reduce the time to initiate a command, KSH-93 allows 70da2e3ebdSchincommands to be added as built-ins at run time 71da2e3ebdSchinon systems that support dynamic loading such as System V Release 4. 72da2e3ebdSchin.LI 73da2e3ebdSchinArithmetic: KSH-93 allows you to do integer arithmetic in any 74da2e3ebdSchinbase from two to sixty-four. You can also do double 75da2e3ebdSchinprecision floating point arithmetic. 76da2e3ebdSchinAlmost the complete set of C language operators are available 77da2e3ebdSchinwith the same syntax and precedence. 78da2e3ebdSchinArithmetic expressions can be used to as an argument expansion 79da2e3ebdSchinor as a separate command. 80da2e3ebdSchinIn addition there is an arithmetic for command that works 81da2e3ebdSchinlike the for statement in C. 82da2e3ebdSchin.LI 83da2e3ebdSchinArrays: KSH-93 supports both indexed and associative arrays. 84da2e3ebdSchinThe subscript for an indexed array is an arithmetic expression, 85da2e3ebdSchinwhereas, the subscript for an associative array is a string. 86da2e3ebdSchin.LI 87da2e3ebdSchinShell Functions and Aliases: Two mechanisms - functions and 88da2e3ebdSchinaliases - can be used to assign a user-selected identifier to 89da2e3ebdSchinan existing command or shell script. 90da2e3ebdSchinFunctions allow local variables and provide scoping 91da2e3ebdSchinfor exception handling. 92da2e3ebdSchinFunctions can be searched for and loaded on first reference the 93da2e3ebdSchinway scripts are. 94da2e3ebdSchin.LI 95da2e3ebdSchinSubstring Capabilities: KSH-93 allows you to create a 96da2e3ebdSchinsubstring of any given string either by specifying the starting 97da2e3ebdSchinoffset and length, or by stripping off leading 98da2e3ebdSchinor trailing substrings during parameter substitution. 99da2e3ebdSchinYou can also specify attributes, such as upper and lower case, 100da2e3ebdSchinfield width, and justification to shell variables. 101da2e3ebdSchin.LI 102da2e3ebdSchinMore pattern matching capabilities: KSH-93 allows you to specify 103da2e3ebdSchinextended regular expressions for file and string matches. 104da2e3ebdSchin.LI 105da2e3ebdSchinKSH-93 uses a hierarchal name space for variables. 106da2e3ebdSchinCompound variables can be defined and variables can 107da2e3ebdSchinbe passed by reference. In addition, each variable 108da2e3ebdSchincan have one or more disciplines associated with 109da2e3ebdSchinit to intercept assignments and references. 110da2e3ebdSchin.LI 111da2e3ebdSchinImproved debugging: KSH-93 can generate line numbers on execution 112da2e3ebdSchintraces. Also, I/O redirections are now traced. 113*7c2fbfb3SApril ChinThere is a DEBUG trap that gets evaluated before each command 114da2e3ebdSchinso that errors can be localized. 115da2e3ebdSchin.LI 116da2e3ebdSchinJob Control: On systems that support job control, including 117da2e3ebdSchinSystem V Release 4, KSH-93 118da2e3ebdSchinprovides a job-control mechanism almost identical to that of 119da2e3ebdSchinthe BSD "csh", version 4.1. 120da2e3ebdSchinThis feature allows you 121da2e3ebdSchinto stop and restart programs, and to move programs between the 122da2e3ebdSchinforeground and the background. 123da2e3ebdSchin.LI 124da2e3ebdSchinAdded security: 125da2e3ebdSchinKSH-93 can execute scripts which do not have read permission 126da2e3ebdSchinand scripts which have the setuid and/or setgid set when 127da2e3ebdSchininvoked by name, rather than as an argument to the shell. 128da2e3ebdSchinIt is possible to log or control the execution of setuid and/or 129da2e3ebdSchinsetgid scripts. 130da2e3ebdSchinThe noclobber option prevents you from accidentally erasing 131da2e3ebdSchina file by redirecting to an existing file. 132da2e3ebdSchin.LI 133da2e3ebdSchinKSH-93 can be extended by adding built-in commands at run time. 134da2e3ebdSchinIn addition, KSH-93 can be used as a library that can 135da2e3ebdSchinbe embedded into an application to allow scripting. 136da2e3ebdSchin.LE 137da2e3ebdSchinDocumentation for KSH-93 consists of an "Introduction to KSH-93", 138da2e3ebdSchin"Compatibility with the Bourne Shell" and a manual page and a 139da2e3ebdSchinREADME file. In addition, the "New KornShell Command and Programming 140da2e3ebdSchinLanguage," book is available from Prentice Hall. 141da2e3ebdSchin 142