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