[BusyBox] Re: overriding builtins
Larry Doolittle
ldoolitt at recycle.lbl.gov
Fri Nov 17 17:30:51 UTC 2000
Someone could add a "command" builtin if they like.
I don't see an urgent need. Although POSIX conformance
is nice, there are lots more important features to add,
like real variable expansion.
All the recent posts got sidetracked by an error of
mine in the subject line: I'm not really talking about
"builtin" functions (bg, cd, exec, ...). Rather, the
concern is for "applets" (ar, basename, cat, chgrp, ...).
Here is my (tested) one-liner that makes busybox-0.47
sh act the way _I_ expect.
- Larry Doolittle <LRDoolittle at lbl.gov>
--- busybox-0.47/sh.c Mon Sep 25 14:42:27 2000
+++ busybox-0.47-lrd/sh.c Fri Nov 17 09:20:34 2000
@@ -1203,9 +1203,16 @@
}
}
#ifdef BB_FEATURE_SH_STANDALONE_SHELL
- /* Check if the command matches any busybox internal commands here */
+ /* Check if the command matches any busybox internal commands ("applets") here.
+ * Following discussions from November 2000 on busybox at busybox.net,
+ * don't use get_last_path_component(). This way explicit (with slashes)
+ * filenames will never be interpreted as an applet, just like with builtins.
+ * This way the user can override an applet with an explicit filename reference.
+ * The only downside to this change is that an explicit /bin/foo invocation
+ * fill fork and exec /bin/foo, even if /bin/foo is a symlink to busybox.
+ */
while (a->name != 0) {
- if (strcmp(get_last_path_component(newJob->progs[i].argv[0]), a->name) == 0) {
+ if (strcmp(newJob->progs[i].argv[0], a->name) == 0) {
int argc_l;
char** argv=newJob->progs[i].argv;
for(argc_l=0;*argv!=NULL; argv++, argc_l++);
More information about the busybox
mailing list