summaryrefslogtreecommitdiffstats
path: root/bin/sh/parser.c
diff options
context:
space:
mode:
authortegge <tegge@FreeBSD.org>1998-09-06 21:13:09 +0000
committertegge <tegge@FreeBSD.org>1998-09-06 21:13:09 +0000
commitac59a0c5cd4a2de80842186c8dd22ff48fe29da8 (patch)
treedda84e744f853179b31c4cd9bfa1676a63fa9c1e /bin/sh/parser.c
parent59e6a57bc195e6145db20a1292466fa6df067e24 (diff)
downloadFreeBSD-src-ac59a0c5cd4a2de80842186c8dd22ff48fe29da8.zip
FreeBSD-src-ac59a0c5cd4a2de80842186c8dd22ff48fe29da8.tar.gz
Better handling of word splitting. Don't record the same region
multiple times when performing nested variable expansion, and preserve some quoting information in order to avoid removing apparently empty expansion result.
Diffstat (limited to 'bin/sh/parser.c')
-rw-r--r--bin/sh/parser.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index 0999b22..8df30ca 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: parser.c,v 1.22 1998/05/18 06:44:12 charnier Exp $";
#endif /* not lint */
#include <stdlib.h>
@@ -619,6 +619,7 @@ parsefname() {
if (quoteflag == 0)
n->type = NXHERE;
TRACE(("Here document %d\n", n->type));
+ rmquotes0(wordtext);
if (here->striptabs) {
while (*wordtext == '\t')
wordtext++;
@@ -942,14 +943,18 @@ readtoken1(firstc, syntax, eofmark, striptabs)
USTPUTC('\\', out);
if (SQSYNTAX[c] == CCTL)
USTPUTC(CTLESC, out);
+ else
+ USTPUTC(CTLQUOTEMARK, out);
USTPUTC(c, out);
quotef++;
}
break;
case CSQUOTE:
+ USTPUTC(CTLQUOTEMARK, out);
syntax = SQSYNTAX;
break;
case CDQUOTE:
+ USTPUTC(CTLQUOTEMARK, out);
syntax = DQSYNTAX;
dblquote = 1;
break;
@@ -1401,6 +1406,10 @@ parsearith: {
prevsyntax = syntax;
syntax = ARISYNTAX;
USTPUTC(CTLARI, out);
+ if (dblquote)
+ USTPUTC('"',out);
+ else
+ USTPUTC(' ',out);
} else {
/*
* we collapse embedded arithmetic expansion to
OpenPOWER on IntegriCloud