aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-29 00:59:24 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-29 00:59:24 +0200
commitf128bdbbd7ab14146a45166d20348f7705888353 (patch)
treee831e3be3d1db5dbbb0484eb70af51b580c921ac
parentbe366e5afac1d9f5b3958bd3899a389308d5d9d3 (diff)
downloadbusybox-w32-f128bdbbd7ab14146a45166d20348f7705888353.tar.gz
busybox-w32-f128bdbbd7ab14146a45166d20348f7705888353.tar.bz2
busybox-w32-f128bdbbd7ab14146a45166d20348f7705888353.zip
shell: make standalone shell tab-complete "busybox"
function old new delta busybox_main - 624 +624 packed_usage 31758 31777 +19 applet_names 2638 2646 +8 applet_main 1528 1532 +4 applet_install_loc 191 192 +1 run_applet_and_exit 681 78 -603 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/1 up/down: 656/-603) Total: 53 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/appletlib.c23
-rw-r--r--libbb/lineedit.c4
2 files changed, 21 insertions, 6 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index b9fbbd1f2..7a1a7f005 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -760,11 +760,26 @@ static void install_links(const char *busybox UNUSED_PARAM,
760} 760}
761# endif 761# endif
762 762
763# if ENABLE_BUSYBOX
764static void run_applet_and_exit(const char *name, char **argv) NORETURN; 763static void run_applet_and_exit(const char *name, char **argv) NORETURN;
765 764
766/* If we were called as "busybox..." */ 765# if ENABLE_BUSYBOX
767static int busybox_main(char **argv) 766# if ENABLE_FEATURE_SH_STANDALONE && ENABLE_FEATURE_TAB_COMPLETION
767 /*
768 * Insert "busybox" into applet table as well.
769 * This makes standalone shell tab-complete this name too.
770 * (Otherwise having "busybox" in applet table is not necessary,
771 * there is other code which routes "busyboxANY_SUFFIX" name
772 * to busybox_main()).
773 */
774//usage:#define busybox_trivial_usage NOUSAGE_STR
775//usage:#define busybox_full_usage ""
776//applet:IF_BUSYBOX(IF_FEATURE_SH_STANDALONE(IF_FEATURE_TAB_COMPLETION(APPLET(busybox, BB_DIR_BIN, BB_SUID_MAYBE))))
777int busybox_main(int argc, char *argv[]) MAIN_EXTERNALLY_VISIBLE;
778# else
779# define busybox_main(argc,argv) busybox_main(argv)
780static
781# endif
782int busybox_main(int argc UNUSED_PARAM, char **argv)
768{ 783{
769 if (!argv[1]) { 784 if (!argv[1]) {
770 /* Called without arguments */ 785 /* Called without arguments */
@@ -937,7 +952,7 @@ static NORETURN void run_applet_and_exit(const char *name, char **argv)
937{ 952{
938# if ENABLE_BUSYBOX 953# if ENABLE_BUSYBOX
939 if (is_prefixed_with(name, "busybox")) 954 if (is_prefixed_with(name, "busybox"))
940 exit(busybox_main(argv)); 955 exit(busybox_main(/*unused:*/ 0, argv));
941# endif 956# endif
942# if NUM_APPLETS > 0 957# if NUM_APPLETS > 0
943 /* find_applet_by_name() search is more expensive, so goes second */ 958 /* find_applet_by_name() search is more expensive, so goes second */
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 2a5d4e704..e5721b063 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -776,7 +776,7 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
776 } 776 }
777 pf_len = strlen(pfind); 777 pf_len = strlen(pfind);
778 778
779#if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 779# if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1
780 if (type == FIND_EXE_ONLY && !dirbuf) { 780 if (type == FIND_EXE_ONLY && !dirbuf) {
781 const char *p = applet_names; 781 const char *p = applet_names;
782 782
@@ -787,7 +787,7 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
787 continue; 787 continue;
788 } 788 }
789 } 789 }
790#endif 790# endif
791 791
792 for (i = 0; i < npaths; i++) { 792 for (i = 0; i < npaths; i++) {
793 DIR *dir; 793 DIR *dir;