[BusyBox] clean Bourne shell parser, under construction

larry at doolittle.boa.org larry at doolittle.boa.org
Sun Dec 24 05:15:12 UTC 2000


I just posted parser.c to
  http://doolittle.faludi.com/~larry/parser.c

parser.c -- a prototype Bourne shell grammar parser
     Intended to follow the original Thompson and Ritchie
     "small and simple is beautiful" philosophy, which
     incidentally is a good match to today's BusyBox.

I wrote it from scratch in about three days, and place it under GPLv2.

The code (with the usual terse comments) runs to 460 lines so far.
If I strip the executable now, even with all the printfs, it comes
in at just over 6 Kbytes.  This already "implements" quoting rules,
parameter expansion, command substitution, globbing, pipes,
and command chaining with ;, &, ||, and &&.

It will take some effort to complete, but I see it on a track
to replace the existing parser in BusyBox's sh.c.

to-do:
     final backslash "quote" removal
     null argument handling
     implement redirects
     paste in real run_job from BusyBox
     continuation lines, both explicit and implicit
     memory leak finding and plugging
     clean up dest->quote=tq; hack
     more testing, especially quoting rules
     maybe change map[] to use 2-bit entries
     (eventually) remove all the printf's
     integration with BusyBox

Comments welcome, but I suggest keeping any active discussion
that develops away from this mailing list, at least until someone
has a working version merged into BusyBox.

      - Larry Doolittle   <larry at doolittle.boa.org>





More information about the busybox mailing list