summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-20 21:51:38 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-20 21:51:38 +0000
commit14b5dd9943d7873d5184c64236b37407bff9baaa (patch)
tree4821f5580e27585bce7fda1020018f298489efa1 /shell/hush.c
parentfe52a74ecf895de3baaaccb863ad50467b336ea9 (diff)
downloadbusybox-w32-14b5dd9943d7873d5184c64236b37407bff9baaa.tar.gz
busybox-w32-14b5dd9943d7873d5184c64236b37407bff9baaa.tar.bz2
busybox-w32-14b5dd9943d7873d5184c64236b37407bff9baaa.zip
hush: make process substitution configurable; add a testcase
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index a462090c6..9c7fc8645 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -480,7 +480,9 @@ static int done_pipe(struct p_context *ctx, pipe_style type);
480/* primary string parsing: */ 480/* primary string parsing: */
481static int redirect_dup_num(struct in_str *input); 481static int redirect_dup_num(struct in_str *input);
482static int redirect_opt_num(o_string *o); 482static int redirect_opt_num(o_string *o);
483#if ENABLE_HUSH_TICK
483static int process_command_subs(o_string *dest, struct p_context *ctx, struct in_str *input, const char *subst_end); 484static int process_command_subs(o_string *dest, struct p_context *ctx, struct in_str *input, const char *subst_end);
485#endif
484static int parse_group(o_string *dest, struct p_context *ctx, struct in_str *input, int ch); 486static int parse_group(o_string *dest, struct p_context *ctx, struct in_str *input, int ch);
485static const char *lookup_param(const char *src); 487static const char *lookup_param(const char *src);
486static char *make_string(char **inp); 488static char *make_string(char **inp);
@@ -3054,6 +3056,7 @@ static int redirect_opt_num(o_string *o)
3054 return num; 3056 return num;
3055} 3057}
3056 3058
3059#if ENABLE_HUSH_TICK
3057static FILE *generate_stream_from_list(struct pipe *head) 3060static FILE *generate_stream_from_list(struct pipe *head)
3058{ 3061{
3059 FILE *pf; 3062 FILE *pf;
@@ -3131,6 +3134,7 @@ static int process_command_subs(o_string *dest, struct p_context *ctx,
3131 debug_printf("pclosed, retcode=%d\n", retcode); 3134 debug_printf("pclosed, retcode=%d\n", retcode);
3132 return retcode; 3135 return retcode;
3133} 3136}
3137#endif
3134 3138
3135static int parse_group(o_string *dest, struct p_context *ctx, 3139static int parse_group(o_string *dest, struct p_context *ctx,
3136 struct in_str *input, int ch) 3140 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
3262 } 3266 }
3263 b_addchr(dest, SPECIAL_VAR_SYMBOL); 3267 b_addchr(dest, SPECIAL_VAR_SYMBOL);
3264 break; 3268 break;
3269#if ENABLE_HUSH_TICK
3265 case '(': 3270 case '(':
3266 b_getch(input); 3271 b_getch(input);
3267 process_command_subs(dest, ctx, input, ")"); 3272 process_command_subs(dest, ctx, input, ")");
3268 break; 3273 break;
3274#endif
3269 case '-': 3275 case '-':
3270 case '_': 3276 case '_':
3271 /* still unhandled, but should be eventually */ 3277 /* still unhandled, but should be eventually */
@@ -3371,9 +3377,11 @@ static int parse_stream(o_string *dest, struct p_context *ctx,
3371 dest->nonnull = 1; 3377 dest->nonnull = 1;
3372 dest->quote = !dest->quote; 3378 dest->quote = !dest->quote;
3373 break; 3379 break;
3380#if ENABLE_HUSH_TICK
3374 case '`': 3381 case '`':
3375 process_command_subs(dest, ctx, input, "`"); 3382 process_command_subs(dest, ctx, input, "`");
3376 break; 3383 break;
3384#endif
3377 case '>': 3385 case '>':
3378 redir_fd = redirect_opt_num(dest); 3386 redir_fd = redirect_opt_num(dest);
3379 done_word(dest, ctx); 3387 done_word(dest, ctx);
@@ -3481,9 +3489,13 @@ static void update_charmap(void)
3481 * and on most machines that would be faster (reduced L1 cache use). 3489 * and on most machines that would be faster (reduced L1 cache use).
3482 */ 3490 */
3483 memset(charmap, CHAR_ORDINARY, sizeof(charmap)); 3491 memset(charmap, CHAR_ORDINARY, sizeof(charmap));
3492#if ENABLE_HUSH_TICK
3484 set_in_charmap("\\$\"`", CHAR_SPECIAL); 3493 set_in_charmap("\\$\"`", CHAR_SPECIAL);
3494#else
3495 set_in_charmap("\\$\"", CHAR_SPECIAL);
3496#endif
3485 set_in_charmap("<>;&|(){}#'", CHAR_ORDINARY_IF_QUOTED); 3497 set_in_charmap("<>;&|(){}#'", CHAR_ORDINARY_IF_QUOTED);
3486 set_in_charmap(ifs, CHAR_IFS); /* also flow through if quoted */ 3498 set_in_charmap(ifs, CHAR_IFS); /* are ordinary if quoted */
3487} 3499}
3488 3500
3489/* most recursion does not come through here, the exception is 3501/* most recursion does not come through here, the exception is