On Friday 21 September 2007 08:30, Natanael Copa wrote: > (I forgot to CC th emailint list so I resend this one) > > On Sat, 2007-09-15 at 14:28 +0100, Denis Vlasenko wrote: > > On Thursday 13 September 2007 12:39, Natanael Copa wrote: > > > Hi, > > > > > > Attatched is a patch that fixes the annoying bug in ash prmpt expansion. > > > > > > Currently the default PS1='\w \$ ' will always show a '$' as prompt > > > while PS1='\w \\$ ' will show a '#' if effective user is root and '$' > > > otherwise. > > > > This is strange, for me current svn seems to work: > > > > sh-3.2# ./busybox ash > > /.1/usr/srcdevel/bbox/fix/busybox.t3 # PS1='\w \$ ' > > /.1/usr/srcdevel/bbox/fix/busybox.t3 # PS1='\w \\$ ' > > /.1/usr/srcdevel/bbox/fix/busybox.t3 \$ PS1='TEST>\$ ' > > TEST># PS1='TEST>\\$ ' > > TEST>\$ > > > > Is it already fixed? Or maybe it depends on .config. > > Mine is attached. > > > CONFIG_ASH_RANDOM_SUPPORT=y > > # CONFIG_ASH_EXPAND_PRMT is not set > > CONFIG_HUSH=y > > Try enable CONFIG_ASH_EXPAND_PRMT > > Maybe we should check if ASH_EXPAND_PRMT is enabled before trying to fix > the prompt expansion. See attatched patch.
With this patch I get this: $ env - ./busybox ash w $ set IFS=' ' OPTIND='1' PATH='/sbin:/usr/sbin:/bin:/usr/bin' PPID='12606' PS1='\w \$ ' PS2='> ' PS4='+ ' PWD='/usr/local/google/vda/srcdev/bbox/fix/busybox.t5' w $ Looks like it got worse, not better... I am attaching my .config too. (I edited ash.c in svn. I rediffed your patch, see attached). -- vda
diff -d -urpN busybox.4/shell/ash.c busybox.5/shell/ash.c
--- busybox.4/shell/ash.c 2007-09-21 17:38:38.000000000 +0100
+++ busybox.5/shell/ash.c 2007-09-21 17:50:20.000000000 +0100
@@ -2494,6 +2494,7 @@ pwdcmd(int argc, char **argv)
#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 @@ readtoken1(int firstc, int syntax, char
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 */
@@ -9910,6 +9914,11 @@ readtoken1(int firstc, int syntax, char
dblquote = (syntax == DQSYNTAX);
oldstyle = 0;
prevsyntax = 0;
+#if ENABLE_ASH_EXPAND_PRMT
+ pssyntax = (syntax == PSSYNTAX);
+ if (pssyntax)
+ syntax = DQSYNTAX;
+#endif
varnest = 0;
arinest = 0;
parenlevel = 0;
@@ -9948,6 +9957,12 @@ readtoken1(int firstc, int syntax, char
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 @@ expandstr(const char *ps)
/* XXX Fix (char *) cast. */
setinputstring((char *)ps);
- readtoken1(pgetc(), DQSYNTAX, nullstr, 0);
+ readtoken1(pgetc(), PSSYNTAX, nullstr, 0);
popfile();
n.narg.type = NARG;
.config.bz2
Description: BZip2 compressed data
_______________________________________________ busybox mailing list [email protected] http://busybox.net/cgi-bin/mailman/listinfo/busybox
