[BusyBox] experiments with sh.c

larry at doolittle.boa.org larry at doolittle.boa.org
Sat Dec 16 17:41:14 UTC 2000


I spent some airplane time with my laptop, hacking on sh.c.
You can look at the results at http://doolittle.faludi.com/~larry/sh.c
This version is based on 0.48, not including recent changes by
other folks (no net access at 39,000 feet :-( ).

I put in a subtle rearrangement of the data structures that represent the
job after parsing (struct jobList, struct job, struct childProgram).  In
particular, you can now find the job associated with any childProgram,
and the jobList associated with any job.  I could therefore simplify some
subroutine interfaces.

I also took two big blocks of code out of runCommand, and made subroutines
  static int pseudo_exec(struct childProgram *cmd);
  static void insert_job(struct job *newJob, int inBg);

In the process of making these changes, I discovered and fixed two real bugs.
Fixing them without my data structure rearrangement would be very messy.

bash $ ./busybox sh
[larry at traveller busybox]$ echo foo | exec ls
sh: Exec to foo failed: No such file or directory
bash $ ./busybox sh
[larry at traveller busybox]$ export PATH=foo
[larry at traveller busybox]$ # ls is an applet, so it doesn't need a path
[larry at traveller busybox]$ ls busybox
busybox
[larry at traveller busybox]$ # Surprise!  exec doesn't check for applets
[larry at traveller busybox]$ exec busybox
sh: Exec to ls failed: No such file or directory
bash $

I don't really expect these hacks to go in without further work,
although you are welcome to do so.  I do suggest anyone interested
in working on the shell look at them, test them, and we can discuss
and probably improve on them further.

        - Larry Doolittle   <LRDoolittle at lbl.gov>





More information about the busybox mailing list