1*b4dd7d09SAndy FiddamanHere is an overview of the source code organization for ksh93. 2*b4dd7d09SAndy Fiddaman 3*b4dd7d09SAndy FiddamanDirectory layout: 4*b4dd7d09SAndy Fiddaman 5*b4dd7d09SAndy Fiddaman The directory include contains header files for ksh93. 6*b4dd7d09SAndy Fiddaman The files nval.h and shell.h are intended to be public 7*b4dd7d09SAndy Fiddaman headers and can be used to add runtime builtin command. 8*b4dd7d09SAndy Fiddaman The remainder are private. 9*b4dd7d09SAndy Fiddaman 10*b4dd7d09SAndy Fiddaman The directory data contains readonly data files for ksh93. 11*b4dd7d09SAndy Fiddaman The man pages for built-ins are in builtins.c rather 12*b4dd7d09SAndy Fiddaman than included as statics with the implementations in the 13*b4dd7d09SAndy Fiddaman bltins directory because some systems don't make static const 14*b4dd7d09SAndy Fiddaman data readonly and we want these to be shared by all running 15*b4dd7d09SAndy Fiddaman shells. 16*b4dd7d09SAndy Fiddaman 17*b4dd7d09SAndy Fiddaman The directory edit contains the code for command line 18*b4dd7d09SAndy Fiddaman editing and history. 19*b4dd7d09SAndy Fiddaman 20*b4dd7d09SAndy Fiddaman The fun directory contains some shell function such as 21*b4dd7d09SAndy Fiddaman pushd, popd, and dirs. 22*b4dd7d09SAndy Fiddaman 23*b4dd7d09SAndy Fiddaman The directory features contains files that are used to generate 24*b4dd7d09SAndy Fiddaman header files in the FEATURE directory. Most of these files 25*b4dd7d09SAndy Fiddaman are in a format that is processed by iffe. 26*b4dd7d09SAndy Fiddaman 27*b4dd7d09SAndy Fiddaman The directory bltins contains code for most of the built-in 28*b4dd7d09SAndy Fiddaman commands. Additional built-in commands are part of libcmd. 29*b4dd7d09SAndy Fiddaman 30*b4dd7d09SAndy Fiddaman The directory sh contains most of the code for ksh93. 31*b4dd7d09SAndy Fiddaman 32*b4dd7d09SAndy Fiddaman The directory tests contains a number of regression tests. 33*b4dd7d09SAndy Fiddaman In most cases, when a bug gets fixed, a test is added to 34*b4dd7d09SAndy Fiddaman one of these files. The regression tests can be run by 35*b4dd7d09SAndy Fiddaman going to this directory and running 36*b4dd7d09SAndy Fiddaman SHELL=shell_path shell_path shtests 37*b4dd7d09SAndy Fiddaman where shell_path is an absolute pathname for the shell to 38*b4dd7d09SAndy Fiddaman be tested. 39*b4dd7d09SAndy Fiddaman 40*b4dd7d09SAndy Fiddaman The top level directory contains the nmake Makefile, the 41*b4dd7d09SAndy Fiddaman RELEASE file, the ksh93 man file (sh.1) and nval.3 and shell.3 42*b4dd7d09SAndy Fiddaman documentation files. The RELEASE file contains the list of bug 43*b4dd7d09SAndy Fiddaman fixes and new features since the original ksh93 release. The file 44*b4dd7d09SAndy Fiddaman COMPATIBILITY is a list of all known incompatibilities with ksh88. 45*b4dd7d09SAndy Fiddaman 46*b4dd7d09SAndy Fiddaman The data/bash_pre_rc.sh is a startup script used when emulating 47*b4dd7d09SAndy Fiddaman bash if the shell is compiled with SHOPT_BASH and the shell 48*b4dd7d09SAndy Fiddaman is invoked as bash. The bash emulation is not complete. 49*b4dd7d09SAndy Fiddaman 50*b4dd7d09SAndy FiddamanInclude directory: 51*b4dd7d09SAndy Fiddaman 1. argnod.h contains the type definitions for command 52*b4dd7d09SAndy Fiddaman nodes, io nodes, argument nodes, and for positional 53*b4dd7d09SAndy Fiddaman parameters.a It defines the prototypes for 54*b4dd7d09SAndy Fiddaman all the positional parameters functions. 55*b4dd7d09SAndy Fiddaman 2. builtins.h contains prototypes for builtins as well 56*b4dd7d09SAndy Fiddaman as symbolic constants that refer to the name-pairs 57*b4dd7d09SAndy Fiddaman that are associated with some of the built-ins. 58*b4dd7d09SAndy Fiddaman It also contains prototypes for many of the strings. 59*b4dd7d09SAndy Fiddaman 3. defs.h is the catch all for all definitions that 60*b4dd7d09SAndy Fiddaman don't fit elsewhere and it includes several other 61*b4dd7d09SAndy Fiddaman headers. It defines a structure that contains ksh 62*b4dd7d09SAndy Fiddaman global data, sh, and a structure that contains per 63*b4dd7d09SAndy Fiddaman function data, sh.st. 64*b4dd7d09SAndy Fiddaman 4. edit.h contains definitions that are common to both 65*b4dd7d09SAndy Fiddaman vi and emacs edit modes. 66*b4dd7d09SAndy Fiddaman 5. env.h contains an alternative interfaces for creating and 67*b4dd7d09SAndy Fiddaman modifying environment variables. 68*b4dd7d09SAndy Fiddaman 6. fault.h contains prototypes for signal related 69*b4dd7d09SAndy Fiddaman functions and trap and fault handling. 70*b4dd7d09SAndy Fiddaman 7. fcin.h contains macro and function definitions for 71*b4dd7d09SAndy Fiddaman reading from a file or string. 72*b4dd7d09SAndy Fiddaman 8. history.h contains macros and functions definitions 73*b4dd7d09SAndy Fiddaman related to history file processing. 74*b4dd7d09SAndy Fiddaman 9. jobs.h contains the definitions relating to job 75*b4dd7d09SAndy Fiddaman processing and control. 76*b4dd7d09SAndy Fiddaman 10. lexstates.h contains the states associated with 77*b4dd7d09SAndy Fiddaman lexical processing. 78*b4dd7d09SAndy Fiddaman 11. name.h contains the internal definitions related 79*b4dd7d09SAndy Fiddaman to name-value pair processing. 80*b4dd7d09SAndy Fiddaman 12. national.h contains a few I18N definitions, mostly 81*b4dd7d09SAndy Fiddaman obsolete. 82*b4dd7d09SAndy Fiddaman 13. nval.h is the public interface to the name-value 83*b4dd7d09SAndy Fiddaman pair library that is documented with nval.3. 84*b4dd7d09SAndy Fiddaman 14. path.h contains the interface for pathname processing 85*b4dd7d09SAndy Fiddaman and pathname searching. 86*b4dd7d09SAndy Fiddaman 15. shell.h is the public interface for shell functions 87*b4dd7d09SAndy Fiddaman that are documented int shell.3. 88*b4dd7d09SAndy Fiddaman 16. shlex.h contains the lexical token definitions and 89*b4dd7d09SAndy Fiddaman interfaces for lexical analysis. 90*b4dd7d09SAndy Fiddaman 17. shnodes.h contains the definition of the structures 91*b4dd7d09SAndy Fiddaman for each of the parse nodes and flags for the attributes. 92*b4dd7d09SAndy Fiddaman 18. shtable.h contains some interfaces and functions for 93*b4dd7d09SAndy Fiddaman table lookup. 94*b4dd7d09SAndy Fiddaman 19. streval.h contains the interface to the arithmetic 95*b4dd7d09SAndy Fiddaman functions. 96*b4dd7d09SAndy Fiddaman 20. terminal.h is a header file that includes the appropriate 97*b4dd7d09SAndy Fiddaman terminal include. 98*b4dd7d09SAndy Fiddaman 21. test.h contains the definitions for the test and [[...]] 99*b4dd7d09SAndy Fiddaman commands. 100*b4dd7d09SAndy Fiddaman 22. timeout.h contains the define constant for the maximum 101*b4dd7d09SAndy Fiddaman shell timeout. 102*b4dd7d09SAndy Fiddaman 23. ulimit.h includes the appropriate resource header. 103*b4dd7d09SAndy Fiddaman 24. variables.h contains symbolic constants for the built-in 104*b4dd7d09SAndy Fiddaman shell variables. 105*b4dd7d09SAndy Fiddaman 25. version.h contains the version string for this release. 106*b4dd7d09SAndy Fiddaman 107*b4dd7d09SAndy Fiddamansh directory: 108*b4dd7d09SAndy Fiddaman 1. args.c contains functions for parsing shell options 109*b4dd7d09SAndy Fiddaman and for processing positional parameters. 110*b4dd7d09SAndy Fiddaman 2. arith.c contains callback functions for the streval.c 111*b4dd7d09SAndy Fiddaman library and the interface to shell arithmetic. 112*b4dd7d09SAndy Fiddaman 3. array.c contains the code for indexed and associative 113*b4dd7d09SAndy Fiddaman arrays. 114*b4dd7d09SAndy Fiddaman 4. bash.c contains code used when compiling with SHOPT_BASH 115*b4dd7d09SAndy Fiddaman to add bash specific features such as shopt. 116*b4dd7d09SAndy Fiddaman 5. defs.c contains the data definitions for global symbols. 117*b4dd7d09SAndy Fiddaman 6. deparse.c contains code to generate shell script from 118*b4dd7d09SAndy Fiddaman a parse tree. 119*b4dd7d09SAndy Fiddaman 7. env.c contains code to add and delete environment variables 120*b4dd7d09SAndy Fiddaman to an environment list. 121*b4dd7d09SAndy Fiddaman 8. expand.c contains code for file name expansion and 122*b4dd7d09SAndy Fiddaman file name generation. 123*b4dd7d09SAndy Fiddaman 9. fault.c contains code for signal processing, trap 124*b4dd7d09SAndy Fiddaman handling and termination. 125*b4dd7d09SAndy Fiddaman 10. fcin.c contains code for reading and writing a character 126*b4dd7d09SAndy Fiddaman at a time from a file or string. 127*b4dd7d09SAndy Fiddaman 11. init.c contains initialization code and callbacks 128*b4dd7d09SAndy Fiddaman for get and set functions for built-in variables. 129*b4dd7d09SAndy Fiddaman 12. io.o contains code for redirections and managing file 130*b4dd7d09SAndy Fiddaman descriptors and file streams. 131*b4dd7d09SAndy Fiddaman 13. jobs.c contains the code for job management. 132*b4dd7d09SAndy Fiddaman 14. lex.c contains the code for the lexical analyzer. 133*b4dd7d09SAndy Fiddaman 15. macro.c contains code for the $ macro expansions, including 134*b4dd7d09SAndy Fiddaman here-documents. 135*b4dd7d09SAndy Fiddaman 16. main.c contains the calls to initialization, profile 136*b4dd7d09SAndy Fiddaman processing and the main evaluation loop as well as 137*b4dd7d09SAndy Fiddaman mail processing. 138*b4dd7d09SAndy Fiddaman 17. name.c contains the name-value pair routines that are 139*b4dd7d09SAndy Fiddaman built on the hash library in libast. 140*b4dd7d09SAndy Fiddaman 18. nvdisc.c contains code related to name-value pair disciplines. 141*b4dd7d09SAndy Fiddaman 19. nvtree.c contains code for compound variables and for 142*b4dd7d09SAndy Fiddaman walking the namespace. 143*b4dd7d09SAndy Fiddaman 20. nvtype.c contains most of the code related to types that 144*b4dd7d09SAndy Fiddaman are created with typeset -T. 145*b4dd7d09SAndy Fiddaman 21. parse.c contains the code for the shell parser. 146*b4dd7d09SAndy Fiddaman 22. path.c contains the code for pathname lookup and 147*b4dd7d09SAndy Fiddaman some path functions. It also contains the code 148*b4dd7d09SAndy Fiddaman that executes commands and scripts. 149*b4dd7d09SAndy Fiddaman 23. pmain.c is just a calls sh_main() so that all of the 150*b4dd7d09SAndy Fiddaman rest of the shell can be in a shared library. 151*b4dd7d09SAndy Fiddaman 24. shcomp.c contains the main program to the shell 152*b4dd7d09SAndy Fiddaman compiler. This program parses a script and creates 153*b4dd7d09SAndy Fiddaman a file that the shell can read containing the parse tree. 154*b4dd7d09SAndy Fiddaman 25. streval.c is an C arithmetic evaluator. 155*b4dd7d09SAndy Fiddaman 26. string.c contains some string related functions. 156*b4dd7d09SAndy Fiddaman 27. subshell.c contains the code to save and restore 157*b4dd7d09SAndy Fiddaman environments so that subshells can run without creating 158*b4dd7d09SAndy Fiddaman a new process. 159*b4dd7d09SAndy Fiddaman 28. suid_exec.c contains the program from running execute 160*b4dd7d09SAndy Fiddaman only and/or setuid/setgid scripts. 161*b4dd7d09SAndy Fiddaman 29. tdump.c contains the code to dump a parse tree into 162*b4dd7d09SAndy Fiddaman a file. 163*b4dd7d09SAndy Fiddaman 30. timers.c contains code for multiple event timeouts. 164*b4dd7d09SAndy Fiddaman 31. trestore contains the code for restoring the parse 165*b4dd7d09SAndy Fiddaman tree from the file created by tdump. 166*b4dd7d09SAndy Fiddaman 32. userinit.c contains a dummy userinit() function. 167*b4dd7d09SAndy Fiddaman This is now obsolete with the new version of sh_main(). 168*b4dd7d09SAndy Fiddaman 33. waitevent.c contains the sh_waitnotify function so 169*b4dd7d09SAndy Fiddaman that builtins can handle processing events when the 170*b4dd7d09SAndy Fiddaman shell is waiting for input or for process completion. 171*b4dd7d09SAndy Fiddaman 34. xec.c is the main shell execution loop. 172*b4dd7d09SAndy Fiddamanedit directory: 173*b4dd7d09SAndy Fiddaman 1. completion.c contains code for command and file generation and 174*b4dd7d09SAndy Fiddaman completion. 175*b4dd7d09SAndy Fiddaman 2. edit.c contains common editing and terminal code for vi and 176*b4dd7d09SAndy Fiddaman emacs. 177*b4dd7d09SAndy Fiddaman 3. emacs.c contains code for the emacs editor. 178*b4dd7d09SAndy Fiddaman 4. hexpand.c contains code for C-shell style history expansions. 179*b4dd7d09SAndy Fiddaman 5. history.c contains code for creating managing the history file. 180*b4dd7d09SAndy Fiddaman 6. vi.c contains the code for the vi editor. 181