dont crash if the variable we do substitution on is not set
This commit is contained in:
parent
d68ae08cde
commit
57e746781c
26
shell/hush.c
26
shell/hush.c
@ -2025,18 +2025,20 @@ static int expand_vars_to_list(o_string *output, int n, char *arg, char or_mask)
|
|||||||
debug_printf_expand("%s\n", val);
|
debug_printf_expand("%s\n", val);
|
||||||
} else if (exp_off) {
|
} else if (exp_off) {
|
||||||
if (exp_op == '%' || exp_op == '#') {
|
if (exp_op == '%' || exp_op == '#') {
|
||||||
/* we need to do a pattern match */
|
if (val) {
|
||||||
bool zero;
|
/* we need to do a pattern match */
|
||||||
char *loc;
|
bool zero;
|
||||||
scan_t scan = pick_scan(exp_op, *exp_word, &zero);
|
char *loc;
|
||||||
if (exp_op == *exp_word) /* ## or %% */
|
scan_t scan = pick_scan(exp_op, *exp_word, &zero);
|
||||||
++exp_word;
|
if (exp_op == *exp_word) /* ## or %% */
|
||||||
val = dyn_val = xstrdup(val);
|
++exp_word;
|
||||||
loc = scan(dyn_val, exp_word, zero);
|
val = dyn_val = xstrdup(val);
|
||||||
if (zero)
|
loc = scan(dyn_val, exp_word, zero);
|
||||||
val = loc;
|
if (zero)
|
||||||
else
|
val = loc;
|
||||||
*loc = '\0';
|
else
|
||||||
|
*loc = '\0';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* we need to do an expansion */
|
/* we need to do an expansion */
|
||||||
int exp_test = (!val || (exp_null && !val[0]));
|
int exp_test = (!val || (exp_null && !val[0]));
|
||||||
|
Loading…
Reference in New Issue
Block a user