summaryrefslogtreecommitdiff
path: root/Src/text.c
diff options
context:
space:
mode:
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(' ');