diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-05 16:46:49 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-05 16:46:49 +0200 |
commit | f2ed39b93075f384f9e82f5130f94174b05dc300 (patch) | |
tree | 89a73d4f78c942e587571665c1b78305c1cfe698 /shell/hush.c | |
parent | d878ccca9cc2537f4046a618aa9122967aa2ce3a (diff) | |
download | busybox-w32-f2ed39b93075f384f9e82f5130f94174b05dc300.tar.gz busybox-w32-f2ed39b93075f384f9e82f5130f94174b05dc300.tar.bz2 busybox-w32-f2ed39b93075f384f9e82f5130f94174b05dc300.zip |
hush: implement "hush -s"
function old new delta
hush_main 1015 1031 +16
packed_usage 32757 32745 -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 16/-12) Total: 4 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r-- | shell/hush.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/shell/hush.c b/shell/hush.c index 577faf466..42e311839 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -312,13 +312,13 @@ | |||
312 | //kbuild:lib-$(CONFIG_BASH_IS_HUSH) += hush.o match.o shell_common.o | 312 | //kbuild:lib-$(CONFIG_BASH_IS_HUSH) += hush.o match.o shell_common.o |
313 | //kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o | 313 | //kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o |
314 | 314 | ||
315 | /* -i (interactive) and -s (read stdin) are also accepted, | 315 | /* -i (interactive) is also accepted, |
316 | * but currently do nothing, therefore aren't shown in help. | 316 | * but does nothing, therefore not shown in help. |
317 | * NOMMU-specific options are not meant to be used by users, | 317 | * NOMMU-specific options are not meant to be used by users, |
318 | * therefore we don't show them either. | 318 | * therefore we don't show them either. |
319 | */ | 319 | */ |
320 | //usage:#define hush_trivial_usage | 320 | //usage:#define hush_trivial_usage |
321 | //usage: "[-enxl] [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS]]" | 321 | //usage: "[-enxl] [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS] / -s [ARGS]]" |
322 | //usage:#define hush_full_usage "\n\n" | 322 | //usage:#define hush_full_usage "\n\n" |
323 | //usage: "Unix shell interpreter" | 323 | //usage: "Unix shell interpreter" |
324 | 324 | ||
@@ -9150,9 +9150,9 @@ int hush_main(int argc, char **argv) | |||
9150 | { | 9150 | { |
9151 | enum { | 9151 | enum { |
9152 | OPT_login = (1 << 0), | 9152 | OPT_login = (1 << 0), |
9153 | OPT_s = (1 << 1), | ||
9153 | }; | 9154 | }; |
9154 | unsigned flags; | 9155 | unsigned flags; |
9155 | int opt; | ||
9156 | unsigned builtin_argc; | 9156 | unsigned builtin_argc; |
9157 | char **e; | 9157 | char **e; |
9158 | struct variable *cur_var; | 9158 | struct variable *cur_var; |
@@ -9275,7 +9275,7 @@ int hush_main(int argc, char **argv) | |||
9275 | flags = (argv[0] && argv[0][0] == '-') ? OPT_login : 0; | 9275 | flags = (argv[0] && argv[0][0] == '-') ? OPT_login : 0; |
9276 | builtin_argc = 0; | 9276 | builtin_argc = 0; |
9277 | while (1) { | 9277 | while (1) { |
9278 | opt = getopt(argc, argv, "+c:exinsl" | 9278 | int opt = getopt(argc, argv, "+c:exinsl" |
9279 | #if !BB_MMU | 9279 | #if !BB_MMU |
9280 | "<:$:R:V:" | 9280 | "<:$:R:V:" |
9281 | # if ENABLE_HUSH_FUNCTIONS | 9281 | # if ENABLE_HUSH_FUNCTIONS |
@@ -9333,8 +9333,7 @@ int hush_main(int argc, char **argv) | |||
9333 | /* G_interactive_fd++; */ | 9333 | /* G_interactive_fd++; */ |
9334 | break; | 9334 | break; |
9335 | case 's': | 9335 | case 's': |
9336 | /* "-s" means "read from stdin", but this is how we always | 9336 | flags |= OPT_s; |
9337 | * operate, so simply do nothing here. */ | ||
9338 | break; | 9337 | break; |
9339 | case 'l': | 9338 | case 'l': |
9340 | flags |= OPT_login; | 9339 | flags |= OPT_login; |
@@ -9437,7 +9436,8 @@ int hush_main(int argc, char **argv) | |||
9437 | */ | 9436 | */ |
9438 | } | 9437 | } |
9439 | 9438 | ||
9440 | if (G.global_argv[1]) { | 9439 | /* -s is: hush -s ARGV1 ARGV2 (no SCRIPT) */ |
9440 | if (!(flags & OPT_s) && G.global_argv[1]) { | ||
9441 | FILE *input; | 9441 | FILE *input; |
9442 | /* | 9442 | /* |
9443 | * "bash <script>" (which is never interactive (unless -i?)) | 9443 | * "bash <script>" (which is never interactive (unless -i?)) |