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