mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-24 06:54:13 +00:00
SHOPT_ENV is an undocumented compile-time option implementing an experimental method for handling environment variables, which is implemented in env.h and env.c. There is no mention in the docs or Makefile, and no mention in the mailing list archives. It adds no new functionality, but at first glance it's a clean-looking interface. However, unfortunately, it's broken. Compiling with -DSHOPT_ENV added to CCFLAGS causes bin/shtests to show these regressions: functions.sh[341]: export not restored name=value function call -- expected 'base', got '' functions.sh[1274]: Environment variable is not passed to a function substring.sh[236]: export not restored name=value function call variables.sh[782]: SHLVL should be 3 not 2 In addition, 'export' stops working on unset variables. In the 93v- beta this code is still present, unchanged, though 93v- made lots of incompatible changes. By the time ksh2020 noticed it, it was no longer compiling, so it probably wasn't compiling in the 93v- beta either. Discussion: https://github.com/att/ast/issues/504 So the experiment was already abandoned by D. Korn and his team. Meanwhile it was leaving sh/name.c with two versions of several enviornment-related functions, and it's not clear which one is actually compiled without doing detective work tracing header files (most of the code was made conditional on _ENV_H, which is defined in env.h, which is included by defs.h if SHOPT_ENV is defined). This actively hinders understanding of the codebase. And any changes to these functions would need to be implemented twice. src/cmd/ksh93/include/env.h, src/cmd/ksh93/sh/env.c: - Removed. src/cmd/ksh93/DESIGN, src/cmd/ksh93/Makefile, src/cmd/ksh93/Mamfile: - Update accordingly. All other changed files: - Remove deactivated code behind SHOPT_ENV and _ENV_H.
171 lines
7.3 KiB
Text
171 lines
7.3 KiB
Text
Here is an overview of the source code organization for ksh93.
|
|
|
|
Directory layout:
|
|
|
|
The directory include contains header files for ksh93.
|
|
The files nval.h and shell.h are intended to be public
|
|
headers and can be used to add runtime builtin command.
|
|
The remainder are private.
|
|
|
|
The directory data contains readonly data files for ksh93.
|
|
The man pages for built-ins are in builtins.c rather
|
|
than included as statics with the implementations in the
|
|
bltins directory because some systems don't make static const
|
|
data readonly and we want these to be shared by all running
|
|
shells.
|
|
|
|
The directory edit contains the code for command line
|
|
editing and history.
|
|
|
|
The fun directory contains some shell function such as
|
|
pushd, popd, and dirs.
|
|
|
|
The directory features contains files that are used to generate
|
|
header files in the FEATURE directory. Most of these files
|
|
are in a format that is processed by iffe.
|
|
|
|
The directory bltins contains code for most of the built-in
|
|
commands. Additional built-in commands are part of libcmd.
|
|
|
|
The directory sh contains most of the code for ksh93.
|
|
|
|
The directory tests contains a number of regression tests.
|
|
In most cases, when a bug gets fixed, a test is added to
|
|
one of these files. The regression tests can be run by
|
|
going to this directory and running
|
|
SHELL=shell_path shell_path shtests
|
|
where shell_path is an absolute pathname for the shell to
|
|
be tested.
|
|
|
|
The top level directory contains the nmake Makefile, the
|
|
RELEASE file, the ksh93 man file (sh.1) and nval.3 and shell.3
|
|
documentation files. The RELEASE file contains the list of bug
|
|
fixes and new features since the original ksh93 release. The file
|
|
COMPATIBILITY is a list of all known incompatibilities with ksh88.
|
|
|
|
Include directory:
|
|
1. argnod.h contains the type definitions for command
|
|
nodes, io nodes, argument nodes, and for positional
|
|
parameters.a It defines the prototypes for
|
|
all the positional parameters functions.
|
|
2. builtins.h contains prototypes for builtins as well
|
|
as symbolic constants that refer to the name-pairs
|
|
that are associated with some of the built-ins.
|
|
It also contains prototypes for many of the strings.
|
|
3. defs.h is the catch all for all definitions that
|
|
don't fit elsewhere and it includes several other
|
|
headers. It defines a structure that contains ksh
|
|
global data, sh, and a structure that contains per
|
|
function data, sh.st.
|
|
4. edit.h contains definitions that are common to both
|
|
vi and emacs edit modes.
|
|
5. fault.h contains prototypes for signal related
|
|
functions and trap and fault handling.
|
|
6. fcin.h contains macro and function definitions for
|
|
reading from a file or string.
|
|
7. history.h contains macros and functions definitions
|
|
related to history file processing.
|
|
8. jobs.h contains the definitions relating to job
|
|
processing and control.
|
|
9. lexstates.h contains the states associated with
|
|
lexical processing.
|
|
10. name.h contains the internal definitions related
|
|
to name-value pair processing.
|
|
11. national.h contains a few I18N definitions, mostly
|
|
obsolete.
|
|
12. nval.h is the public interface to the name-value
|
|
pair library that is documented with nval.3.
|
|
13. path.h contains the interface for pathname processing
|
|
and pathname searching.
|
|
14. shell.h is the public interface for shell functions
|
|
that are documented int shell.3.
|
|
15. shlex.h contains the lexical token definitions and
|
|
interfaces for lexical analysis.
|
|
16. shnodes.h contains the definition of the structures
|
|
for each of the parse nodes and flags for the attributes.
|
|
17. shtable.h contains some interfaces and functions for
|
|
table lookup.
|
|
18. streval.h contains the interface to the arithmetic
|
|
functions.
|
|
19. terminal.h is a header file that includes the appropriate
|
|
terminal include.
|
|
20. test.h contains the definitions for the test and [[...]]
|
|
commands.
|
|
21. timeout.h contains the define constant for the maximum
|
|
shell timeout.
|
|
22. ulimit.h includes the appropriate resource header.
|
|
23. variables.h contains symbolic constants for the built-in
|
|
shell variables.
|
|
24. version.h contains the version string for this release.
|
|
|
|
sh directory:
|
|
1. args.c contains functions for parsing shell options
|
|
and for processing positional parameters.
|
|
2. arith.c contains callback functions for the streval.c
|
|
library and the interface to shell arithmetic.
|
|
3. array.c contains the code for indexed and associative
|
|
arrays.
|
|
4. defs.c contains the data definitions for global symbols.
|
|
5. deparse.c contains code to generate shell script from
|
|
a parse tree.
|
|
6. expand.c contains code for file name expansion and
|
|
file name generation.
|
|
7. fault.c contains code for signal processing, trap
|
|
handling and termination.
|
|
8. fcin.c contains code for reading and writing a character
|
|
at a time from a file or string.
|
|
9. init.c contains initialization code and callbacks
|
|
for get and set functions for built-in variables.
|
|
10. io.o contains code for redirections and managing file
|
|
descriptors and file streams.
|
|
11. jobs.c contains the code for job management.
|
|
12. lex.c contains the code for the lexical analyzer.
|
|
13. macro.c contains code for the $ macro expansions, including
|
|
here-documents.
|
|
14. main.c contains the calls to initialization, profile
|
|
processing and the main evaluation loop as well as
|
|
mail processing.
|
|
15. name.c contains the name-value pair routines that are
|
|
built on the hash library in libast.
|
|
16. nvdisc.c contains code related to name-value pair disciplines.
|
|
17. nvtree.c contains code for compound variables and for
|
|
walking the namespace.
|
|
18. nvtype.c contains most of the code related to types that
|
|
are created with typeset -T.
|
|
19. parse.c contains the code for the shell parser.
|
|
20. path.c contains the code for pathname lookup and
|
|
some path functions. It also contains the code
|
|
that executes commands and scripts.
|
|
21. pmain.c is just a calls sh_main() so that all of the
|
|
rest of the shell can be in a shared library.
|
|
22. shcomp.c contains the main program to the shell
|
|
compiler. This program parses a script and creates
|
|
a file that the shell can read containing the parse tree.
|
|
23. streval.c is an C arithmetic evaluator.
|
|
24. string.c contains some string related functions.
|
|
25. subshell.c contains the code to save and restore
|
|
environments so that subshells can run without creating
|
|
a new process.
|
|
26. suid_exec.c contains the program from running execute
|
|
only and/or setuid/setgid scripts.
|
|
27. tdump.c contains the code to dump a parse tree into
|
|
a file.
|
|
28. timers.c contains code for multiple event timeouts.
|
|
29. trestore contains the code for restoring the parse
|
|
tree from the file created by tdump.
|
|
30. userinit.c contains a dummy userinit() function.
|
|
This is now obsolete with the new version of sh_main().
|
|
31. waitevent.c contains the sh_waitnotify function so
|
|
that builtins can handle processing events when the
|
|
shell is waiting for input or for process completion.
|
|
32. xec.c is the main shell execution loop.
|
|
|
|
edit directory:
|
|
1. completion.c contains code for command and file generation and
|
|
completion.
|
|
2. edit.c contains common editing and terminal code for vi and
|
|
emacs.
|
|
3. emacs.c contains code for the emacs editor.
|
|
4. hexpand.c contains code for C-shell style history expansions.
|
|
5. history.c contains code for creating managing the history file.
|
|
6. vi.c contains the code for the vi editor.
|