diff --git a/Build.sh b/Build.sh index 5846d99..1c98546 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $MirBSD: src/bin/ksh/Build.sh,v 2.1 2004/12/10 18:09:40 tg Exp $ +# $MirBSD: src/bin/ksh/Build.sh,v 2.2 2004/12/13 17:33:35 tg Exp $ #- # Copyright (c) 2004 # Thorsten "mirabile" Glaser @@ -20,27 +20,18 @@ # of this work, even if advised of the possibility of such damage. #- # Build the more or less portable mksh on most (non-MirBSD) UNIX®ish -# operating systems. -# Notes for building on various operating systems: +# operating systems. Building on various operating systems: # - Solaris: SHELL=ksh LDFLAGS=-ldl WEIRD_OS=1 sh ./Build.sh # - Interix: SHELL=ksh sh ./Build.sh (also on GNU and most *BSD) # - Mac OSX: SHELL=bash WEIRD_OS=1 sh ./Build.sh # # Explicit note: you _have_ to use a "modern" bourne-compatible pre- # installed shell to execute the build script, such as the GNU bash, -# PDKSH or any AT&T KSH. Explicit notice to Debian GNU/Some*nix pak- +# PDKSH or AT&T KSH; Solaris /usr/xpg4/bin/sh works as well; Solaris +# /bin/sh, zsh or non-bourne (csh, bsh) won't do. Rebuild afterwards +# with mksh (suggested). Explicit notice to Debian GNU/Some*nix pak- # kagers: you also have to set SHELL=/path/to/yourshell in the envi- # ronment of the script, as shown above. -# Shells known to work: -# - mirbsdksh, pdksh 5.2 -# - GNU bash 2.05* -# - Solaris /usr/xpg4/bin/sh -# Shells which should work: -# - AT&T ast-ksh (88 and 93) -# Shells known to *not* work: -# - Solaris /bin/sh (bourne non-POSIX) -# - non-bourne (csh, bsh, ...) -# - zsh SHELL="${SHELL:-/bin/sh}"; export SHELL CONFIG_SHELL="${SHELL}"; export CONFIG_SHELL diff --git a/NOTES b/NOTES index 8591204..9b411f3 100644 --- a/NOTES +++ b/NOTES @@ -1,4 +1,4 @@ -$MirBSD: src/bin/ksh/NOTES,v 2.1 2004/12/10 18:09:40 tg Exp $ +$MirBSD: src/bin/ksh/NOTES,v 2.2 2004/12/13 17:33:35 tg Exp $ $OpenBSD: NOTES,v 1.9 2003/10/26 15:07:25 jmc Exp $ General features of at&t ksh88 that are not (yet) in pdksh: @@ -246,254 +246,7 @@ Oddities in ksh (pd & at&t): - undocumented at&t ksh feature: FPATH is searched after PATH if no executable is found, even if typeset -uf wasn't used. -at&t ksh bugs: - [various versions: - MIPS m120 RISC/os 5.0: Version 11/16/88d - Dec alpha osf/1 v1.3: OSF/1 Version 11/16/88d NLS - HP pa HP-UX 9.01: Version 11/16/88 - ] - - (only hpux) - $ _[2]=hi - Bus error (core dumped) - - (only riscos, hpux) - $ typeset x[ - $ - - (only osf/1) - $ A=B cat << EOF - .$A. - EOF - Segmentation fault(coredump) - $ - - (only osf/1) - $ read "?foo " - foo Foo - $ set | grep Foo - =Foo - $ - - (all) - $ typeset -i A - $ typeset -L3 A - $ typeset -l A - Illegal instruction (core dumped) - - (all) - $ for i in a b c ; do echo $i, ${i[2]}, ${i[10]} ; done - a, , - a, , b - a, , c - $ - - (all) - $ echo ${abc:-G { I } K } - G { I K } - $ - $ abc=hi - $ echo ${abc:-G { I } K } - hi K } - $ - The second echo should only have printed 'hi'. - - (all) - $ echo ${abc:- > foo} - syntax error: > unexpected - $ - - (all? hpux) read reads too much from pipe (when pipe isn't stdin) - print 'hi\nthere' | ksh 8<&0 0< /dev/tty - $ read -u8 x - $ print $x - hi - $ cat 0<&8 - $ read -u8 y - $ print $y - there - $ - - (all) - $ umask 0 - $ umask - 00 - $ - - (osf, mips, !hpux) - $ exec alias - alias: not found - (shell dead) - - (all) non-white space IFS in non-substitution not preserved - $ IFS="$IFS:" - $ echo : "$@" # this is ok - : - $ echo :"$@" # this should print : too (me thinks) - - $ - - (only osf/1) - $ set +m - $ sleep 1 & # wait for a sec or two - $ jobs - Memory fault (core dumped) - - (all) - $ (sleep 1 & echo hi) & - [1] 123 - $ [1] 234 - hi - - (osf/1, mips) - $ getopts abc optc -a -b -c - $ getopts abc optc -a -b -c - $ getopts abc optc -a - Memory fault (core dumped) - - (osf/1) POSIX says OPTIND shall be initialized to 1 - $ echo $OPTIND - 0 - $ - - (osf/1 + others?) - $ typeset -ri r=10 - $ let r=12 - $ echo $r - 12 - $ - - (osf/1 + others?) - $ typeset -i a - $ typeset -L3 a - Memory fault (core dumped) - - (osf/1 + others?): -L strips leading \ \t\n\r, -R only strips trailing - spaces - $ typeset -L3 x - $ x=' ^I^J^M 2' - $ echo "($x)" - (2 ) - $ typeset -R3 y - $ x='2^I^J^M ' - $ echo "($x)" - (^I^J^M) - $ - - (osf/1 + others?) - $ typeset +i RANDOM - Memory fault (core dumped) - - (osf/1 + others?): -L/-R/-Z clear -l/-u after assignment and vise versa - $ typeset -u x=ab - $ echo "($x)" - (AB) - $ typeset -L4 x=def - $ echo "($x)" - (DEF ) - $ typeset | grep ' x$' - leftjust 4 x - $ - $ typeset -L4 x=def - $ echo "($x)" - (def ) - $ typeset -u x=ab - $ echo "($x)" - (AB ) - $ typeset | grep ' x$' - uppercase x - $ - $ typeset -i x - $ x='2()' - $ x='()' - $ x='2(4)' - - (osf/1, others?) - $ unset foo - $ echo "${foo:-"*"}" - - $ - - (osf/1, others?) - $ alias blah - blah: alias not found - $ alias -x blah | grep blah - blah - $ type blah - Memory fault (core dumped) - - (osf/1, others?) - $ trap 'echo hi; false' ERR - $ false - hi - hi - .... - Memory fault (core dumped) - - (osf/1, others?) - $ typeset +i ERRNO - Memory fault (core dumped) - - (osf/1, others?) - $ X=abcdef - $ echo ${X#a{b,c}e} # does not match {} inside word part of ${..#..} - abcdefe} - $ - - (osf/1, others?) - $ x=f=abcdef - $ echo ${f#a|abc} - def - $ echo ${f#abc|a} - bcdef - $ echo ${f#abc|a|d} - abcdef - $ - - (osf/1, hp-ux, others?) - $ i() echo hi - $ typeset -f - function i - { - hi - $ - - (osf/1, others?) - $ function X { - echo start of X - function Y { - echo in Y - } - echo end of X - } - $ X - start of X - end of X - $ typeset -f - function X - { - echo start of X - function Y { - echo in Y - } - echo end of X - } - function Y - { - echo in Y - echo end of X - } - } - $ - - (osf/1, others?) - $ while read x; do print -r "A $x"; done |& - [1] 18212 - $ exec 8<&p - $ kill %1 - Memory fault - - (osf/1, others?) Error only happens for builtin commands (/bin/echo works) - $ while read x; do print -r "A $x"; done |& - [1] 18212 - $ echo hi <&p - hi - $ echo hi <&p - ksh: p: bad file unit number - $ while read x; do print -r "A $x"; done |& - ksh: process already exists - $ - - (osf/1, others?) in restricted shells, command -p should not work. - $ PATH=/tmp ksh -r - $ print hi | command -p cat -n - 1 hi - $ - - (osf/1, others?) error message wrong for autoload files that don't define - functions - $ FPATH=/tmp - $ echo echo hi there > /tmp/aja - $ aja - hi there - ksh: echo: not found - $ - - (SunOS M-12/28/93d): - $ cat -n << X $( - > echo foo - > ) - > X - > echo bar - ) - ./ksh93: X: cannot open [No such file or directory] - Memory fault (core dumped) +[...] POSIX sh questions (references are to POSIX 1003.2-1992) - arithmetic expressions: how are empty expressions treated? diff --git a/PROJECTS b/PROJECTS deleted file mode 100644 index f60b8a5..0000000 --- a/PROJECTS +++ /dev/null @@ -1,103 +0,0 @@ -$MirBSD: src/bin/ksh/PROJECTS,v 2.1 2004/12/10 18:09:40 tg Exp $ -$OpenBSD: PROJECTS,v 1.5 1999/07/14 13:37:23 millert Exp $ - - -Wouldn't it be nice to: - * have 64 bit signed arithmetic in mirbsdksh expressions? - - -Things to be done in pdksh (see also the NOTES file): - - * builtin utilities: - pdksh has most if not all POSIX/at&t ksh builtins, but they need to - be checked that they conform to POSIX/at&t manual. Part of the - process is changing the builtins to use the ksh_getopt() routine. - - The following builtins, which are defined by POSIX, haven't been - examined: - eval - - The first pass has been done on the following commands: - . : alias bg break cd continue echo exec exit export false fc fg - getopts jobs kill pwd read readonly return set shift time trap true - umask unalias unset wait - - The second pass (ie, believed to be completely POSIX) has been done on - the following commands: - test - - (ulimit also needs to be examined to check that it fits the posix style) - - * test suite - Ideally, as the builtin utilities are being POSIXized, short tests - should be written to be used in regression testing. The tests - directory contains some tests, but many more need to be written. - - * trap code - * add the DEBUG trap. - * fix up signal handling code. In particular, fatal vs tty signals, - have signal routine to call to check for pending/fatal traps, etc. - - * parsing - * the time keyword needs to be hacked to accept options (!) since - POSIX says it shall accept the -p option and must skip a -- argument - (end of options). Yuck. - - * lexing - the lexing may need a re-write since it currently doesn't parse $( .. ), - $(( .. )), (( ... )) properly. - * need to ignore contents of quoted strings (and escaped chars?) - inside $( .. ) and $(( .. )) when counting parentheses. - * need to put bounds check on states[] array (if it still exists after - the re-write) - - * variables - * The "struct tbl" that is currently used for variables needs work since - more information (eg, array stuff, fields) are needed for variables - but not for the other things that use "struct tbl". - * Arrays need to be implemented differently: currently does a linear - search of a linked list to find element i; the linked list is not - freed when a variable is unset. - - * functions - finish the differences between function x and x(): trap EXIT, traps - in general, treatment of OPTIND/OPTARG, - - * history - There are two versions of the history code, COMPLEX_HISTORY and - EASY_HISTORY, which need to be merged. COMPLEX does at&t style history - where the history file is written after each command and checked when - ever looking through the history (in case another shell has added - something). EASY simply reads the history file at startup and writes - it before exiting. - * re-write the COMPLEX_HISTORY code so mmap() not needed (currently - can't be used on machines without mmap()). - * Add multiline knowledge to COMPLEX_HISTORY (see EASY_HISTORY - stuff). - * change COMPLEX_HISTORY code so concurrent history files are - controlled by an option (set -o history-concurrent?). Delete - the EASY_HISTORY code. - * bring history code up to POSIX standards (see POSIX description - of fc, etc.). - - * documentation - Some sort of tutorial with examples would be good. Texinfo is probably - the best medium for this. - - * miscellaneous - * POSIX specifies what happens when various kinds of errors occur - in special built-ins commands vs regular commands (builtin or - otherwise) (see POSIX.2:3.8.1). Some of this has been taken - care of, but more needs doing. - - * remove static limits created by fixed sized arrays - (eg, ident[], heres[], PATH, buffer size in emacs/vi code) - - * merge the emacs and vi code (should reduce the size of the shell and - make maintenance easier); handle SIGWINCH while editing a line. - [John Rochester is working on the merge] - - * add POSIX globbing (eg, [[:alnum:]]), see POSIX.2:2.8.3.2. - - * teach shf_vfprintf() about long long's (%lld); also make %p use - long longs if appropriate. diff --git a/README b/README index f30a49d..7e5008f 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -$MirBSD: src/bin/ksh/README,v 2.1 2004/12/10 18:09:40 tg Exp $ +$MirBSD: src/bin/ksh/README,v 2.2 2004/12/13 17:33:35 tg Exp $ This is the README for mirbsdksh, developed as part of the MirBSD operating system at The MirOS Project, and produced portably. @@ -6,19 +6,8 @@ Legal information is provided about a screenpage farther down. To build on MirOS only, issue 'make obj && make depend && make'. -To build on other systems, consult: - * if you have a pre-installed GNU bash or (pd)ksh - => there have been build problems e.g. with /bin/sh on - Solaris, which isn't the Bourne shell anyways - * if you can build statically - => this is not possible on Solaris and Mac OSX, for example - * if you need additional libs - -Then issue a command like -$ SHELL=bash bash ./Build.sh -$ SHELL=ksh WEIRD_OS=1 LDFLAGS=-ldl ksh ./Build.sh - -Always try with as few options first as possible. +To build on other systems, consult http://wiki.mirbsd.de/MirbsdKsh +or read Build.sh first. Set the CC, CFLAGS, CPPFLAGS and LDFLAGS environment variables to your likes. Don't complain if anything doesn't work. @@ -59,148 +48,16 @@ machines. For example, in the CS dept. of MUN, pdksh is installed on a variety of machines including Suns, HPs, DecStations, pcs running Linux, etc., and is the login shell of ~5200 users. -PDksh is currently being maintained by Michael Rendell (michael@cs.mun.ca), -who took over from Simon J. Gerraty (sjg@zen.void.oz.au) at the later's -suggestion. A short list of things that have been added since the last -public pdksh release (4.9) are auto-configuration, arrays, $(( .. )), -[[ .. ]], variable attributes, co-processes, extended file globbing, -many POSIXisms and many bug fixes. See the NEWS and ChangeLog files for -other features added and bugs fixed. - Note that pdksh is provided AS IS, with NO WARRANTY, either expressed or implied. Also note that although the bulk of the code in pdksh is in the -public domain, some files are copyrighten (but freely distributable) and -subject to certain conditions (eg, don't remove copyright, document any -changes, etc.). See the LEGAL file for details. +public domain, some files are copyrighted (but freely distributable) and +subject to certain conditions. If you would like to be notified via email of new releases as they become available, send mail to pdksh-request@cs.mun.ca with subject "send release notifications" (or "don't send release notifications" to stop them). - -Files of interest: - CONTRIBUTORS short history of pdksh, people who contributed, etc. - NOTES lists of known bugs in pdksh, at&t ksh, and posix. - PROJECTS list of things that need to be done in pdksh. - tests/* pdksh's regression testing system. - - -Compiling/Installing: - - The quick way: - ./configure - make - make check # optional - make install # will install /usr/local/bin/ksh - # and /usr/local/man/man1/ksh.1 - [add path-to-installed-pdksh to /etc/shells] - - The more detailed description: - * run "configure --help | your-favorite-pager" and look at the - --enable-* and --disable-* options (they are at the end). - Select any you options you wish to enable/disable - (most people can skip this step). - * run configure: this is a GNU autoconf configure script that will generate - a Makefile and a config.h. Some of the useful options to configure are: - --prefix=PATH indicates the directory tree under which the binary - and man page are installed (ie, PATH/bin/ksh and - PATH/man/man1/ksh.1). - The default prefix is /usr/local. - --exec-prefix=PATH overrides --prefix for machine dependent files - (ie, the ksh binary) - --program-prefix=pd install binary and man page as pdksh and pdksh.1 - --verbose show what is being defined as script runs - Note that you don't have to build in the source directory. To build - in a separate directory, do something like: - $ mkdir objs - $ cd objs - $ ../configure --verbose - .... - $ make - See the file INSTALL for a more complete description of configure and its - generic options (ksh specific options are documented in the --help output) - * miscellaneous configuration notes: - * If your make doesn't understand VPATH, you must compile in - the source directory. - * On DecStations, MIPS and SONY machines with older C compilers that - can't handle "int * volatile x", you should use gcc or turn off - optimization. The problem is configure defines volatile to nothing - since the compiler can't handle it properly, but the compiler does - optimizations that the volatile is meant to prevent. So. Use gcc. - * On MIPS RISC/os 5.0 systems, sysv environment, is - messed up - it defines sigset_t, but not any of the rest of - the posix signals (the sigset_t typedef should be in the - ifdef KERNEL section) - also doesn't have waitpid() or wait3(). - Things compile up ok in the svr4 environment, but it dumps core - in __start (perhaps our system doesn't have the full svr4 - environ?). Try compiling in the bsd43 environ instead (still not - perfect - see BUG-REPORTS file), using gcc - cc has problems with - macro expansions in the argument of a macro. - * On TitanOS (Stardent/Titan), use 'CC="cc -43" configure ...'. - When configure finishes, edit config.h, undef HAVE_DIRENT_H and - define HAVE_SYS_DIR_H (the dirent.h header file is broken). - * On Linux (red hat distribution), check that /dev/tty has mode 0666 - (not mode 0644). If it has the wrong permissions, ksh will print - warnings about not being able to do job control. - * on NeXT machines (3.2, probably other releases), the siglist.out file - won't be generated correctly if you try to use the system's compiler - (it has a broken cc -E and strange header files). There are two - ways to make it work: - 1) if you have gcc, use it (for everything). Alternatively, - force configure to use it for CPP, i.e., use - CPP="gcc -E" configure ... - 2) Force configure to use some extra CPPFLAGS, using - CPPFLAGS="XXX" configure ... - where XXX is obtained from running "cc -v YYY.c" on some - C file. Look at the options passed to cpp (there are lots - of them...) and replace the XXX above with them. - Make sure you do a "make distclean" (or "rm config.cache") if - you re-run configure with a difference CPP or CPPFLAGS. - Also note that if you are building multiple arch binaries, you - will have to specify both CC and CPP. - * run make: everything should compile and link without problems. - * run make check: this fires up a perl script that checks for some known - and some fixed bugs. The script prints pass/fail for tests it expected - to pass/fail, and PASS/FAIL for tests it expected to fail/pass. If you - don't have perl, or if your perl doesn't work (most common problem is - the .ph header files are missing or broken), you can run - ENV= path-to-pdksh-executable misc/Bugs path-to-pdksh-executable - instead. - * run make install: this installs ksh (in /usr/local/bin/ksh by default, - or where ever you told configure to put things). - * add path-to-installed-pdksh to /etc/shells if it's not already there. - This is only needed if you intend to use pdksh as a login shell (things - like ftp won't allow users to connect in if their shell isn't in this - file). - -The following is a list of machines that pdksh is reported to work on: - -/PC Linux 1.x,2.x - -/PC NetBSD 0.9a - -/PC BSDI 1.1 - -/PC FreeBSD 2.x, 3.x - -/PC OpenBSD - -/PC Interactive/Sunsoft 3.0.1 and 4.1 (note that problems have been - reported with isc3.2 - see the BUG-REPORTS file) - -/PC OS/2 - Commodore/Amiga NetBSD 1.0 - Dec/alpha OSF/1 v2.x, v3.x - Dec/alpha NetBSD 1.1B - Dec/pmax Ultrix 4.2 - Dec/vax Ultrix 2.2 (not tested recently :-)) - Dec/vax 4.3BSD+NFS (MtXinu) (not tested recently :-)) - HP/pa HP-UX 9.01 - IBM/RS/6000 AIX 3.2.5 - MIPS/m120 RISC/os 5.0 (bsd43 environ) - NeXT NeXTStep 3.2 - SGI/IRIX 6.2 - Sun/sun4 SunOS 4.1.3, 4.1.4 - Sun/sun4 Solaris 2.x - Sun/sun386i SunOS 4.0.2 - Sun/sun3 SunOS 4.0.3, 4.1.1_U1 - Stardent/TitanOS 4.2 - - Newer versions of pdksh may be available from ftp://ftp.cs.mun.ca:/pub/pdksh/ you may want to check for one if you run into any problems, as the problem may