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) | |
download | busybox-w32-b0b834342ffece7f3debd8c7199a07ce8a6d942c.tar.gz busybox-w32-b0b834342ffece7f3debd8c7199a07ce8a6d942c.tar.bz2 busybox-w32-b0b834342ffece7f3debd8c7199a07ce8a6d942c.zip |
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 @@ | |||
190 | //config: variable each time it is displayed. | 190 | //config: variable each time it is displayed. |
191 | //config: | 191 | //config: |
192 | 192 | ||
193 | //usage:#define ash_trivial_usage NOUSAGE_STR | ||
194 | //usage:#define ash_full_usage "" | ||
195 | //usage:#define sh_trivial_usage NOUSAGE_STR | ||
196 | //usage:#define sh_full_usage "" | ||
197 | //usage:#define bash_trivial_usage NOUSAGE_STR | ||
198 | //usage:#define bash_full_usage "" | ||
199 | |||
200 | 193 | ||
201 | /* ============ Hash table sizes. Configurable. */ | 194 | /* ============ Hash table sizes. Configurable. */ |
202 | 195 | ||
@@ -10155,6 +10148,7 @@ setoption(int flag, int val) | |||
10155 | /* NOTREACHED */ | 10148 | /* NOTREACHED */ |
10156 | } | 10149 | } |
10157 | static int | 10150 | static int |
10151 | |||
10158 | options(int cmdline) | 10152 | options(int cmdline) |
10159 | { | 10153 | { |
10160 | char *p; | 10154 | char *p; |
@@ -10180,7 +10174,7 @@ options(int cmdline) | |||
10180 | else if (*argptr == NULL) | 10174 | else if (*argptr == NULL) |
10181 | setparam(argptr); | 10175 | setparam(argptr); |
10182 | } | 10176 | } |
10183 | break; /* "-" or "--" terminates options */ | 10177 | break; /* "-" or "--" terminates options */ |
10184 | } | 10178 | } |
10185 | } | 10179 | } |
10186 | /* first char was + or - */ | 10180 | /* first char was + or - */ |
@@ -10282,10 +10276,10 @@ setcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
10282 | 10276 | ||
10283 | if (!argv[1]) | 10277 | if (!argv[1]) |
10284 | return showvars(nullstr, 0, VUNSET); | 10278 | return showvars(nullstr, 0, VUNSET); |
10279 | |||
10285 | INT_OFF; | 10280 | INT_OFF; |
10286 | retval = 1; | 10281 | retval = options(/*cmdline:*/ 0); |
10287 | if (!options(0)) { /* if no parse error... */ | 10282 | if (retval == 0) { /* if no parse error... */ |
10288 | retval = 0; | ||
10289 | optschanged(); | 10283 | optschanged(); |
10290 | if (*argptr != NULL) { | 10284 | if (*argptr != NULL) { |
10291 | setparam(argptr); | 10285 | setparam(argptr); |
@@ -12938,14 +12932,32 @@ init(void) | |||
12938 | setvar("PPID", utoa(getppid()), 0); | 12932 | setvar("PPID", utoa(getppid()), 0); |
12939 | 12933 | ||
12940 | p = lookupvar("PWD"); | 12934 | p = lookupvar("PWD"); |
12941 | if (p) | 12935 | if (p) { |
12942 | if (*p != '/' || stat(p, &st1) || stat(".", &st2) | 12936 | if (*p != '/' || stat(p, &st1) || stat(".", &st2) |
12943 | || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) | 12937 | || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino |
12938 | ) { | ||
12944 | p = '\0'; | 12939 | p = '\0'; |
12940 | } | ||
12941 | } | ||
12945 | setpwd(p, 0); | 12942 | setpwd(p, 0); |
12946 | } | 12943 | } |
12947 | } | 12944 | } |
12948 | 12945 | ||
12946 | |||
12947 | //usage:#define ash_trivial_usage | ||
12948 | //usage: "[-/+OPTCHARS] [-/+o OPTNAME]... [-c 'SCRIPT' [ARG0 [ARGS]] / SCRIPT_FILE [ARGS]]" | ||
12949 | //usage:#define ash_full_usage "\n\n" | ||
12950 | //usage: "Unix shell interpreter" | ||
12951 | |||
12952 | //usage:#if ENABLE_FEATURE_SH_IS_ASH | ||
12953 | //usage:# define sh_trivial_usage ash_trivial_usage | ||
12954 | //usage:# define sh_full_usage ash_full_usage | ||
12955 | //usage:#endif | ||
12956 | //usage:#if ENABLE_FEATURE_BASH_IS_ASH | ||
12957 | //usage:# define bash_trivial_usage ash_trivial_usage | ||
12958 | //usage:# define bash_full_usage ash_full_usage | ||
12959 | //usage:#endif | ||
12960 | |||
12949 | /* | 12961 | /* |
12950 | * Process the shell command line arguments. | 12962 | * Process the shell command line arguments. |
12951 | */ | 12963 | */ |
@@ -12963,7 +12975,7 @@ procargs(char **argv) | |||
12963 | for (i = 0; i < NOPTS; i++) | 12975 | for (i = 0; i < NOPTS; i++) |
12964 | optlist[i] = 2; | 12976 | optlist[i] = 2; |
12965 | argptr = xargv; | 12977 | argptr = xargv; |
12966 | if (options(1)) { | 12978 | if (options(/*cmdline:*/ 1)) { |
12967 | /* it already printed err message */ | 12979 | /* it already printed err message */ |
12968 | raise_exception(EXERROR); | 12980 | raise_exception(EXERROR); |
12969 | } | 12981 | } |
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 @@ | |||
255 | * therefore we don't show them either. | 255 | * therefore we don't show them either. |
256 | */ | 256 | */ |
257 | //usage:#define hush_trivial_usage | 257 | //usage:#define hush_trivial_usage |
258 | //usage: "[-nx] [-c SCRIPT]" | 258 | //usage: "[-nx] [-c 'SCRIPT' [ARG0 [ARGS]] / SCRIPT_FILE [ARGS]]" |
259 | //usage:#define hush_full_usage "" | 259 | //usage:#define hush_full_usage "\n\n" |
260 | //usage: "Unix shell interpreter" | ||
261 | |||
260 | //usage:#define msh_trivial_usage hush_trivial_usage | 262 | //usage:#define msh_trivial_usage hush_trivial_usage |
261 | //usage:#define msh_full_usage "" | 263 | //usage:#define msh_full_usage hush_full_usage |
262 | //usage:#define sh_trivial_usage NOUSAGE_STR | 264 | |
263 | //usage:#define sh_full_usage "" | 265 | //usage:#if ENABLE_FEATURE_SH_IS_HUSH |
264 | //usage:#define bash_trivial_usage NOUSAGE_STR | 266 | //usage:# define sh_trivial_usage hush_trivial_usage |
265 | //usage:#define bash_full_usage "" | 267 | //usage:# define sh_full_usage hush_full_usage |
268 | //usage:#endif | ||
269 | //usage:#if ENABLE_FEATURE_BASH_IS_HUSH | ||
270 | //usage:# define bash_trivial_usage hush_trivial_usage | ||
271 | //usage:# define bash_full_usage hush_full_usage | ||
272 | //usage:#endif | ||
266 | 273 | ||
267 | 274 | ||
268 | /* Build knobs */ | 275 | /* Build knobs */ |