[BusyBox] experiments with sh.c
Erik Andersen
andersen at lineo.com
Mon Dec 18 06:57:01 UTC 2000
On Sat Dec 16, 2000 at 09:41:14AM -0800, larry at doolittle.boa.org wrote:
>
> 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.
Finding the job associated with a child_program will come in handy --
I wanted that while I was on the plane... Good, good, good.
> 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);
Sounds fair.
> 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
Ouch!
> 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 $
Ahh. Good catch.
> 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.
/me goes off to read your changes carefully.
-Erik
--
Erik B. Andersen email: andersen at lineo.com
--This message was written using 73% post-consumer electrons--
More information about the busybox
mailing list