mirror of git://git.code.sf.net/p/zsh/code
37493: readonly + POSIX_BUILTINS == typeset -gr
This commit is contained in:
parent
b4643fce2d
commit
03adf52414
|
@ -1,3 +1,8 @@
|
|||
2016-01-02 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 37493: Doc/Zsh/builtins.yo, Src/builtin.c, Src/hashtable.h,
|
||||
Test/B02typeset.ztst: readonly + POSIX_BUILTINS == typeset -gr
|
||||
|
||||
2016-01-01 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 37483: Src/glob.c: save and possibly restore cshnullglob failure
|
||||
|
|
|
@ -1465,7 +1465,10 @@ cancels both tt(-p) and tt(-u).
|
|||
The tt(-c) or tt(-l) flags cancel any and all of tt(-kpquz).
|
||||
)
|
||||
cindex(parameters, marking readonly)
|
||||
alias(readonly)(typeset -r)
|
||||
item(tt(readonly))(
|
||||
Same as tt(typeset -r). With the tt(POSIX_BUILTINS) option set, same
|
||||
as tt(typeset -gr).
|
||||
)
|
||||
alias(rehash)(hash -r)
|
||||
findex(return)
|
||||
cindex(functions, returning from)
|
||||
|
|
|
@ -62,7 +62,7 @@ static struct builtin builtins[] =
|
|||
BUILTIN("enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmprs", 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("export", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, BIN_EXPORT, "E:%F:%HL:%R:%TUZ:%afhi:%lprtu", "xg"),
|
||||
BUILTIN("export", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "E:%F:%HL:%R:%TUZ:%afhi:%lprtu", "xg"),
|
||||
BUILTIN("false", 0, bin_false, 0, -1, 0, NULL, NULL),
|
||||
/*
|
||||
* We used to behave as if the argument to -e was optional.
|
||||
|
@ -106,7 +106,7 @@ static struct builtin builtins[] =
|
|||
BUILTIN("pwd", 0, bin_pwd, 0, 0, 0, "rLP", NULL),
|
||||
BUILTIN("r", 0, bin_fc, 0, -1, BIN_R, "IlLnr", NULL),
|
||||
BUILTIN("read", 0, bin_read, 0, -1, 0, "cd:ek:%lnpqrst:%zu:AE", NULL),
|
||||
BUILTIN("readonly", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%afghi:%lptux", "r"),
|
||||
BUILTIN("readonly", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, BIN_READONLY, "AE:%F:%HL:%R:%TUZ:%afghi:%lptux", "r"),
|
||||
BUILTIN("rehash", 0, bin_hash, 0, 0, 0, "df", "r"),
|
||||
BUILTIN("return", BINF_PSPECIAL, bin_break, 0, 1, BIN_RETURN, NULL, NULL),
|
||||
BUILTIN("set", BINF_PSPECIAL | BINF_HANDLES_OPTS, bin_set, 0, -1, 0, NULL, NULL),
|
||||
|
@ -2533,6 +2533,10 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
|
|||
if (OPT_ISSET(ops,'f'))
|
||||
return bin_functions(name, argv, ops, func);
|
||||
|
||||
/* POSIX handles "readonly" specially */
|
||||
if (func == BIN_READONLY && isset(POSIXBUILTINS) && !OPT_PLUS(ops, 'g'))
|
||||
ops->ind['g'] = 1;
|
||||
|
||||
/* Translate the options into PM_* flags. *
|
||||
* Unfortunately, this depends on the order *
|
||||
* these flags are defined in zsh.h */
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#define BIN_LOGOUT 19
|
||||
#define BIN_TEST 20
|
||||
#define BIN_BRACKET 21
|
||||
#define BIN_EXPORT 22
|
||||
#define BIN_READONLY 22
|
||||
#define BIN_ECHO 23
|
||||
#define BIN_DISABLE 24
|
||||
#define BIN_ENABLE 25
|
||||
|
|
|
@ -479,12 +479,12 @@
|
|||
setopt POSIXBUILTINS
|
||||
readonly pbro
|
||||
print ${+pbro} >&2
|
||||
(typeset pbro=3)
|
||||
(typeset -g pbro=3)
|
||||
(pbro=4)
|
||||
readonly -p | grep pbro >&2 # shows up as "readonly" although unset
|
||||
typeset -r pbro # idempotent (no error)...
|
||||
readonly -p pbro >&2 # shows up as "readonly" although unset
|
||||
typeset -gr pbro # idempotent (no error)...
|
||||
print ${+pbro} >&2 # ...so still readonly...
|
||||
typeset +r pbro # ...can't turn it off
|
||||
typeset -g +r pbro # ...can't turn it off
|
||||
)
|
||||
1:readonly with POSIX_BUILTINS
|
||||
?0
|
||||
|
|
Loading…
Reference in New Issue