1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-27 16:50:58 +01:00

11838: typeset -H

This commit is contained in:
Peter Stephenson 2000-06-09 15:37:05 +00:00
parent 716f5d4e39
commit 6b87e6fda3
7 changed files with 38 additions and 24 deletions

View file

@ -1128,6 +1128,14 @@ having the tt(-h) attribute. Global special parameters loaded from shell
modules (currently those in tt(mapfile) and tt(parameter)) are modules (currently those in tt(mapfile) and tt(parameter)) are
automatically given the tt(-h) attribute to avoid name clashes. automatically given the tt(-h) attribute to avoid name clashes.
) )
item(tt(-H))(
Hide value: specifies that tt(typeset) will not display the value of the
parameter when listing parameters; the display for such parameters is
always as if the `tt(PLUS())' flag had been given. Use of the parameter is
in other respects normal. This is on by default for the parameters in the
tt(zsh/parameter) and tt(zsh/mapfile) modules. Note, however, that unlike
the tt(-h) flag this is also useful for non-special parameters.
)
item(tt(-i))( item(tt(-i))(
Use an internal integer representation. If var(n) is nonzero it Use an internal integer representation. If var(n) is nonzero it
defines the output arithmetic base, otherwise it is determined by the defines the output arithmetic base, otherwise it is determined by the

View file

@ -86,8 +86,8 @@ createmapfilehash()
unsetparam(mapfile_nam); unsetparam(mapfile_nam);
mapfile_pm = NULL; mapfile_pm = NULL;
if (!(pm = createparam(mapfile_nam, if (!(pm = createparam(mapfile_nam, PM_SPECIAL|PM_HIDE|PM_HIDEVAL|
PM_SPECIAL|PM_HIDE|PM_REMOVABLE|PM_HASHED))) PM_REMOVABLE|PM_HASHED)))
return NULL; return NULL;
pm->level = pm->old ? locallevel : 0; pm->level = pm->old ? locallevel : 0;

View file

@ -51,7 +51,8 @@ createspecialhash(char *name, GetNodeFunc get, ScanTabFunc scan)
Param pm; Param pm;
HashTable ht; HashTable ht;
if (!(pm = createparam(name, PM_SPECIAL|PM_HIDE|PM_REMOVABLE|PM_HASHED))) if (!(pm = createparam(name, PM_SPECIAL|PM_HIDE|PM_HIDEVAL|
PM_REMOVABLE|PM_HASHED)))
return NULL; return NULL;
pm->level = pm->old ? locallevel : 0; pm->level = pm->old ? locallevel : 0;
@ -122,6 +123,8 @@ paramtypestr(Param pm)
val = dyncat(val, "-unique"); val = dyncat(val, "-unique");
if (f & PM_HIDE) if (f & PM_HIDE)
val = dyncat(val, "-hide"); val = dyncat(val, "-hide");
if (f & PM_HIDEVAL)
val = dyncat(val, "-hideval");
if (f & PM_SPECIAL) if (f & PM_SPECIAL)
val = dyncat(val, "-special"); val = dyncat(val, "-special");
} else } else
@ -1942,8 +1945,8 @@ boot_(Module m)
if (def->hsetfn) if (def->hsetfn)
def->pm->sets.hfn = def->hsetfn; def->pm->sets.hfn = def->hsetfn;
} else { } else {
if (!(def->pm = createparam(def->name, def->flags | PM_HIDE | if (!(def->pm = createparam(def->name, def->flags | PM_HIDE|
PM_REMOVABLE))) PM_HIDEVAL | PM_REMOVABLE)))
return 1; return 1;
def->pm->sets.afn = def->setfn; def->pm->sets.afn = def->setfn;
def->pm->gets.afn = def->getfn; def->pm->gets.afn = def->getfn;

View file

@ -50,7 +50,7 @@ static struct builtin builtins[] =
BUILTIN("cd", 0, bin_cd, 0, 2, BIN_CD, NULL, NULL), BUILTIN("cd", 0, bin_cd, 0, 2, BIN_CD, NULL, NULL),
BUILTIN("chdir", 0, bin_cd, 0, 2, BIN_CD, NULL, NULL), BUILTIN("chdir", 0, bin_cd, 0, 2, BIN_CD, NULL, NULL),
BUILTIN("continue", BINF_PSPECIAL, bin_break, 0, 1, BIN_CONTINUE, NULL, NULL), BUILTIN("continue", BINF_PSPECIAL, bin_break, 0, 1, BIN_CONTINUE, NULL, NULL),
BUILTIN("declare", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFLRTUZafghilrtux", NULL), BUILTIN("declare", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFHLRTUZafghilrtux", NULL),
BUILTIN("dirs", 0, bin_dirs, 0, -1, 0, "v", NULL), BUILTIN("dirs", 0, bin_dirs, 0, -1, 0, "v", NULL),
BUILTIN("disable", 0, bin_enable, 0, -1, BIN_DISABLE, "afmr", NULL), BUILTIN("disable", 0, bin_enable, 0, -1, BIN_DISABLE, "afmr", NULL),
BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL), BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL),
@ -60,11 +60,11 @@ static struct builtin builtins[] =
BUILTIN("enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmr", NULL), BUILTIN("enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmr", NULL),
BUILTIN("eval", BINF_PSPECIAL, bin_eval, 0, -1, BIN_EVAL, NULL, NULL), BUILTIN("eval", BINF_PSPECIAL, bin_eval, 0, -1, BIN_EVAL, NULL, NULL),
BUILTIN("exit", BINF_PSPECIAL, bin_break, 0, 1, BIN_EXIT, NULL, NULL), BUILTIN("exit", BINF_PSPECIAL, bin_break, 0, 1, BIN_EXIT, NULL, NULL),
BUILTIN("export", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, BIN_EXPORT, "EFLRTUZafhilrtu", "xg"), BUILTIN("export", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, BIN_EXPORT, "EFHLRTUZafhilrtu", "xg"),
BUILTIN("false", 0, bin_false, 0, -1, 0, NULL, NULL), BUILTIN("false", 0, bin_false, 0, -1, 0, NULL, NULL),
BUILTIN("fc", BINF_FCOPTS, bin_fc, 0, -1, BIN_FC, "nlreIRWAdDfEim", NULL), BUILTIN("fc", BINF_FCOPTS, bin_fc, 0, -1, BIN_FC, "nlreIRWAdDfEim", NULL),
BUILTIN("fg", 0, bin_fg, 0, -1, BIN_FG, NULL, NULL), BUILTIN("fg", 0, bin_fg, 0, -1, BIN_FG, NULL, NULL),
BUILTIN("float", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "EFghlrtux", "E"), BUILTIN("float", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "EFHghlrtux", "E"),
BUILTIN("functions", BINF_TYPEOPTS, bin_functions, 0, -1, 0, "mtuU", NULL), BUILTIN("functions", BINF_TYPEOPTS, bin_functions, 0, -1, 0, "mtuU", NULL),
BUILTIN("getln", 0, bin_read, 0, -1, 0, "ecnAlE", "zr"), BUILTIN("getln", 0, bin_read, 0, -1, 0, "ecnAlE", "zr"),
BUILTIN("getopts", 0, bin_getopts, 2, -1, 0, NULL, NULL), BUILTIN("getopts", 0, bin_getopts, 2, -1, 0, NULL, NULL),
@ -75,11 +75,11 @@ static struct builtin builtins[] =
#endif #endif
BUILTIN("history", 0, bin_fc, 0, -1, BIN_FC, "nrdDfEim", "l"), BUILTIN("history", 0, bin_fc, 0, -1, BIN_FC, "nrdDfEim", "l"),
BUILTIN("integer", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "ghilrtux", "i"), BUILTIN("integer", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "Hghilrtux", "i"),
BUILTIN("jobs", 0, bin_fg, 0, -1, BIN_JOBS, "dlpZrs", NULL), BUILTIN("jobs", 0, bin_fg, 0, -1, BIN_JOBS, "dlpZrs", NULL),
BUILTIN("kill", 0, bin_kill, 0, -1, 0, NULL, NULL), BUILTIN("kill", 0, bin_kill, 0, -1, 0, NULL, NULL),
BUILTIN("let", 0, bin_let, 1, -1, 0, NULL, NULL), BUILTIN("let", 0, bin_let, 1, -1, 0, NULL, NULL),
BUILTIN("local", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFLRTUZahilrtux", NULL), BUILTIN("local", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFHLRTUZahilrtux", NULL),
BUILTIN("log", 0, bin_log, 0, 0, 0, NULL, NULL), BUILTIN("log", 0, bin_log, 0, 0, 0, NULL, NULL),
BUILTIN("logout", 0, bin_break, 0, 1, BIN_LOGOUT, NULL, NULL), BUILTIN("logout", 0, bin_break, 0, 1, BIN_LOGOUT, NULL, NULL),
@ -98,7 +98,7 @@ static struct builtin builtins[] =
BUILTIN("pwd", 0, bin_pwd, 0, 0, 0, "rLP", NULL), BUILTIN("pwd", 0, bin_pwd, 0, 0, 0, "rLP", NULL),
BUILTIN("r", BINF_R, bin_fc, 0, -1, BIN_FC, "nrl", NULL), BUILTIN("r", BINF_R, bin_fc, 0, -1, BIN_FC, "nrl", NULL),
BUILTIN("read", 0, bin_read, 0, -1, 0, "rzu0123456789pkqecnAlE", NULL), BUILTIN("read", 0, bin_read, 0, -1, 0, "rzu0123456789pkqecnAlE", NULL),
BUILTIN("readonly", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFLRTUZafghiltux", "r"), BUILTIN("readonly", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFHLRTUZafghiltux", "r"),
BUILTIN("rehash", 0, bin_hash, 0, 0, 0, "df", "r"), BUILTIN("rehash", 0, bin_hash, 0, 0, 0, "df", "r"),
BUILTIN("return", BINF_PSPECIAL, bin_break, 0, 1, BIN_RETURN, NULL, NULL), BUILTIN("return", BINF_PSPECIAL, bin_break, 0, 1, BIN_RETURN, NULL, NULL),
BUILTIN("set", BINF_PSPECIAL, bin_set, 0, -1, 0, NULL, NULL), BUILTIN("set", BINF_PSPECIAL, bin_set, 0, -1, 0, NULL, NULL),
@ -112,7 +112,7 @@ static struct builtin builtins[] =
BUILTIN("trap", BINF_PSPECIAL, bin_trap, 0, -1, 0, NULL, NULL), BUILTIN("trap", BINF_PSPECIAL, bin_trap, 0, -1, 0, NULL, NULL),
BUILTIN("true", 0, bin_true, 0, -1, 0, NULL, NULL), BUILTIN("true", 0, bin_true, 0, -1, 0, NULL, NULL),
BUILTIN("type", 0, bin_whence, 0, -1, 0, "ampfsw", "v"), BUILTIN("type", 0, bin_whence, 0, -1, 0, "ampfsw", "v"),
BUILTIN("typeset", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFLRTUZafghilrtuxm", NULL), BUILTIN("typeset", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "AEFHLRTUZafghilrtuxm", NULL),
BUILTIN("umask", 0, bin_umask, 0, 1, 0, "S", NULL), BUILTIN("umask", 0, bin_umask, 0, 1, 0, "S", NULL),
BUILTIN("unalias", 0, bin_unhash, 1, -1, 0, "m", "a"), BUILTIN("unalias", 0, bin_unhash, 1, -1, 0, "m", "a"),
BUILTIN("unfunction", 0, bin_unhash, 1, -1, 0, "m", "f"), BUILTIN("unfunction", 0, bin_unhash, 1, -1, 0, "m", "f"),

View file

@ -3181,7 +3181,7 @@ printparamnode(HashNode hn, int printflags)
printf("exported "); printf("exported ");
} }
if (printflags & PRINT_NAMEONLY) { if ((printflags & PRINT_NAMEONLY) || (p->flags & PM_HIDEVAL)) {
zputs(p->nam, stdout); zputs(p->nam, stdout);
putchar('\n'); putchar('\n');
return; return;

View file

@ -1109,6 +1109,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
val = dyncat(val, "-unique"); val = dyncat(val, "-unique");
if (f & PM_HIDE) if (f & PM_HIDE)
val = dyncat(val, "-hide"); val = dyncat(val, "-hide");
if (f & PM_HIDE)
val = dyncat(val, "-hideval");
if (f & PM_SPECIAL) if (f & PM_SPECIAL)
val = dyncat(val, "-special"); val = dyncat(val, "-special");
vunset = 0; vunset = 0;

View file

@ -1117,21 +1117,22 @@ struct param {
#define PM_UNALIASED (1<<13) /* do not expand aliases when autoloading */ #define PM_UNALIASED (1<<13) /* do not expand aliases when autoloading */
#define PM_HIDE (1<<14) /* Special behaviour hidden by local */ #define PM_HIDE (1<<14) /* Special behaviour hidden by local */
#define PM_TIED (1<<15) /* array tied to colon-path or v.v. */ #define PM_HIDEVAL (1<<15) /* Value not shown in `typeset' commands */
#define PM_TIED (1<<16) /* array tied to colon-path or v.v. */
/* Remaining flags do not correspond directly to command line arguments */ /* Remaining flags do not correspond directly to command line arguments */
#define PM_LOCAL (1<<16) /* this parameter will be made local */ #define PM_LOCAL (1<<17) /* this parameter will be made local */
#define PM_SPECIAL (1<<17) /* special builtin parameter */ #define PM_SPECIAL (1<<18) /* special builtin parameter */
#define PM_DONTIMPORT (1<<18) /* do not import this variable */ #define PM_DONTIMPORT (1<<19) /* do not import this variable */
#define PM_RESTRICTED (1<<19) /* cannot be changed in restricted mode */ #define PM_RESTRICTED (1<<20) /* cannot be changed in restricted mode */
#define PM_UNSET (1<<20) /* has null value */ #define PM_UNSET (1<<21) /* has null value */
#define PM_REMOVABLE (1<<21) /* special can be removed from paramtab */ #define PM_REMOVABLE (1<<22) /* special can be removed from paramtab */
#define PM_AUTOLOAD (1<<22) /* autoloaded from module */ #define PM_AUTOLOAD (1<<23) /* autoloaded from module */
#define PM_NORESTORE (1<<23) /* do not restore value of local special */ #define PM_NORESTORE (1<<24) /* do not restore value of local special */
#define PM_HASHELEM (1<<24) /* is a hash-element */ #define PM_HASHELEM (1<<25) /* is a hash-element */
/* The option string corresponds to the first of the variables above */ /* The option string corresponds to the first of the variables above */
#define TYPESET_OPTSTR "aiEFALRZlurtxUhT" #define TYPESET_OPTSTR "aiEFALRZlurtxUhHT"
/* These typeset options take an optional numeric argument */ /* These typeset options take an optional numeric argument */
#define TYPESET_OPTNUM "LRZiEF" #define TYPESET_OPTNUM "LRZiEF"