svn commit: trunk/busybox/shell
vda at busybox.net
vda at busybox.net
Mon Sep 24 18:30:04 UTC 2007
Author: vda
Date: 2007-09-24 11:30:02 -0700 (Mon, 24 Sep 2007)
New Revision: 19993
Log:
ash: fix prompt expansion (Natanael Copa <natanael.copa at gmail.com>)
Modified:
trunk/busybox/shell/ash.c
Changeset:
Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c 2007-09-24 18:27:04 UTC (rev 19992)
+++ trunk/busybox/shell/ash.c 2007-09-24 18:30:02 UTC (rev 19993)
@@ -2494,6 +2494,7 @@
#define DQSYNTAX 1 /* in double quotes */
#define SQSYNTAX 2 /* in single quotes */
#define ARISYNTAX 3 /* in arithmetic */
+#define PSSYNTAX 4 /* prompt */
#if ENABLE_ASH_OPTIMIZE_FOR_SIZE
#define USE_SIT_FUNCTION
@@ -9886,6 +9887,9 @@
smallint dblquote;
smallint oldstyle;
smallint prevsyntax; /* syntax before arithmetic */
+#if ENABLE_ASH_EXPAND_PRMT
+ smallint pssyntax; /* we are expanding a prompt string */
+#endif
int varnest; /* levels of variables expansion */
int arinest; /* levels of arithmetic expansion */
int parenlevel; /* levels of parens in arithmetic */
@@ -9907,9 +9911,14 @@
startlinno = plinno;
bqlist = NULL;
quotef = 0;
- dblquote = (syntax == DQSYNTAX);
oldstyle = 0;
prevsyntax = 0;
+#if ENABLE_ASH_EXPAND_PRMT
+ pssyntax = (syntax == PSSYNTAX);
+ if (pssyntax)
+ syntax = DQSYNTAX;
+#endif
+ dblquote = (syntax == DQSYNTAX);
varnest = 0;
arinest = 0;
parenlevel = 0;
@@ -9948,6 +9957,12 @@
if (doprompt)
setprompt(2);
} else {
+#if ENABLE_ASH_EXPAND_PRMT
+ if (c == '$' && pssyntax) {
+ USTPUTC(CTLESC, out);
+ USTPUTC('\\', out);
+ }
+#endif
if (dblquote &&
c != '\\' && c != '`' &&
c != '$' && (
@@ -10780,7 +10795,7 @@
/* XXX Fix (char *) cast. */
setinputstring((char *)ps);
- readtoken1(pgetc(), DQSYNTAX, nullstr, 0);
+ readtoken1(pgetc(), PSSYNTAX, nullstr, 0);
popfile();
n.narg.type = NARG;
More information about the busybox-cvs
mailing list