aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-04-21 16:00:41 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-04-21 16:00:41 +0200
commitde5edadee2dca2896492f97ab3a56e389305e74d (patch)
tree80cdba9f7822f0ca9996dd1b5ceef0607c069c5d
parent7d86384b246434e72533332f7f409a7aa9efeacb (diff)
downloadbusybox-w32-de5edadee2dca2896492f97ab3a56e389305e74d.tar.gz
busybox-w32-de5edadee2dca2896492f97ab3a56e389305e74d.tar.bz2
busybox-w32-de5edadee2dca2896492f97ab3a56e389305e74d.zip
special-case {true,false,test} --help
This also removes their help texts. function old new delta run_applet_no_and_exit 442 452 +10 packed_usage 30713 30625 -88 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/false.c8
-rw-r--r--coreutils/test.c11
-rw-r--r--coreutils/true.c8
-rw-r--r--libbb/appletlib.c22
4 files changed, 21 insertions, 28 deletions
diff --git a/coreutils/false.c b/coreutils/false.c
index 59c2f321a..0591a6cdc 100644
--- a/coreutils/false.c
+++ b/coreutils/false.c
@@ -10,11 +10,9 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/000095399/utilities/false.html */ 11/* http://www.opengroup.org/onlinepubs/000095399/utilities/false.html */
12 12
13//usage:#define false_trivial_usage 13/* "false --help" is special-cased to ignore --help */
14//usage: "" 14//usage:#define false_trivial_usage NOUSAGE_STR
15//usage:#define false_full_usage "\n\n" 15//usage:#define false_full_usage ""
16//usage: "Return an exit code of FALSE (1)"
17//usage:
18//usage:#define false_example_usage 16//usage:#define false_example_usage
19//usage: "$ false\n" 17//usage: "$ false\n"
20//usage: "$ echo $?\n" 18//usage: "$ echo $?\n"
diff --git a/coreutils/test.c b/coreutils/test.c
index 88cc55050..7b8b10cd9 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -39,14 +39,9 @@
39//config: help 39//config: help
40//config: Enable 64-bit support in test. 40//config: Enable 64-bit support in test.
41 41
42/* "test --help" does not print help (POSIX compat), only "[ --help" does. 42/* "test --help" is special-cased to ignore --help */
43 * We display "<applet> EXPRESSION ]" here (not "<applet> EXPRESSION") 43//usage:#define test_trivial_usage NOUSAGE_STR
44 * Unfortunately, it screws up generated BusyBox.html. TODO. */ 44//usage:#define test_full_usage ""
45//usage:#define test_trivial_usage
46//usage: "EXPRESSION ]"
47//usage:#define test_full_usage "\n\n"
48//usage: "Check file types, compare values etc. Return a 0/1 exit code\n"
49//usage: "depending on logical value of EXPRESSION"
50//usage: 45//usage:
51//usage:#define test_example_usage 46//usage:#define test_example_usage
52//usage: "$ test 1 -eq 2\n" 47//usage: "$ test 1 -eq 2\n"
diff --git a/coreutils/true.c b/coreutils/true.c
index 382e476a8..89f892961 100644
--- a/coreutils/true.c
+++ b/coreutils/true.c
@@ -10,11 +10,9 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/true.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/true.html */
12 12
13//usage:#define true_trivial_usage 13/* "true --help" is special-cased to ignore --help */
14//usage: "" 14//usage:#define true_trivial_usage NOUSAGE_STR
15//usage:#define true_full_usage "\n\n" 15//usage:#define true_full_usage ""
16//usage: "Return an exit code of TRUE (0)"
17//usage:
18//usage:#define true_example_usage 16//usage:#define true_example_usage
19//usage: "$ true\n" 17//usage: "$ true\n"
20//usage: "$ echo $?\n" 18//usage: "$ echo $?\n"
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index e0b843d30..ba3d6e7a0 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -748,23 +748,25 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv)
748 xfunc_error_retval = EXIT_FAILURE; 748 xfunc_error_retval = EXIT_FAILURE;
749 applet_name = APPLET_NAME(applet_no); 749 applet_name = APPLET_NAME(applet_no);
750 750
751#if defined APPLET_NO_test
752 /* Special case. POSIX says "test --help" 751 /* Special case. POSIX says "test --help"
753 * should be no different from e.g. "test --foo". 752 * should be no different from e.g. "test --foo".
754 * Thus for "test", we skip --help check. 753 * Thus for "test", we skip --help check.
754 * "true" and "false" are also special.
755 */ 755 */
756 if (applet_no != APPLET_NO_test) 756 if (1
757#if defined APPLET_NO_test
758 && applet_no != APPLET_NO_test
759#endif
760#if defined APPLET_NO_true
761 && applet_no != APPLET_NO_true
757#endif 762#endif
758 {
759 if (argc == 2 && strcmp(argv[1], "--help") == 0) {
760#if defined APPLET_NO_false 763#if defined APPLET_NO_false
761 /* Someone insisted that "false --help" must exit 1. Sigh */ 764 && applet_no != APPLET_NO_false
762 if (applet_no != APPLET_NO_false)
763#endif 765#endif
764 { 766 ) {
765 /* Make "foo --help" exit with 0: */ 767 if (argc == 2 && strcmp(argv[1], "--help") == 0) {
766 xfunc_error_retval = 0; 768 /* Make "foo --help" exit with 0: */
767 } 769 xfunc_error_retval = 0;
768 bb_show_usage(); 770 bb_show_usage();
769 } 771 }
770 } 772 }