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