diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-07 12:34:59 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-07 12:34:59 +0100 |
commit | b0b834342ffece7f3debd8c7199a07ce8a6d942c (patch) | |
tree | c7434ffd6577942730d4a9ec8a716a30a67d8dda | |
parent | aefe1c260ec5aa691e8b6f773c7fa393bfad0f7b (diff) |
ash/hush: provide help text
$ ./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>
-rw-r--r-- | shell/ash.c | 40 | ||||
-rw-r--r-- | shell/hush.c | 21 |
2 files changed, 40 insertions, 21 deletions
diff --git a/shell/ash.c b/shell/ash.c index 09db046fe..bfbd60d78 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -190,13 +190,6 @@ //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); } diff --git a/shell/hush.c b/shell/hush.c index 4d9e5f8c7..6b3dc46d4 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -255,14 +255,21 @@ * 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 */ |