diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-21 15:24:12 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-21 15:24:12 +0200 |
commit | 73e013fca7afd2edc9ba8530df77c8210a14700b (patch) | |
tree | cee35b3493f12565fd20100be1ea2da4a6a86baf /shell/hush.c | |
parent | a88585a931c7e81d4d3d393127d8ad8c0fe73fb5 (diff) | |
download | busybox-w32-73e013fca7afd2edc9ba8530df77c8210a14700b.tar.gz busybox-w32-73e013fca7afd2edc9ba8530df77c8210a14700b.tar.bz2 busybox-w32-73e013fca7afd2edc9ba8530df77c8210a14700b.zip |
hush: handle ${var:NUM:} too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c index 945077d87..6cf8899b0 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -2649,12 +2649,17 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char | |||
2649 | beg = bb_strtou(exp_word, &end, 0); | 2649 | beg = bb_strtou(exp_word, &end, 0); |
2650 | //bb_error_msg("beg:'%s'=%u end:'%s'", exp_word, beg, end); | 2650 | //bb_error_msg("beg:'%s'=%u end:'%s'", exp_word, beg, end); |
2651 | if (*end == ':') { | 2651 | if (*end == ':') { |
2652 | len = bb_strtou(end + 1, &end, 0); | 2652 | if (end[1] != '\0') /* not ${var:NUM:} */ |
2653 | len = bb_strtou(end + 1, &end, 0); | ||
2654 | else { | ||
2655 | len = 0; | ||
2656 | end++; | ||
2657 | } | ||
2653 | //bb_error_msg("len:%u end:'%s'", len, end); | 2658 | //bb_error_msg("len:%u end:'%s'", len, end); |
2654 | } | 2659 | } |
2655 | if (*end == '\0') { | 2660 | if (*end == '\0') { |
2656 | //bb_error_msg("from val:'%s'", val); | 2661 | //bb_error_msg("from val:'%s'", val); |
2657 | if (!val || beg >= strlen(val)) | 2662 | if (len == 0 || !val || beg >= strlen(val)) |
2658 | val = ""; | 2663 | val = ""; |
2659 | else | 2664 | else |
2660 | val = dyn_val = xstrndup(val + beg, len); | 2665 | val = dyn_val = xstrndup(val + beg, len); |
@@ -2663,6 +2668,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char | |||
2663 | #endif | 2668 | #endif |
2664 | { | 2669 | { |
2665 | die_if_script("malformed ${%s...}", var); | 2670 | die_if_script("malformed ${%s...}", var); |
2671 | val = ""; | ||
2666 | } | 2672 | } |
2667 | } else { /* one of "-=+?" */ | 2673 | } else { /* one of "-=+?" */ |
2668 | /* Standard-mandated substitution ops: | 2674 | /* Standard-mandated substitution ops: |