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