ash: command line editing question
Denys Vlasenko
vda.linux at googlemail.com
Sun Dec 9 01:57:06 PST 2007
On Thursday 06 December 2007 00:21, Alexander Griesser wrote:
> Again, busybox ash doesn't do this, but I found out another interesting
> thing. bash, dash and ash seem to act very differently wrt arithmetic
> parsing:
>
> -------------------------[ bash ]---------------------------
> $ VAR=2
> $ echo $(( $VAR + $VAR )
> > ))
> bash: syntax error near unexpected token `)'
> $ echo $(( $VAR + $VAR )
> > )
> bash: 2: command not found
> $
> -------------------------------------------------------------
> There's no obvious way to let the arith complete successfully.
>
> -------------------------[ dash ] ---------------------------
> $ VAR=2
> $ echo $(( $VAR + $VAR )
> > )
> > [CTRL-C]
> $ echo $(( $VAR + $VAR )
> > ))
> 4
> $
> --------------------------------------------------------------
> One single paren doesn't help, but two parens let the arith
> complete successfully and will bring me back to the shell prompt.
>
> -------------------------[ busybox ash ]----------------------
> $ VAR=2
> $ echo $(( $VAR + $VAR)
> > )
> > ))
> ash: syntax error: 2 + 2 )
> $
> --------------------------------------------------------------
> No reaction on a single paren in the second line, but a double
> closing paren seems to do what dash does, but the arith itself
> throws a syntax error afterwards.
I guess ash treats '))' as a token. You cannot separate it into two ) ).
Basically, in the above case it sees: $(( $VAR + $VAR ) ))
>
> So, what's the desired behaviour?
Oh no, dreaded ash.c :)
preadfd() is the function where Ctrl-C simply loops you back to input.
If you press Ctrl-D, you fall through into preadbuffer() [the only place which
uses preadfd()] and:
again:
more = preadfd();
if (more <= 0) {
parselleft = parsenleft = EOF_NLEFT;
return PEOF;
}
Next... preadbuffer() is used in pgetc_as_macro()... and so forth...
ash is way bigger than my tiny brain can hold :(
--
vda
More information about the busybox
mailing list