mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
This fixes the following: 1. 'set --posix' now works as an equivalent of 'set -o posix'. 2. The posix option turns off braceexpand and turns on letoctal. Any attempt to override that in a single command such as 'set -o posix +o letoctal' was quietly ignored. This now works as long as the overriding option follows the posix option in the command. 3. The --default option to 'set' now stops the 'posix' option, if set or unset in the same 'set' command, from changing other options. This allows the command output by 'set +o' to correctly restore the current options. src/cmd/ksh93/data/builtins.c: - To make 'set --posix' work, we must explicitly list it in sh_set[] as a supported option so that AST optget(3) recognises it and won't override it with its own default --posix option, which converts the optget(3) string to at POSIX getopt(3) string. This means it will appear as a separate entry in --man output, whether we want it to or not. So we might as well use it as an example to document how --optionname == -o optionname, replacing the original documentation that was part of the '-o' description. src/cmd/ksh93/sh/args.c: sh_argopts(): - Add handling for explitit --posix option in data/builtins.c. - Move SH_POSIX syncing SH_BRACEEXPAND and SH_LETOCTAL from sh_applyopts() into the option parsing loop here. This fixes the bug that letoctal was ignored in 'set -o posix +o letoctal'. - Remember if --default was used in a flag, and do not sync options with SH_POSIX if the flag is set. This makes 'set +o' work. src/cmd/ksh93/include/argnod.h, src/cmd/ksh93/data/msg.c, src/cmd/ksh93/sh/args.c: sh_printopts(): - Do not potentially translate the 'on' and 'off' labels in 'set -o' output. No other shell does, and some scripts parse these. src/cmd/ksh93/sh/init.c: sh_init(): - Turn on SH_LETOCTAL early along with SH_POSIX if the shell was invoked as sh; this makes 'sh -o' and 'sh +o' show expected options (not that anyone does this, but correctness is good). src/cmd/ksh93/include/defs.h, src/cmd/ksh93/include/shell.h: - The state flags were in defs.h and most (but not all) of the shell options were in shell.h. Gather all the shell state and option flag definitions into one place in shell.h for clarity. - Remove unused SH_NOPROFILE and SH_XARGS option flags. src/cmd/ksh93/tests/options.sh: - Add tests for these bugs. src/lib/libast/misc/optget.c: styles[]: - Edit default optget(3) option self-documentation for clarity. Several changed files: - Some SHOPT_PFSH fixes to avoid compiling dead code.
This commit is contained in:
parent
cd1cd9c5da
commit
af5f7acf99
15 changed files with 123 additions and 83 deletions
|
@ -60,6 +60,33 @@ typedef void (*Shinit_f)(Shell_t*, int);
|
|||
union Shnode_u;
|
||||
typedef union Shnode_u Shnode_t;
|
||||
|
||||
/*
|
||||
* Shell state flags. Used with sh_isstate(), sh_onstate(), sh_offstate().
|
||||
* See also shell options below. States 0-5 are also used as shell options.
|
||||
*/
|
||||
#define SH_NOFORK 0 /* set when fork not necessary */
|
||||
#define SH_FORKED 7 /* set when process has been forked */
|
||||
#define SH_PROFILE 8 /* set when processing profiles */
|
||||
#define SH_NOALIAS 9 /* do not expand non-exported aliases */
|
||||
#define SH_NOTRACK 10 /* set to disable sftrack() function */
|
||||
#define SH_STOPOK 11 /* set for stopable builtins */
|
||||
#define SH_GRACE 12 /* set for timeout grace period */
|
||||
#define SH_TIMING 13 /* set while timing pipelines */
|
||||
#define SH_DEFPATH 14 /* set when using default path */
|
||||
#define SH_INIT 15 /* set when initializing the shell */
|
||||
#define SH_TTYWAIT 16 /* waiting for keyboard input */
|
||||
#define SH_FCOMPLETE 17 /* set for filename completion */
|
||||
#define SH_PREINIT 18 /* set with SH_INIT before parsing options */
|
||||
#define SH_COMPLETE 19 /* set for command completion */
|
||||
#define SH_INTESTCMD 20 /* set while test/[ command is being run */
|
||||
#define SH_XARG 21 /* set while in xarg (command -x) mode */
|
||||
|
||||
/*
|
||||
* Shell options (set -o). Used with sh_isoption(), sh_onoption(), sh_offoption().
|
||||
* There can be a maximum of 256 (0..0xFF) shell options.
|
||||
* The short option letters are defined in optksh[] and flagval[] in sh/args.c.
|
||||
* The long option names are defined in shtab_options[] in data/options.c.
|
||||
*/
|
||||
#define SH_CFLAG 0
|
||||
#define SH_HISTORY 1 /* used also as a state */
|
||||
#define SH_ERREXIT 2 /* used also as a state */
|
||||
|
@ -72,7 +99,9 @@ typedef union Shnode_u Shnode_t;
|
|||
#define SH_NOUNSET 9
|
||||
#define SH_NOGLOB 10
|
||||
#define SH_ALLEXPORT 11
|
||||
#if SHOPT_PFSH
|
||||
#define SH_PFSH 12
|
||||
#endif
|
||||
#define SH_IGNOREEOF 13
|
||||
#define SH_NOCLOBBER 14
|
||||
#define SH_MARKDIRS 15
|
||||
|
@ -95,10 +124,17 @@ typedef union Shnode_u Shnode_t;
|
|||
#define SH_DICTIONARY 30
|
||||
#define SH_PIPEFAIL 32
|
||||
#define SH_GLOBSTARS 33
|
||||
#define SH_XARGS 34
|
||||
#define SH_RC 35
|
||||
#define SH_SHOWME 36
|
||||
#define SH_LETOCTAL 37
|
||||
#if SHOPT_BRACEPAT
|
||||
#define SH_BRACEEXPAND 42
|
||||
#endif
|
||||
#define SH_POSIX 46
|
||||
#define SH_MULTILINE 47
|
||||
#define SH_LOGIN_SHELL 67
|
||||
#define SH_NOUSRPROFILE 79 /* internal use only */
|
||||
#define SH_COMMANDLINE 0x100 /* bit flag for invocation-only options ('set -o' cannot change them) */
|
||||
|
||||
/*
|
||||
* passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue