More bbsh design notes.
Bernhard Fischer
rep.nop at aon.at
Thu Sep 14 16:16:35 UTC 2006
On Sun, Sep 10, 2006 at 05:40:02PM -0400, Rob Landley wrote:
>According to bloatcheck, enabling the minimal configuration of bbsh (with no
>sub-features) currently adds 583 bytes to busybox. I think I can live with
>that.
>
>I'm planning to add bbsh to menuconfig (well, check in the changes I've made
>locally anyway) once it can replace lash. I.E. lash comes out of the tree at
>the same time bbsh goes in. (I'm not counting checking in shell/bbsh.c,
>that's just for history tracking. I don't expect anybody but me to actually
>use it yet.)
>
>The real trick is getting everything configurable, so you can chop it down
>under 600 bytes if all you want is something to run a few commands in your
>init script. Here's what I've got so far:
>
>Feature list for bbsh (nesting indicates sub-features):
> Terminal Control
> History (count)
> Save on disk (count)
> Tab completion
> Pipes/redirect ( < << > >> | || & && () ; )
> Flow control (if while for functions {})
> Job Control (& fg bg jobs +tty=ctrl-z)
> quotes "" ''
> Wildcards (globbing: * ? {})
> Backticks ( `` +envvars=$(blah))
> Environment variables ($blah, ${blah}, =, export)
> Local variables (set, local)
> Synthetic environment variables (reorganize this:)
> $*, $@, $1 - $9
> Fancy prompts ($PS1, $PS2, $GAMECUBE).
> +quotes=$IFS
> +pipes=$_
> +jobctl=$$ $? $PPID
> +tty=$COLUMNS $LINES
> $RANDOM
> $PWD
> $UID $EUID $GROUPS
> $HOSTNAME $HOSTTYPE
> +history=$HISTSIZE
> $IFS $PATH $TERM )
> $[] $(())
> Arrays (${blah[blah]}
> Advanced (${blah/blah/blah} ${blah:#:#})
> Builtin functions
> alias, exec, help, jobs, export, source, read (-nst), set/unset, fgbg
>
>Some of that's automatic (for example, if you enable pipes and synthetic
>environment variables, you get $_. It's not a separate config option.)
>Others I haven't got a clue about. (Should aliases be their own config
>option, or grouped with something else...)
>
>Anyway, random snapshost of the thinking process...
Random comments while reading the currently visible incarnation..
run_pipeline() currently is only used by handle() and should be merged
into it IFF it stays to be the only user.
run_pipeline(): save 9 bytes by reusing skip_whitespace().
Why are you doubling code for list management? Use llist_free() instead
of free_list()?
run_pipeline(): missing newline in print("NO %s"); Why don't you just
use bb_perror_msg_and_die? Doing so saved another 8 byte.
run_pipeline(): There is still that pointless status integer. Ditched to
save 4b
run_pipeline(): cache argv0 to save another 5b
pipeline.job_id commented out; Currently not used.
command.flags perhaps unsigned?
Quick impl of `export´ and `unset´..
Wants a table for these builtins and chdir et al.
Need to play with it some more.. later
cheers,
Bernhard
More information about the busybox
mailing list