1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 10:01:11 +02:00

20112 changed c.f. 20113:

fix here string and here document expansion and quoting
This commit is contained in:
Peter Stephenson 2004-06-28 15:38:10 +00:00
parent 81d27b662a
commit 7f26993e99
5 changed files with 51 additions and 4 deletions

View file

@ -1,3 +1,12 @@
2004-06-28 Peter Stephenson <pws@csr.com>
* 20112, changed as per 20113: Src/exec.c, Src/parse.c,
Src/subst.c, Doc/Zsh/redirect.yo, Test/A04redirect.yo:
Fix here-strings to do standard single-word expansion (which
was always intended but was partially broken), and also
attempt to parse the end string for here-documents in
a more standard fashion.
2004-06-26 Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
* unposted: Functions/Zle/.distfiles: add zed-set-file-name.

View file

@ -70,12 +70,22 @@ occurs, `tt(\)' followed by a newline is removed,
and `tt(\)' must be used to quote the characters
`tt(\)', `tt($)', `tt(`)' and the first character of var(word).
Note that var(word) itself does not undergo shell expansion. Backquotes
in var(word) do not have their usual effect; instead they behave
similarly to double quotes, except that the backquotes themselves are
passed through unchanged. (This information is given for completeness
and it is not recommended that backquotes be used.) Quotes in the form
tt($')var(...)tt(') have their standard effect of expanding backslashed
references to special characters.
If tt(<<-) is used, then all leading
tabs are stripped from var(word) and from the document.
)
item(tt(<<<) var(word))(
Perform shell expansion on var(word) and pass the result
to standard input. This is known as a em(here-string).
Compare the use of var(word) in here-documents above, where var(word)
does not undergo shell expansion.
)
xitem(tt(<&) var(number))
item(tt(>&) var(number))(

View file

@ -2714,9 +2714,10 @@ gethere(char *str, int typ)
for (s = str; *s; s++)
if (INULL(*s)) {
*s = Nularg;
qt = 1;
break;
}
quotesubst(str);
untokenize(str);
if (typ == REDIR_HEREDOCDASH) {
strip = 1;

View file

@ -1754,9 +1754,6 @@ par_redir(int *rp)
if ((tokstr[0] == Inang || tokstr[0] == Outang) && tokstr[1] == Inpar)
type = tokstr[0] == Inang ? REDIR_INPIPE : REDIR_OUTPIPE;
break;
case REDIR_HERESTR:
remnulargs(name = dupstring(name));
break;
}
yylex();

View file

@ -231,6 +231,36 @@ stringsubst(LinkList list, LinkNode node, int ssub, int asssub)
return errflag ? NULL : node;
}
/*
* Simplified version of the prefork/singsub processing where
* we only do substitutions appropriate to quoting. Currently
* this means only the expansions in $'....'. This is used
* for the end tag for here documents. As we are not doing
* `...` expansions, we just use those for quoting. However,
* they stay in the text. This is weird, but that's not
* my fault.
*
* The remnulargs() makes this consistent with the other forms
* of substitution, indicating that quotes have been fully
* processed.
*/
/**/
void
quotesubst(char *str)
{
char *s = str;
while (*s) {
if (*s == String && s[1] == Snull) {
s = getkeystring(s, NULL, 4, NULL);
} else {
s++;
}
}
remnulargs(str);
}
/**/
mod_export void
globlist(LinkList list, int nountok)