[PATCH] ash fancy prompt expansion

Natanael Copa natanael.copa at gmail.com
Mon Sep 24 14:03:45 UTC 2007


On Fri, 2007-09-21 at 23:36 +0100, Denys Vlasenko wrote:
> On Friday 21 September 2007 20:15, Natanael Copa wrote:
> > > Looks like it got worse, not better...
> > > I am attaching my .config too.
> > 
> > How does it look with your config and without the patch?
> 
> It works without the patch.

Your config (had to disable readahead and taskset), witout patch,
uclibc, r19987:

# env - ./busybox_unstripped ash
/busybox/svn $ set
IFS=' 
'
OPTIND='1'
PATH='/sbin:/usr/sbin:/bin:/usr/bin'
PPID='26186'
PS1='\w \$ '
PS2='> '
PS4='+ '
PWD='/busybox/svn'
/busybox/svn $ whoami
root
/busybox/svn $ 

With patch:

# env - ./busybox_unstripped ash
w # 

Humm...

the problem is in your modified patch:

@@ -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;

The

	dblquote = (syntax == DQSYNTAX);

line *must* come after the:

	if (pssyntax)
		syntax = DQSYNTAX;

I think this is a proof of how dirty the code really is.

I was thinking of:
#define DQSYNTAX   0x01    /* in double quotes */
#define SQSYNTAX   0x02    /* in single quotes */
#define ARISYNTAX  0x04    /* in arithmetic */
#define PSSYNTAX   0x08    /* prompt */

and use bit wise operations:
  if (syntax & PSSYNTAX) ...; 
  if (syntax & DQSYNTAX) ...;

But i have no idea what obscure consequences that might have in the
other end of the building. The patch tries to touch as little as
possible. 

Updated patch attatched.

Thanks!
> --
> vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox-svn-ash-prompt-expansion4.patch
Type: text/x-patch
Size: 1648 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070924/85fedb4f/attachment-0002.bin 


More information about the busybox mailing list