diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2012-08-16 14:00:11 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2012-08-16 14:00:11 +0000 |
commit | 268e56a1446af3ca6df84789180b87ac4f57d1d3 (patch) | |
tree | 57ea3541a19ae7007b910d391bc4a1af6d9d53af | |
parent | 1849668c81919808b206550fd176b203e67026db (diff) | |
download | zsh-268e56a1446af3ca6df84789180b87ac4f57d1d3.tar.gz zsh-268e56a1446af3ca6df84789180b87ac4f57d1d3.tar.xz zsh-268e56a1446af3ca6df84789180b87ac4f57d1d3.zip |
30169: repeat "typeset -T" with same two first arguments is not an error
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Doc/Zsh/builtins.yo | 4 | ||||
-rw-r--r-- | Src/builtin.c | 15 | ||||
-rw-r--r-- | Test/B02typeset.ztst | 9 |
4 files changed, 31 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog index 424c6c83c..41172b1c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2012-08-16 Peter Stephenson <pws@csr.com> + * 30619: Doc/Zsh/builtins.yo, Src/builtin.c, + Test/B02typeset.ztst: repeat "typeset -T" with same two first + arguments is not an error. + * 30617: Src/prototypes.h, Src/zsh_system.h: rationalise replacement of tgoto() prototype which could appear twice inconsistently. @@ -57,5 +61,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5695 $ +* $Revision: 1.5696 $ ***************************************************** diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 98c470a54..5c133a856 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -1552,7 +1552,9 @@ an array to var(SCALAR) is an error, and assigning a scalar to var(array) sets it to be a single-element array. Note that both `tt(typeset -xT ...)' and `tt(export -T ...)' work, but only the scalar will be marked for export. Setting the value using the scalar version causes a split on all -separators (which cannot be quoted). +separators (which cannot be quoted). It is possible to use the +same two tied variables with a different separator character in which +case the variables remain joined as before but the separator is changed. The tt(-g) (global) flag is treated specially: it means that any resulting parameter will not be restricted to local scope. Note that this diff --git a/Src/builtin.c b/Src/builtin.c index b5a98cbd2..ce7d6a563 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -2449,7 +2449,20 @@ bin_typeset(char *name, char **argv, Options ops, int func) && (locallevel == pm->level || !(on & PM_LOCAL))) { if (pm->node.flags & PM_TIED) { unqueue_signals(); - zerrnam(name, "can't tie already tied scalar: %s", asg0.name); + if (!strcmp(asg->name, pm->ename)) { + /* + * Already tied in the fashion requested. + */ + struct tieddata *tdp = (struct tieddata*)pm->u.data; + /* Update join character */ + tdp->joinchar = joinchar; + if (asg0.value) + setsparam(asg0.name, ztrdup(asg0.value)); + return 0; + } else { + zerrnam(name, "can't tie already tied scalar: %s", + asg0.name); + } return 1; } if (!asg0.value && !(PM_TYPE(pm->node.flags) & (PM_ARRAY|PM_HASHED))) diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst index 7a9928abe..51ebc6535 100644 --- a/Test/B02typeset.ztst +++ b/Test/B02typeset.ztst @@ -459,3 +459,12 @@ silent2(){ local silence; silent1; } silent2 0:typeset -g should be silent even without TYPESET_SILENT + + typeset -T TIED_SCALAR tied_array + TIED_SCALAR=foo:bar + print $tied_array + typeset -T TIED_SCALAR=goo:car tied_array + print $tied_array +0:retying arrays to same array works +>foo bar +>goo car |