1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Remove abandoned SHOPT_ENV experiment

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.
This commit is contained in:
Martijn Dekker 2020-09-02 15:52:41 +01:00
parent bc4dbe0627
commit 8d7f616e75
10 changed files with 57 additions and 488 deletions

View file

@ -59,46 +59,44 @@ Include directory:
function data, sh.st.
4. edit.h contains definitions that are common to both
vi and emacs edit modes.
5. env.h contains an alternative interfaces for creating and
modifying environment variables.
6. fault.h contains prototypes for signal related
5. fault.h contains prototypes for signal related
functions and trap and fault handling.
7. fcin.h contains macro and function definitions for
6. fcin.h contains macro and function definitions for
reading from a file or string.
8. history.h contains macros and functions definitions
7. history.h contains macros and functions definitions
related to history file processing.
9. jobs.h contains the definitions relating to job
8. jobs.h contains the definitions relating to job
processing and control.
10. lexstates.h contains the states associated with
9. lexstates.h contains the states associated with
lexical processing.
11. name.h contains the internal definitions related
10. name.h contains the internal definitions related
to name-value pair processing.
12. national.h contains a few I18N definitions, mostly
11. national.h contains a few I18N definitions, mostly
obsolete.
13. nval.h is the public interface to the name-value
12. nval.h is the public interface to the name-value
pair library that is documented with nval.3.
14. path.h contains the interface for pathname processing
13. path.h contains the interface for pathname processing
and pathname searching.
15. shell.h is the public interface for shell functions
14. shell.h is the public interface for shell functions
that are documented int shell.3.
16. shlex.h contains the lexical token definitions and
15. shlex.h contains the lexical token definitions and
interfaces for lexical analysis.
17. shnodes.h contains the definition of the structures
16. shnodes.h contains the definition of the structures
for each of the parse nodes and flags for the attributes.
18. shtable.h contains some interfaces and functions for
17. shtable.h contains some interfaces and functions for
table lookup.
19. streval.h contains the interface to the arithmetic
18. streval.h contains the interface to the arithmetic
functions.
20. terminal.h is a header file that includes the appropriate
19. terminal.h is a header file that includes the appropriate
terminal include.
21. test.h contains the definitions for the test and [[...]]
20. test.h contains the definitions for the test and [[...]]
commands.
22. timeout.h contains the define constant for the maximum
21. timeout.h contains the define constant for the maximum
shell timeout.
23. ulimit.h includes the appropriate resource header.
24. variables.h contains symbolic constants for the built-in
22. ulimit.h includes the appropriate resource header.
23. variables.h contains symbolic constants for the built-in
shell variables.
25. version.h contains the version string for this release.
24. version.h contains the version string for this release.
sh directory:
1. args.c contains functions for parsing shell options
@ -107,63 +105,61 @@ sh directory:
library and the interface to shell arithmetic.
3. array.c contains the code for indexed and associative
arrays.
4. (removed)
5. defs.c contains the data definitions for global symbols.
6. deparse.c contains code to generate shell script from
4. defs.c contains the data definitions for global symbols.
5. deparse.c contains code to generate shell script from
a parse tree.
7. env.c contains code to add and delete environment variables
to an environment list.
8. expand.c contains code for file name expansion and
6. expand.c contains code for file name expansion and
file name generation.
9. fault.c contains code for signal processing, trap
7. fault.c contains code for signal processing, trap
handling and termination.
10. fcin.c contains code for reading and writing a character
8. fcin.c contains code for reading and writing a character
at a time from a file or string.
11. init.c contains initialization code and callbacks
9. init.c contains initialization code and callbacks
for get and set functions for built-in variables.
12. io.o contains code for redirections and managing file
10. io.o contains code for redirections and managing file
descriptors and file streams.
13. jobs.c contains the code for job management.
14. lex.c contains the code for the lexical analyzer.
15. macro.c contains code for the $ macro expansions, including
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.
16. main.c contains the calls to initialization, profile
14. main.c contains the calls to initialization, profile
processing and the main evaluation loop as well as
mail processing.
17. name.c contains the name-value pair routines that are
15. name.c contains the name-value pair routines that are
built on the hash library in libast.
18. nvdisc.c contains code related to name-value pair disciplines.
19. nvtree.c contains code for compound variables and for
16. nvdisc.c contains code related to name-value pair disciplines.
17. nvtree.c contains code for compound variables and for
walking the namespace.
20. nvtype.c contains most of the code related to types that
18. nvtype.c contains most of the code related to types that
are created with typeset -T.
21. parse.c contains the code for the shell parser.
22. path.c contains the code for pathname lookup and
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.
23. pmain.c is just a calls sh_main() so that all of the
21. pmain.c is just a calls sh_main() so that all of the
rest of the shell can be in a shared library.
24. shcomp.c contains the main program to the shell
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.
25. streval.c is an C arithmetic evaluator.
26. string.c contains some string related functions.
27. subshell.c contains the code to save and restore
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.
28. suid_exec.c contains the program from running execute
26. suid_exec.c contains the program from running execute
only and/or setuid/setgid scripts.
29. tdump.c contains the code to dump a parse tree into
27. tdump.c contains the code to dump a parse tree into
a file.
30. timers.c contains code for multiple event timeouts.
31. trestore contains the code for restoring the parse
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.
32. userinit.c contains a dummy userinit() function.
30. userinit.c contains a dummy userinit() function.
This is now obsolete with the new version of sh_main().
33. waitevent.c contains the sh_waitnotify function so
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.
34. xec.c is the main shell execution loop.
32. xec.c is the main shell execution loop.
edit directory:
1. completion.c contains code for command and file generation and
completion.