summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko2018-04-05 16:46:49 +0200
committerDenys Vlasenko2018-04-05 16:46:49 +0200
commitf2ed39b93075f384f9e82f5130f94174b05dc300 (patch)
tree89a73d4f78c942e587571665c1b78305c1cfe698 /shell/hush.c
parentd878ccca9cc2537f4046a618aa9122967aa2ce3a (diff)
downloadbusybox-f2ed39b93075f384f9e82f5130f94174b05dc300.zip
busybox-f2ed39b93075f384f9e82f5130f94174b05dc300.tar.gz
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 'shell/hush.c')
-rw-r--r--shell/hush.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 577faf4..42e3118 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -312,13 +312,13 @@
//kbuild:lib-$(CONFIG_BASH_IS_HUSH) += hush.o match.o shell_common.o
//kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o
-/* -i (interactive) and -s (read stdin) are also accepted,
- * but currently do nothing, therefore aren't shown in help.
+/* -i (interactive) is also accepted,
+ * but does nothing, therefore not shown in help.
* NOMMU-specific options are not meant to be used by users,
* therefore we don't show them either.
*/
//usage:#define hush_trivial_usage
-//usage: "[-enxl] [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS]]"
+//usage: "[-enxl] [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS] / -s [ARGS]]"
//usage:#define hush_full_usage "\n\n"
//usage: "Unix shell interpreter"
@@ -9150,9 +9150,9 @@ int hush_main(int argc, char **argv)
{
enum {
OPT_login = (1 << 0),
+ OPT_s = (1 << 1),
};
unsigned flags;
- int opt;
unsigned builtin_argc;
char **e;
struct variable *cur_var;
@@ -9275,7 +9275,7 @@ int hush_main(int argc, char **argv)
flags = (argv[0] && argv[0][0] == '-') ? OPT_login : 0;
builtin_argc = 0;
while (1) {
- opt = getopt(argc, argv, "+c:exinsl"
+ int opt = getopt(argc, argv, "+c:exinsl"
#if !BB_MMU
"<:$:R:V:"
# if ENABLE_HUSH_FUNCTIONS
@@ -9333,8 +9333,7 @@ int hush_main(int argc, char **argv)
/* G_interactive_fd++; */
break;
case 's':
- /* "-s" means "read from stdin", but this is how we always
- * operate, so simply do nothing here. */
+ flags |= OPT_s;
break;
case 'l':
flags |= OPT_login;
@@ -9437,7 +9436,8 @@ int hush_main(int argc, char **argv)
*/
}
- if (G.global_argv[1]) {
+ /* -s is: hush -s ARGV1 ARGV2 (no SCRIPT) */
+ if (!(flags & OPT_s) && G.global_argv[1]) {
FILE *input;
/*
* "bash <script>" (which is never interactive (unless -i?))