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