mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-08 12:01:21 +02:00
28530: replace (z+opts+) flag with (Z:opts:), add reserved (_🎏).
This commit is contained in:
parent
ef5cf45780
commit
66152e8ada
4 changed files with 63 additions and 25 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2010-12-14 Barton E. Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* 28530: Doc/Zsh/expn.yo, Src/subst.c, Test/D04parameter.ztst:
|
||||||
|
replace (z+opts+) flag with (Z:opts:), add reserved (_:flags:).
|
||||||
|
|
||||||
2010-12-14 Peter Stephenson <pws@csr.com>
|
2010-12-14 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* unposted: Src/lex.c: another neatening of lexflags use for
|
* unposted: Src/lex.c: another neatening of lexflags use for
|
||||||
|
@ -13958,5 +13963,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.5151 $
|
* $Revision: 1.5152 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -1009,18 +1009,6 @@ find the words, i.e. taking into account any quoting in the value.
|
||||||
Comments are not treated specially but as ordinary strings, similar
|
Comments are not treated specially but as ordinary strings, similar
|
||||||
to interactive shells with the tt(INTERACTIVE_COMMENTS) option unset.
|
to interactive shells with the tt(INTERACTIVE_COMMENTS) option unset.
|
||||||
|
|
||||||
The flag can take a combination of option letters between a following
|
|
||||||
pair of `tt(PLUS())' characters. tt(LPAR()z+PLUS()c+PLUS()RPAR())
|
|
||||||
causes comments to be parsed as a string and retained; any field in the
|
|
||||||
resulting array beginning with an unquoted comment character is a
|
|
||||||
comment. tt(LPAR()z+PLUS()C+PLUS()RPAR()) causes comments to be parsed
|
|
||||||
and removed. The rule for comments is standard: anything between a word
|
|
||||||
starting with the third charcter of tt($HISTCHARS), default tt(#), up to
|
|
||||||
the next newline is a comment. tt(LPAR()z+PLUS()n+PLUS()RPAR()) causes
|
|
||||||
unquoted newlines to be treated as ordinary whitespace, else they are
|
|
||||||
treated as if they are shell code delimiters and converted to
|
|
||||||
semicolons.
|
|
||||||
|
|
||||||
Note that this is done very late, as for the `tt((s))' flag. So to
|
Note that this is done very late, as for the `tt((s))' flag. So to
|
||||||
access single words in the result, one has to use nested expansions as
|
access single words in the result, one has to use nested expansions as
|
||||||
in `tt(${${(z)foo}[2]})'. Likewise, to remove the quotes in the
|
in `tt(${${(z)foo}[2]})'. Likewise, to remove the quotes in the
|
||||||
|
@ -1129,6 +1117,25 @@ produces two lines of output for tt(one) and tt(three) and elides the
|
||||||
empty field. To override this behaviour, supply the "(@)" flag as well,
|
empty field. To override this behaviour, supply the "(@)" flag as well,
|
||||||
i.e. tt("${(@s.:.)line}").
|
i.e. tt("${(@s.:.)line}").
|
||||||
)
|
)
|
||||||
|
item(tt(Z:)var(opts)tt(:))(
|
||||||
|
As tt(z) but takes a combination of option letters between a following
|
||||||
|
pair of delimiter characters. tt(LPAR()Z+PLUS()c+PLUS()RPAR())
|
||||||
|
causes comments to be parsed as a string and retained; any field in the
|
||||||
|
resulting array beginning with an unquoted comment character is a
|
||||||
|
comment. tt(LPAR()Z+PLUS()C+PLUS()RPAR()) causes comments to be parsed
|
||||||
|
and removed. The rule for comments is standard: anything between a word
|
||||||
|
starting with the third character of tt($HISTCHARS), default tt(#), up to
|
||||||
|
the next newline is a comment. tt(LPAR()Z+PLUS()n+PLUS()RPAR()) causes
|
||||||
|
unquoted newlines to be treated as ordinary whitespace, else they are
|
||||||
|
treated as if they are shell code delimiters and converted to
|
||||||
|
semicolons.
|
||||||
|
)
|
||||||
|
item(tt(_:)var(flags)tt(:))(
|
||||||
|
The underscore (tt(_)) flag is reserved for future use. As of this
|
||||||
|
revision of zsh, there are no valid var(flags); anything following an
|
||||||
|
underscore, other than an empty pair of delimiters, is treated as an
|
||||||
|
error, and the flag itself has no effect.
|
||||||
|
)
|
||||||
enditem()
|
enditem()
|
||||||
|
|
||||||
The following flags are meaningful with the tt(${)...tt(#)...tt(}) or
|
The following flags are meaningful with the tt(${)...tt(#)...tt(}) or
|
||||||
|
|
42
Src/subst.c
42
Src/subst.c
|
@ -1936,10 +1936,15 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
||||||
|
|
||||||
case 'z':
|
case 'z':
|
||||||
shsplit = LEXFLAGS_ACTIVE;
|
shsplit = LEXFLAGS_ACTIVE;
|
||||||
if (s[1] == '+') {
|
break;
|
||||||
s += 2;
|
|
||||||
while (*s && *s != '+' && *s != ')' && *s != Outpar) {
|
case 'Z':
|
||||||
switch (*s++) {
|
t = get_strarg(++s, &arglen);
|
||||||
|
if (*t) {
|
||||||
|
sav = *t;
|
||||||
|
*t = 0;
|
||||||
|
while (*++s) {
|
||||||
|
switch (*s) {
|
||||||
case 'c':
|
case 'c':
|
||||||
/* Parse and keep comments */
|
/* Parse and keep comments */
|
||||||
shsplit |= LEXFLAGS_COMMENTS_KEEP;
|
shsplit |= LEXFLAGS_COMMENTS_KEEP;
|
||||||
|
@ -1956,12 +1961,14 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
goto flagerr;
|
*t = sav;
|
||||||
|
goto flagerr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*s != '+')
|
*t = sav;
|
||||||
goto flagerr;
|
s = t + arglen - 1;
|
||||||
}
|
} else
|
||||||
|
goto flagerr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
|
@ -1973,6 +1980,25 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
||||||
evalchar = 1;
|
evalchar = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case '_':
|
||||||
|
t = get_strarg(++s, &arglen);
|
||||||
|
if (*t) {
|
||||||
|
sav = *t;
|
||||||
|
*t = 0;
|
||||||
|
while (*++s) {
|
||||||
|
/* Reserved for future use */
|
||||||
|
switch (*s) {
|
||||||
|
default:
|
||||||
|
*t = sav;
|
||||||
|
goto flagerr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*t = sav;
|
||||||
|
s = t + arglen - 1;
|
||||||
|
} else
|
||||||
|
goto flagerr;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
flagerr:
|
flagerr:
|
||||||
zerr("error in flags");
|
zerr("error in flags");
|
||||||
|
|
|
@ -421,9 +421,9 @@
|
||||||
print "*** Normal ***"
|
print "*** Normal ***"
|
||||||
print -l ${(z)line}
|
print -l ${(z)line}
|
||||||
print "*** Kept ***"
|
print "*** Kept ***"
|
||||||
print -l ${(z+c+)line}
|
print -l ${(Z+c+)line}
|
||||||
print "*** Removed ***"
|
print "*** Removed ***"
|
||||||
print -l ${(z+C+)line}
|
print -l ${(Z+C+)line}
|
||||||
0:Comments with (z)
|
0:Comments with (z)
|
||||||
>*** Normal ***
|
>*** Normal ***
|
||||||
>A
|
>A
|
||||||
|
@ -457,13 +457,13 @@
|
||||||
>one
|
>one
|
||||||
|
|
||||||
line='with comment # at the end'
|
line='with comment # at the end'
|
||||||
print -l ${(z+C+)line}
|
print -l ${(Z+C+)line}
|
||||||
0:Test we don't get an additional newline token
|
0:Test we don't get an additional newline token
|
||||||
>with
|
>with
|
||||||
>comment
|
>comment
|
||||||
|
|
||||||
line=$'echo one\necho two # with a comment\necho three'
|
line=$'echo one\necho two # with a comment\necho three'
|
||||||
print -l ${(z+nc+)line}
|
print -l ${(Z+nc+)line}
|
||||||
0:Treating zplit newlines as ordinary whitespace
|
0:Treating zplit newlines as ordinary whitespace
|
||||||
>echo
|
>echo
|
||||||
>one
|
>one
|
||||||
|
|
Loading…
Reference in a new issue