1 2 KSH-I VS. SH 3 4 5 6I have not made a complete comparison between 5.2 /bin/sh and ksh-i. A 7direct comparison of the manuals may uncover more incompatibilities than 8I have listed here. In addition, I have omitted some incompatibilities 9that are bugs in 5.0 sh that may have been fixed for 5.2. I have 10also omitted incompatibilities in cases that sh clearly is incorrect, 11such as in cases where it core dumps. I have also omitted cases which 12are bugs in ksh-i. I have omitted built-ins in ksh-i which are not in /bin/sh 13since this can be circumvented by using the alias facility if necessary. 14 15The following is a list of known incompatibilities between ksh-i and sh: 16 171. The IFS parameter is only effective for the read built-in and 18 after parameter and command substitution in ksh-i. Thus, IFS=x; 19 exit will execute e on the file it with sh but will exit with ksh-i. 20 212. If an environment parameter is modified by ksh-i, the new value 22 will be passed to the children. In sh you must export the 23 parameter for this to happen. 24 253. Time is a reserved word in ksh-i. Thus time a | b will time the 26 pipeline in ksh-i while only a will be timed with sh. You can 27 also time built-in commands and functions with ksh-i, you can't 28 with sh. 29 304. Select and function are reserved words in ksh-i. 31 325. Parameter assignments only have scope for the command or function 33 they precede in ksh-i. Only a subset of built-in commands in ksh-i treat 34 parameter assignments globally. In sh, all built-in commands and 35 functions treat parameter assignments as globals. (Notice that 5.0 36 and 5.2 treat parameter assignments to pwd and echo in an 37 incompatible way). 38 396. The output of some built-in commands and error messages is different 40 in a few cases, for example times produces two lines of output in ksh-i. 41 427. While loops with redirection are not executed in a separate process 43 in ksh-i so assignments made within loops remain in effect after the 44 loop completes. 45 468. The semantics of functions are somewhat different. Ksh-i can have 47 local variables and allow recursive functions. Errors in functions 48 abort the function but not the script that they are in. 49 509. The name space for functions and variables is separate in ksh-i. In 51 /bin/sh they share the same space. The unset builtin requires 52 a -f flag to unset a function in ksh-i. 53 5410. Words that begin with ~ may be expanded in ksh-i. Sh does not have 55 this feature. 56 5711. The character ^ is not special in ksh-i. In sh it is an archaic 58 synonym for |. 59 6012. Whenever (( occurs where a command name is valid, ksh-i assumes 61 that an arithmetic expression follows. In sh this means a 62 sub-shell inside a sub-shell. 63 6413. Non-blank contiguous IFS delimiters generate a null input argument. 65 Therefore, you can use IFS=: and correctly read the /etc/profile 66 file even when fields are omitted. In sh, multiple delimiters 67 count as a single delimiter. 68 6914. Arithmetic test comparison operators (-eq, -lt, ...) allow any 70 arithmetic expressions. Sh allows only constants. If you say 71 test x -eq 0 in sh, which is meaningless, it returns true, but 72 in ksh-i it depends on the value of the variable x. If there 73 is no variable x, then ksh-i produces an error message. 74 7515. The environment handed down to a program is not sorted in ksh-i. 76 A user should not reply in this quirk of sh since any user 77 program can provide an environment list which does not have 78 to be sorted. (Getenv(3) does not assume a sorted list). 79 8016. There is an alias hash in ksh-i which does what the 5.2 has 81 built-in hash does except for the -r flag. In ksh-i, you must say 82 PATH=$PATH to achieve the same result. 83 8417. The expansion of "$@" with no arguments produces the null string 85 in the Bourne shell and produces nothing with ksh-i when there are 86 no arguments. I am not sure whether this is a bug in the Bourne 87 shell or intentional. The manual page leads me to think that it 88 is a bug. Set -- with no arguments unsets the positional parameter 89 list in ksh-i. Thus, scripts that use set -- "$@" when there are 90 so positional parameters will not break. 91 9218. Ksh-i accepts options of the form -x -v as well as -xv both for 93 invocation and for the set builtin. The Bourne shell only allows 94 one option parameter. 95 9619. Ksh-i does not allow unbalanced quotes with any script. If the end of 97 file is reached before a balancing quote in sh, it quietly inserts 98 the balancing quote. Ksh-i, behaves like sh for eval statements. 99 10020. Failures of any built-in command cause a script to abort in sh. Ksh-i 101 scripts will only abort on errors in certainly documented built-ins. 102 In this respect ksh-i treats most built-in commands semantically the 103 same as non-builtin commands. 104 10521. The sequence $( is special in ksh-i. In sh the sequence is illegal 106 unless quoted. When used with "", $( must be preceded by a \ in 107 ksh-i to remove its special meaning. 108 10922. The built-in command exec when used without arguments (for I/O 110 redirection), will close on exec each file unit greater than 2. 111 11223. Ksh-i has some added security features which may cause some setuid 113 programs to stop working. Whenever the real and effective uid 114 of a shell program is different, ksh-i sets the -p mode which resets 115 the PATH and omits user profiles. The file /etc/suid_profile is 116 executed instead of the ENV file. 117 118I am interested in expanding this list so please let me know if you 119uncover any others. 120