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