xref: /titanic_51/usr/src/lib/libshell/common/DESIGN (revision 45818ee124adeaaf947698996b4f4c722afc6d1f)
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, a README,
41	and several documentation files.  The RELEASE file contains
42	the list of bug fixes and new features since the original
43	ksh93 release.  The file COMPATIBILITY is a list of all
44	known incompatibilities with ksh88.
45
46	The  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 strucuture 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 interfaces for creating and modifying
67		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
106sh directory:
107	1.	args.c contains functions for parsing shell options
108		and for processing positional parameters.
109	2.	arith.c contains callback functions for the streval.c
110		library and the interface to shell arithmetic.
111	3.	array.c contains the code for indexed and associative
112		arrays.
113	4.      bash.h contains code used when compiling with SHOPT_BASH
114		to add bash specific features such as shopt.
115	5.	defs.c contains the data definitions for global symbols.
116	6.	deparse.c contains code to generate shell script from
117		a parse tree.
118	7.	env.c contains code to add and delete environment variables
119		to an environment list.
120	8.	expand.c contains code for file name expansion and
121		file name generation.
122	9.	fault.c contains code for signal processing, trap
123		handling and termination.
124	10.	fcin.c contains code for reading and writing a character
125		at a time from a file or string.
126	11.	init.c contains initialization code and callbacks
127		for get and set functions for built-in variables.
128	12.	io.o contains code for redirections and managing file
129		descriptors and file streams.
130	13.	jobs.c contains the code for job management.
131	14.	lex.c contains the code for the lexical analyzer.
132	15.	macro.c contains code for the $ macro expansions, including
133		here-documents.
134	16.	main.c contains the calls to initialization, profile
135		processing and the main evaluation loop as well as
136		mail processing.
137	17.	name.c contains the name-value pair routines that are
138		built on the hash library in libast.
139	18.	nvdisc.c contains code related to name-value pair disciplines.
140	19.	nvtree.c contains code for compound variables and for
141		walking the namespace.
142	20.	nvtype.c contains most of the code related to types that
143		are created with typeset -T.
144	21.	parse.c contains the code for the shell parser.
145	22.	path.c contains the code for pathname lookup and
146		some path functions.  It also contains the code
147		that executes commands and scripts.
148	23.	pmain.c is just a calls sh_main() so that all of the
149		rest of the shell can be in a shared library.
150	24.	shcomp.c contains the main program to the shell
151		compiler.  This program parses a script and creates
152		a file that the shell can read containing the parse tree.
153	25.	streval.c is an C arithmetic evaluator.
154	26.	string.c contains some string related functions.
155	27.	subshell.c contains the code to save and restore
156		environments so that subshells can run without creating
157		a new process.
158	28.	suid_exec.c contains the program from running execute
159		only and/or setuid/setgid scripts.
160	29.	tdump.c contains the code to dump a parse tree into
161		a file.
162	30.	timers.c contains code for multiple event timeouts.
163	31.	trestore contians the code for restoring the parse
164		tree from the file created by tdump.
165	32.	userinit.c contains a dummy userinit() function.
166		This is now obsolete with the new version of sh_main().
167	33.	waitevent.c contains the sh_waitnotify function so
168		that builtins can handle processing events when the
169		shell is waiting for input or for process completion.
170	34.	xec.c is the main shell executuion loop.
171