summaryrefslogtreecommitdiff
path: root/Src/text.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-03-14 11:40:57 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-03-14 11:40:57 +0000
commit948f015df0fee27f4e2c73b442a75c9434702550 (patch)
tree0d28c6e4ad0bd849702de39e544c597634ff7283 /Src/text.c
parent2ca42b2025cceaabd64889aa3b932195e8d5720c (diff)
downloadzsh-948f015df0fee27f4e2c73b442a75c9434702550.tar.gz
zsh-948f015df0fee27f4e2c73b442a75c9434702550.zip
24711: fix re-presentation of here-documents munged internally
to here-strings
Diffstat (limited to 'Src/text.c')
-rw-r--r--Src/text.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Src/text.c b/Src/text.c
index 593c25776..7fdc5757f 100644
--- a/Src/text.c
+++ b/Src/text.c
@@ -831,17 +831,22 @@ getredirs(LinkList redirs)
taddstr(fstr[f->type]);
if (f->type != REDIR_MERGEIN && f->type != REDIR_MERGEOUT)
taddchr(' ');
- if (f->type == REDIR_HERESTR && !has_token(f->name)) {
+ if (f->type == REDIR_HERESTR &&
+ (f->flags & REDIRF_FROM_HEREDOC)) {
/*
* Strings that came from here-documents are converted
* to here strings without quotation, so add that
- * now. If tokens are already present taddstr()
- * will do the right thing (anyway, adding more
- * quotes certainly isn't right in that case).
+ * now. If tokens are present we need to do double quoting.
*/
- taddchr('\'');
- taddstr(quotestring(f->name, NULL, QT_SINGLE));
- taddchr('\'');
+ if (!has_token(f->name)) {
+ taddchr('\'');
+ taddstr(quotestring(f->name, NULL, QT_SINGLE));
+ taddchr('\'');
+ } else {
+ taddchr('"');
+ taddstr(quotestring(f->name, NULL, QT_DOUBLE));
+ taddchr('"');
+ }
} else
taddstr(f->name);
taddchr(' ');