summaryrefslogtreecommitdiffstats
path: root/bin/sh/expand.c
diff options
context:
space:
mode:
authortegge <tegge@FreeBSD.org>1998-09-13 19:24:57 +0000
committertegge <tegge@FreeBSD.org>1998-09-13 19:24:57 +0000
commitc82e121ce74c6eb8a8320558d50687405f5c3b06 (patch)
tree8dc9a8aa332a6ba94153af431e81d754f41f4a2e /bin/sh/expand.c
parentda907f2515cfc4bb9e3baebdeead74eded772425 (diff)
downloadFreeBSD-src-c82e121ce74c6eb8a8320558d50687405f5c3b06.zip
FreeBSD-src-c82e121ce74c6eb8a8320558d50687405f5c3b06.tar.gz
Be more consistent with handling of quote mark control character.
Don't output double-quotes inside variable expansion/arithmetic expansion region in here-documents. When leaving the arithmetic expansion syntax mode, adjust the dblquote flag according to previous syntax, in order to avoid splitting of quoted variables.
Diffstat (limited to 'bin/sh/expand.c')
-rw-r--r--bin/sh/expand.c64
1 files changed, 6 insertions, 58 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index 25cdc1e..757ff3a 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
#endif
static const char rcsid[] =
- "$Id: expand.c,v 1.22 1998/05/18 06:43:40 charnier Exp $";
+ "$Id: expand.c,v 1.23 1998/09/06 21:13:09 tegge Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -142,8 +142,7 @@ expandhere(arg, fd)
{
herefd = fd;
expandarg(arg, (struct arglist *)NULL, 0);
- xwrite(fd, stackblock(),
- rmquotes(stackblock(), expdest - stackblock()));
+ xwrite(fd, stackblock(), expdest - stackblock());
}
@@ -185,8 +184,6 @@ expandarg(arg, arglist, flag)
} else {
if (flag & EXP_REDIR) /*XXX - for now, just remove escapes */
rmescapes(p);
- else
- rmquotes0(p);
sp = (struct strlist *)stalloc(sizeof (struct strlist));
sp->text = p;
*exparg.lastp = sp;
@@ -235,7 +232,8 @@ argstr(p, flag)
/* "$@" syntax adherence hack */
if (p[0] == CTLVAR && p[2] == '@' && p[3] == '=')
break;
- STPUTC(c, expdest);
+ if ((flag & EXP_FULL) != 0)
+ STPUTC(c, expdest);
break;
case CTLESC:
if (quotes)
@@ -292,6 +290,8 @@ exptilde(p, flag)
switch(c) {
case CTLESC:
return (startp);
+ case CTLQUOTEMARK:
+ return (startp);
case ':':
if (flag & EXP_VARTILDE)
goto done;
@@ -1464,58 +1464,6 @@ rmescapes(str)
*q = '\0';
}
-void rmquotes0(str)
- char *str;
-{
- char *p, *q;
-
- p = str;
- while (*p != CTLQUOTEMARK) {
- if (*p == CTLESC) {
- p++;
- p++;
- continue;
- }
- if (*p++ == '\0')
- return;
- }
- q = p;
- while (*p) {
- if (*p == CTLQUOTEMARK) {
- p++;
- continue;
- }
- if (*p == CTLESC)
- *q++ = *p++;
- *q++ = *p++;
- }
- *q = '\0';
-}
-
-int
-rmquotes(str, len)
- char *str;
- int len;
-{
- char *p, *q, *pe;
-
- p = str;
- pe = str + len;
- while (*p != CTLQUOTEMARK) {
- if (++p == pe)
- return len;
- }
- q = p;
- while (p < pe) {
- if (*p == CTLQUOTEMARK) {
- p++;
- continue;
- }
- *q++ = *p++;
- }
- return q - str;
-}
-
/*
OpenPOWER on IntegriCloud