summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2007-05-20 21:51:38 +0000
committerDenis Vlasenko2007-05-20 21:51:38 +0000
commit14b5dd9943d7873d5184c64236b37407bff9baaa (patch)
tree4821f5580e27585bce7fda1020018f298489efa1
parentfe52a74ecf895de3baaaccb863ad50467b336ea9 (diff)
downloadbusybox-14b5dd9943d7873d5184c64236b37407bff9baaa.zip
busybox-14b5dd9943d7873d5184c64236b37407bff9baaa.tar.gz
hush: make process substitution configurable; add a testcase
-rw-r--r--shell/Config.in5
-rw-r--r--shell/hush.c14
-rw-r--r--shell/hush_test/hush-bugs/tick.right0
-rwxr-xr-xshell/hush_test/hush-bugs/tick.tests4
4 files changed, 22 insertions, 1 deletions
diff --git a/shell/Config.in b/shell/Config.in
index 253752b..99e395d 100644
--- a/shell/Config.in
+++ b/shell/Config.in
@@ -197,6 +197,11 @@ config HUSH_JOB
prompting for next command (or executing next command in a script),
but no separate process group is formed.
+config HUSH_TICK
+ bool "Process substitution"
+ default n
+ help
+ Enable process substitution `command` and $(command) in hush.
config LASH
bool "lash"
diff --git a/shell/hush.c b/shell/hush.c
index a462090..9c7fc86 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -480,7 +480,9 @@ static int done_pipe(struct p_context *ctx, pipe_style type);
/* primary string parsing: */
static int redirect_dup_num(struct in_str *input);
static int redirect_opt_num(o_string *o);
+#if ENABLE_HUSH_TICK
static int process_command_subs(o_string *dest, struct p_context *ctx, struct in_str *input, const char *subst_end);
+#endif
static int parse_group(o_string *dest, struct p_context *ctx, struct in_str *input, int ch);
static const char *lookup_param(const char *src);
static char *make_string(char **inp);
@@ -3054,6 +3056,7 @@ static int redirect_opt_num(o_string *o)
return num;
}
+#if ENABLE_HUSH_TICK
static FILE *generate_stream_from_list(struct pipe *head)
{
FILE *pf;
@@ -3131,6 +3134,7 @@ static int process_command_subs(o_string *dest, struct p_context *ctx,
debug_printf("pclosed, retcode=%d\n", retcode);
return retcode;
}
+#endif
static int parse_group(o_string *dest, struct p_context *ctx,
struct in_str *input, int ch)
@@ -3262,10 +3266,12 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i
}
b_addchr(dest, SPECIAL_VAR_SYMBOL);
break;
+#if ENABLE_HUSH_TICK
case '(':
b_getch(input);
process_command_subs(dest, ctx, input, ")");
break;
+#endif
case '-':
case '_':
/* still unhandled, but should be eventually */
@@ -3371,9 +3377,11 @@ static int parse_stream(o_string *dest, struct p_context *ctx,
dest->nonnull = 1;
dest->quote = !dest->quote;
break;
+#if ENABLE_HUSH_TICK
case '`':
process_command_subs(dest, ctx, input, "`");
break;
+#endif
case '>':
redir_fd = redirect_opt_num(dest);
done_word(dest, ctx);
@@ -3481,9 +3489,13 @@ static void update_charmap(void)
* and on most machines that would be faster (reduced L1 cache use).
*/
memset(charmap, CHAR_ORDINARY, sizeof(charmap));
+#if ENABLE_HUSH_TICK
set_in_charmap("\\$\"`", CHAR_SPECIAL);
+#else
+ set_in_charmap("\\$\"", CHAR_SPECIAL);
+#endif
set_in_charmap("<>;&|(){}#'", CHAR_ORDINARY_IF_QUOTED);
- set_in_charmap(ifs, CHAR_IFS); /* also flow through if quoted */
+ set_in_charmap(ifs, CHAR_IFS); /* are ordinary if quoted */
}
/* most recursion does not come through here, the exception is
diff --git a/shell/hush_test/hush-bugs/tick.right b/shell/hush_test/hush-bugs/tick.right
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/shell/hush_test/hush-bugs/tick.right
diff --git a/shell/hush_test/hush-bugs/tick.tests b/shell/hush_test/hush-bugs/tick.tests
new file mode 100755
index 0000000..1f749a9
--- /dev/null
+++ b/shell/hush_test/hush-bugs/tick.tests
@@ -0,0 +1,4 @@
+true
+false; echo `echo $?`
+true
+{ false; echo `echo $?`; }