14887SchinHere is an overview of the source code organization for ksh93. 24887Schin 34887SchinDirectory layout: 44887Schin 54887Schin The directory include contains header files for ksh93. 64887Schin The files nval.h and shell.h are intended to be public 74887Schin headers and can be used to add runtime builtin command. 84887Schin The remainder are private. 94887Schin 104887Schin The directory data contains readonly data files for ksh93. 11*8462SApril.Chin@Sun.COM The man pages for built-ins are in builtins.c rather 12*8462SApril.Chin@Sun.COM than included as statics with the implementations in the 13*8462SApril.Chin@Sun.COM bltins directory because some systems don't make static const 14*8462SApril.Chin@Sun.COM data readonly and we want these to be shared by all running 15*8462SApril.Chin@Sun.COM shells. 164887Schin 174887Schin The directory edit contains the code for command line 184887Schin editing and history. 194887Schin 204887Schin The fun directory contains some shell function such as 214887Schin pushd, popd, and dirs. 224887Schin 234887Schin The directory features contains files that are used to generate 244887Schin header files in the FEATURE directory. Most of these files 254887Schin are in a format that is processed by iffe. 264887Schin 274887Schin The directory bltins contains code for most of the built-in 284887Schin commands. Additional built-in commands are part of libcmd. 294887Schin 304887Schin The directory sh contains most of the code for ksh93. 314887Schin 324887Schin The directory tests contains a number of regression tests. 334887Schin In most cases, when a bug gets fixed, a test is added to 344887Schin one of these files. The regression tests can be run by 354887Schin going to this directory and running 364887Schin SHELL=shell_path shell_path shtests 374887Schin where shell_path is an absolute pathname for the shell to 384887Schin be tested. 394887Schin 404887Schin The top level directory contains the nmake Makefile, a README, 414887Schin and several documentation files. The RELEASE file contains 424887Schin the list of bug fixes and new features since the original 434887Schin ksh93 release. The file COMPATIBILITY is a list of all 444887Schin known incompatibilities with ksh88. 454887Schin 464887Schin The bash_pre_rc.sh is a startup script used when emulating 474887Schin bash if the shell is compiled with SHOPT_BASH and the shell 484887Schin is invoked as bash. The bash emulation is not complete. 494887Schin 504887SchinInclude directory: 514887Schin 1. argnod.h contains the type definitions for command 524887Schin nodes, io nodes, argument nodes, and for positional 534887Schin parameters.a It defines the prototypes for 544887Schin all the positional parameters functions. 554887Schin 2. builtins.h contains prototypes for builtins as well 564887Schin as symbolic constants that refer to the name-pairs 574887Schin that are associated with some of the built-ins. 584887Schin It also contains prototypes for many of the strings. 594887Schin 3. defs.h is the catch all for all definitions that 604887Schin don't fit elsewhere and it includes several other 614887Schin headers. It defines a strucuture that contains ksh 624887Schin global data, sh, and a structure that contains per 634887Schin function data, sh.st. 644887Schin 4. edit.h contains definitions that are common to both 654887Schin vi and emacs edit modes. 664887Schin 5. env.h contains interfaces for creating and modifying 67*8462SApril.Chin@Sun.COM environment variables. 684887Schin 6. fault.h contains prototypes for signal related 694887Schin functions and trap and fault handling. 704887Schin 7. fcin.h contains macro and function definitions for 714887Schin reading from a file or string. 724887Schin 8. history.h contains macros and functions definitions 734887Schin related to history file processing. 744887Schin 9. jobs.h contains the definitions relating to job 754887Schin processing and control. 764887Schin 10. lexstates.h contains the states associated with 774887Schin lexical processing. 784887Schin 11. name.h contains the internal definitions related 794887Schin to name-value pair processing. 804887Schin 12. national.h contains a few I18N definitions, mostly 814887Schin obsolete. 824887Schin 13. nval.h is the public interface to the name-value 834887Schin pair library that is documented with nval.3. 844887Schin 14. path.h contains the interface for pathname processing 854887Schin and pathname searching. 864887Schin 15. shell.h is the public interface for shell functions 874887Schin that are documented int shell.3. 884887Schin 16. shlex.h contains the lexical token definitions and 894887Schin interfaces for lexical analysis. 904887Schin 17. shnodes.h contains the definition of the structures 914887Schin for each of the parse nodes and flags for the attributes. 924887Schin 18. shtable.h contains some interfaces and functions for 934887Schin table lookup. 944887Schin 19. streval.h contains the interface to the arithmetic 954887Schin functions. 964887Schin 20. terminal.h is a header file that includes the appropriate 974887Schin terminal include. 984887Schin 21. test.h contains the definitions for the test and [[...]] 994887Schin commands. 1004887Schin 22. timeout.h contains the define constant for the maximum 1014887Schin shell timeout. 1024887Schin 23. ulimit.h includes the appropriate resource header. 1034887Schin 24. variables.h contains symbolic constants for the built-in 1044887Schin shell variables. 1054887Schin 1064887Schinsh directory: 1074887Schin 1. args.c contains functions for parsing shell options 1084887Schin and for processing positional parameters. 1094887Schin 2. arith.c contains callback functions for the streval.c 1104887Schin library and the interface to shell arithmetic. 1114887Schin 3. array.c contains the code for indexed and associative 1124887Schin arrays. 1134887Schin 4. bash.h contains code used when compiling with SHOPT_BASH 1144887Schin to add bash specific features such as shopt. 1154887Schin 5. defs.c contains the data definitions for global symbols. 1164887Schin 6. deparse.c contains code to generate shell script from 1174887Schin a parse tree. 1184887Schin 7. env.c contains code to add and delete environment variables 1194887Schin to an environment list. 1204887Schin 8. expand.c contains code for file name expansion and 1214887Schin file name generation. 1224887Schin 9. fault.c contains code for signal processing, trap 1234887Schin handling and termination. 1244887Schin 10. fcin.c contains code for reading and writing a character 1254887Schin at a time from a file or string. 1264887Schin 11. init.c contains initialization code and callbacks 1274887Schin for get and set functions for built-in variables. 1284887Schin 12. io.o contains code for redirections and managing file 1294887Schin descriptors and file streams. 1304887Schin 13. jobs.c contains the code for job management. 1314887Schin 14. lex.c contains the code for the lexical analyzer. 1324887Schin 15. macro.c contains code for the $ macro expansions, including 1334887Schin here-documents. 1344887Schin 16. main.c contains the calls to initialization, profile 1354887Schin processing and the main evaluation loop as well as 1364887Schin mail processing. 1374887Schin 17. name.c contains the name-value pair routines that are 1384887Schin built on the hash library in libast. 1394887Schin 18. nvdisc.c contains code related to name-value pair disciplines. 1404887Schin 19. nvtree.c contains code for compound variables and for 1414887Schin walking the namespace. 142*8462SApril.Chin@Sun.COM 20. nvtype.c contains most of the code related to types that 143*8462SApril.Chin@Sun.COM are created with typeset -T. 144*8462SApril.Chin@Sun.COM 21. parse.c contains the code for the shell parser. 145*8462SApril.Chin@Sun.COM 22. path.c contains the code for pathname lookup and 1464887Schin some path functions. It also contains the code 1474887Schin that executes commands and scripts. 148*8462SApril.Chin@Sun.COM 23. pmain.c is just a calls sh_main() so that all of the 1494887Schin rest of the shell can be in a shared library. 150*8462SApril.Chin@Sun.COM 24. shcomp.c contains the main program to the shell 1514887Schin compiler. This program parses a script and creates 1524887Schin a file that the shell can read containing the parse tree. 153*8462SApril.Chin@Sun.COM 25. streval.c is an C arithmetic evaluator. 154*8462SApril.Chin@Sun.COM 26. string.c contains some string related functions. 155*8462SApril.Chin@Sun.COM 27. subshell.c contains the code to save and restore 1564887Schin environments so that subshells can run without creating 1574887Schin a new process. 158*8462SApril.Chin@Sun.COM 28. suid_exec.c contains the program from running execute 1594887Schin only and/or setuid/setgid scripts. 160*8462SApril.Chin@Sun.COM 29. tdump.c contains the code to dump a parse tree into 1614887Schin a file. 162*8462SApril.Chin@Sun.COM 30. timers.c contains code for multiple event timeouts. 163*8462SApril.Chin@Sun.COM 31. trestore contians the code for restoring the parse 1644887Schin tree from the file created by tdump. 165*8462SApril.Chin@Sun.COM 32. userinit.c contains a dummy userinit() function. 1664887Schin This is now obsolete with the new version of sh_main(). 167*8462SApril.Chin@Sun.COM 33. waitevent.c contains the sh_waitnotify function so 1684887Schin that builtins can handle processing events when the 1694887Schin shell is waiting for input or for process completion. 170*8462SApril.Chin@Sun.COM 34. xec.c is the main shell executuion loop. 171