aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-06-15 16:54:25 +0000
committermarkw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-06-15 16:54:25 +0000
commitb6dd391224aed8c58ae0f805147d297d75032d42 (patch)
tree0b639585e4bf9fb16d483a81b0588e62716ed9a9
parent3fcd1c219637f24882bdd5e17a9818ed31f1f944 (diff)
downloadbusybox-w32-b6dd391224aed8c58ae0f805147d297d75032d42.tar.gz
busybox-w32-b6dd391224aed8c58ae0f805147d297d75032d42.tar.bz2
busybox-w32-b6dd391224aed8c58ae0f805147d297d75032d42.zip
Applied patch from Jim Gleason that makes it so busybox will still work even
if you rename it. git-svn-id: svn://busybox.net/trunk/busybox@2836 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--applets.c11
-rw-r--r--applets/applets.c11
2 files changed, 20 insertions, 2 deletions
diff --git a/applets.c b/applets.c
index c1575c70d..90667e52e 100644
--- a/applets.c
+++ b/applets.c
@@ -84,13 +84,22 @@ struct BB_applet *find_applet_by_name(const char *name)
84 84
85void run_applet_by_name(const char *name, int argc, char **argv) 85void run_applet_by_name(const char *name, int argc, char **argv)
86{ 86{
87 static int recurse_level = 0;
88
89 recurse_level++;
87 /* Do a binary search to find the applet entry given the name. */ 90 /* Do a binary search to find the applet entry given the name. */
88 if ((applet_using = find_applet_by_name(name)) != NULL) { 91 if ((applet_using = find_applet_by_name(name)) != NULL) {
89 applet_name = applet_using->name; 92 applet_name = applet_using->name;
90 if (argv[1] && strcmp(argv[1], "--help") == 0) 93 if (argv[1] && strcmp(argv[1], "--help") == 0) {
91 show_usage(); 94 show_usage();
95 }
92 exit((*(applet_using->main)) (argc, argv)); 96 exit((*(applet_using->main)) (argc, argv));
93 } 97 }
98 /* Just in case they have renamed busybox - Check argv[1] */
99 if (recurse_level == 1) {
100 run_applet_by_name("busybox", argc, argv);
101 }
102 recurse_level = 0;
94} 103}
95 104
96 105
diff --git a/applets/applets.c b/applets/applets.c
index c1575c70d..90667e52e 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -84,13 +84,22 @@ struct BB_applet *find_applet_by_name(const char *name)
84 84
85void run_applet_by_name(const char *name, int argc, char **argv) 85void run_applet_by_name(const char *name, int argc, char **argv)
86{ 86{
87 static int recurse_level = 0;
88
89 recurse_level++;
87 /* Do a binary search to find the applet entry given the name. */ 90 /* Do a binary search to find the applet entry given the name. */
88 if ((applet_using = find_applet_by_name(name)) != NULL) { 91 if ((applet_using = find_applet_by_name(name)) != NULL) {
89 applet_name = applet_using->name; 92 applet_name = applet_using->name;
90 if (argv[1] && strcmp(argv[1], "--help") == 0) 93 if (argv[1] && strcmp(argv[1], "--help") == 0) {
91 show_usage(); 94 show_usage();
95 }
92 exit((*(applet_using->main)) (argc, argv)); 96 exit((*(applet_using->main)) (argc, argv));
93 } 97 }
98 /* Just in case they have renamed busybox - Check argv[1] */
99 if (recurse_level == 1) {
100 run_applet_by_name("busybox", argc, argv);
101 }
102 recurse_level = 0;
94} 103}
95 104
96 105