ash/hush: provide help text
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 7 Mar 2011 11:34:59 +0000 (12:34 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 7 Mar 2011 11:34:59 +0000 (12:34 +0100)
$ ./busybox ash --help
BusyBox v1.19.0.git (2011-03-07 11:25:29 CET) multi-call binary.

Usage: ash [-/+OPTCHARS] [-/+o OPTNAME]... [-c 'SCRIPT' [ARG0 [ARGS]] / SCRIPT_FILE [ARGS]]

Unix shell interpreter

$ ./busybox hush --help
BusyBox v1.19.0.git (2011-03-07 11:25:29 CET) multi-call binary.

Usage: hush [-nx] [-c 'SCRIPT' [ARG0 [ARGS]] / SCRIPT_FILE [ARGS]]

Unix shell interpreter

function                                             old     new   delta
packed_usage                                       28163   28212     +49
setcmd                                                85      78      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 49/-7)              Total: 42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c
shell/hush.c

index 09db046fe6e6f93c0bdc349dd26cfea1eed84364..bfbd60d78cbd4efd892c60ec0085620e7a6ffa13 100644 (file)
 //config:        variable each time it is displayed.
 //config:
 
-//usage:#define ash_trivial_usage NOUSAGE_STR
-//usage:#define ash_full_usage ""
-//usage:#define sh_trivial_usage NOUSAGE_STR
-//usage:#define sh_full_usage ""
-//usage:#define bash_trivial_usage NOUSAGE_STR
-//usage:#define bash_full_usage ""
-
 
 /* ============ Hash table sizes. Configurable. */
 
@@ -10155,6 +10148,7 @@ setoption(int flag, int val)
        /* NOTREACHED */
 }
 static int
+
 options(int cmdline)
 {
        char *p;
@@ -10180,7 +10174,7 @@ options(int cmdline)
                                        else if (*argptr == NULL)
                                                setparam(argptr);
                                }
-                               break;    /* "-" or  "--" terminates options */
+                               break;    /* "-" or "--" terminates options */
                        }
                }
                /* first char was + or - */
@@ -10282,10 +10276,10 @@ setcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
 
        if (!argv[1])
                return showvars(nullstr, 0, VUNSET);
+
        INT_OFF;
-       retval = 1;
-       if (!options(0)) { /* if no parse error... */
-               retval = 0;
+       retval = options(/*cmdline:*/ 0);
+       if (retval == 0) { /* if no parse error... */
                optschanged();
                if (*argptr != NULL) {
                        setparam(argptr);
@@ -12938,14 +12932,32 @@ init(void)
                setvar("PPID", utoa(getppid()), 0);
 
                p = lookupvar("PWD");
-               if (p)
+               if (p) {
                        if (*p != '/' || stat(p, &st1) || stat(".", &st2)
-                        || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
+                        || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino
+                       ) {
                                p = '\0';
+                       }
+               }
                setpwd(p, 0);
        }
 }
 
+
+//usage:#define ash_trivial_usage
+//usage:       "[-/+OPTCHARS] [-/+o OPTNAME]... [-c 'SCRIPT' [ARG0 [ARGS]] / SCRIPT_FILE [ARGS]]"
+//usage:#define ash_full_usage "\n\n"
+//usage:       "Unix shell interpreter"
+
+//usage:#if ENABLE_FEATURE_SH_IS_ASH
+//usage:# define sh_trivial_usage ash_trivial_usage
+//usage:# define sh_full_usage    ash_full_usage
+//usage:#endif
+//usage:#if ENABLE_FEATURE_BASH_IS_ASH
+//usage:# define bash_trivial_usage ash_trivial_usage
+//usage:# define bash_full_usage    ash_full_usage
+//usage:#endif
+
 /*
  * Process the shell command line arguments.
  */
@@ -12963,7 +12975,7 @@ procargs(char **argv)
        for (i = 0; i < NOPTS; i++)
                optlist[i] = 2;
        argptr = xargv;
-       if (options(1)) {
+       if (options(/*cmdline:*/ 1)) {
                /* it already printed err message */
                raise_exception(EXERROR);
        }
index 4d9e5f8c7c7dc928159fc140b922f08978eafc67..6b3dc46d4c379dd1a26df82f97607f586e8ab1c0 100644 (file)
  * therefore we don't show them either.
  */
 //usage:#define hush_trivial_usage
-//usage:       "[-nx] [-c SCRIPT]"
-//usage:#define hush_full_usage ""
+//usage:       "[-nx] [-c 'SCRIPT' [ARG0 [ARGS]] / SCRIPT_FILE [ARGS]]"
+//usage:#define hush_full_usage "\n\n"
+//usage:       "Unix shell interpreter"
+
 //usage:#define msh_trivial_usage hush_trivial_usage
-//usage:#define msh_full_usage ""
-//usage:#define sh_trivial_usage NOUSAGE_STR
-//usage:#define sh_full_usage ""
-//usage:#define bash_trivial_usage NOUSAGE_STR
-//usage:#define bash_full_usage ""
+//usage:#define msh_full_usage hush_full_usage
+
+//usage:#if ENABLE_FEATURE_SH_IS_HUSH
+//usage:# define sh_trivial_usage hush_trivial_usage
+//usage:# define sh_full_usage    hush_full_usage
+//usage:#endif
+//usage:#if ENABLE_FEATURE_BASH_IS_HUSH
+//usage:# define bash_trivial_usage hush_trivial_usage
+//usage:# define bash_full_usage    hush_full_usage
+//usage:#endif
 
 
 /* Build knobs */