[patch] Not quite bbsh. :)

Bernhard Fischer rep.nop at aon.at
Sat Sep 2 16:36:00 UTC 2006


On Fri, Sep 01, 2006 at 05:20:45PM -0400, Rob Landley wrote:
>So here's a little toy I made; the world's most pathetic shell.  It's an 
>experiment to see how small I can get a shell down to, and it does indeed 
>beat lash in both size and lameness.

>+static int handle(char *command)
>+{
[snip]
>+	if (!argc) return 0;
>+	if (argc==2 && !strcmp(argv[0],"cd")) chdir(argv[1]);

How should we deal with "builtin" commands?

Should we possibly (optionally) provide "cd" et al as applets?

Theoretical nitpicks about the codeline above:
1) The strcmp call is much larger than comparing these by hand
2) so if i invoke cdplayer /my/music_repo/*.au  then you do what
exactly? ;)

>+	else if(!strcmp(argv[0],"exit")) exit(argc>1 ? atoi(argv[1]) : 0); 
>+	else {
>+		int status;
>+		pid_t pid=fork();
>+		if(!pid) {
>+			run_applet_by_name(argv[0],argc,argv);
>+			execvp(argv[0],argv);
>+			printf("No %s",argv[0]);
>+			exit(1);
>+		} else waitpid(pid, &status, 0);
Another theoretical nitpick (can't resist, sorry :)
status is superfluous, better make that read waitpid(pid,NULL,0); and
ditch it alltogether, at least if no jobcontrol is selected or something
like this.

[snip]
Looks pretty small indeed :)



More information about the busybox mailing list