diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 7dd09a3f..e6d5ab51 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -14169,3 +14169,27 @@ parse.y - history_delimiting_chars: return "" for a blank line, since there's nothing to delimit with `;' + 6/21 + ---- +jobs.c + - wait_for: make sure to call restore_sigint_handler before returning + if we return out of the loop due to no children. Report from + Eduardo Bustamante + +subst.c + - expand_word_internal: if split_on_spaces is set, and the word is + unquoted, and IFS is null, split the results of the previous steps + on $' \t\n' instead of just ' '. This relies on the previous steps + quoting the portions of the word that should not be split. Fixes + bug reported by Kevin Brodsky + +expr.c + - evalexp: after running expr_unwind, make sure we reset expr_depth + to 0 for the next call + - expr_streval: if after a call to get_array_value (which can call + the expression evaluator recursively) we discover that expr_depth + is less than it was before we called it, we assume there has been + some kind of error and an expr_unwind, so we treat it as an + error and either longjmp back to the expression top level or return + 0 immediately. Fixes bug reported by Eduardo Bustamante + diff --git a/examples/loadables/head.c b/examples/loadables/head.c index 748bb83e..1edca6c5 100644 --- a/examples/loadables/head.c +++ b/examples/loadables/head.c @@ -117,6 +117,7 @@ head_builtin (list) return (EX_USAGE); } break; + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/id.c b/examples/loadables/id.c index 87733494..f857b547 100644 --- a/examples/loadables/id.c +++ b/examples/loadables/id.c @@ -91,6 +91,7 @@ id_builtin (list) case 'n': id_flags |= ID_USENAME; break; case 'r': id_flags |= ID_USEREAL; break; case 'u': id_flags |= ID_USERONLY; break; + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/ln.c b/examples/loadables/ln.c index a853bc99..93764a35 100644 --- a/examples/loadables/ln.c +++ b/examples/loadables/ln.c @@ -76,6 +76,7 @@ ln_builtin (list) case 'n': flags |= LN_NOFOLLOW; break; + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/mkdir.c b/examples/loadables/mkdir.c index 39ae07f9..767ad9eb 100644 --- a/examples/loadables/mkdir.c +++ b/examples/loadables/mkdir.c @@ -68,6 +68,7 @@ mkdir_builtin (list) case 'm': mode = list_optarg; break; + CASE_HELPOPT; default: builtin_usage(); return (EX_USAGE); diff --git a/examples/loadables/pathchk.c b/examples/loadables/pathchk.c index 85e8a04c..3d9173a8 100644 --- a/examples/loadables/pathchk.c +++ b/examples/loadables/pathchk.c @@ -112,6 +112,7 @@ pathchk_builtin (list) case 'p': pflag = 1; break; + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/print.c b/examples/loadables/print.c index e17597b3..0120dbf4 100644 --- a/examples/loadables/print.c +++ b/examples/loadables/print.c @@ -122,6 +122,7 @@ print_builtin (list) case 'f': pfmt = list_optarg; break; + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/printenv.c b/examples/loadables/printenv.c index 8d3a05df..8c7f7201 100644 --- a/examples/loadables/printenv.c +++ b/examples/loadables/printenv.c @@ -46,6 +46,7 @@ printenv_builtin (list) { switch (opt) { + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/push.c b/examples/loadables/push.c index b0760733..9bcd5c32 100644 --- a/examples/loadables/push.c +++ b/examples/loadables/push.c @@ -51,6 +51,7 @@ push_builtin (list) { switch (opt) { + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/realpath.c b/examples/loadables/realpath.c index 1d82dd61..9892ddb8 100644 --- a/examples/loadables/realpath.c +++ b/examples/loadables/realpath.c @@ -86,6 +86,7 @@ WORD_LIST *list; case 'v': vflag = 1; break; + CASE_HELPOPT; default: builtin_usage(); return (EX_USAGE); diff --git a/examples/loadables/tee.c b/examples/loadables/tee.c index 9462cda0..819d83ae 100644 --- a/examples/loadables/tee.c +++ b/examples/loadables/tee.c @@ -84,6 +84,7 @@ tee_builtin (list) case 'i': nointr = 1; break; + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/template.c b/examples/loadables/template.c index 8cfd571d..094b80ce 100644 --- a/examples/loadables/template.c +++ b/examples/loadables/template.c @@ -31,6 +31,7 @@ template_builtin (list) { switch (opt) { + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/tty.c b/examples/loadables/tty.c index 1adc5b59..febf518b 100644 --- a/examples/loadables/tty.c +++ b/examples/loadables/tty.c @@ -46,6 +46,7 @@ tty_builtin (list) case 's': sflag = 1; break; + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/uname.c b/examples/loadables/uname.c index 339ec3dd..106a1c8d 100644 --- a/examples/loadables/uname.c +++ b/examples/loadables/uname.c @@ -95,6 +95,7 @@ uname_builtin (list) case 'v': uname_flags |= FLAG_VERSION; break; + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/examples/loadables/whoami.c b/examples/loadables/whoami.c index 5aa73828..3e7e36e4 100644 --- a/examples/loadables/whoami.c +++ b/examples/loadables/whoami.c @@ -39,6 +39,7 @@ whoami_builtin (list) { switch (opt) { + CASE_HELPOPT; default: builtin_usage (); return (EX_USAGE); diff --git a/expr.c b/expr.c index fee7a4aa..c51240f4 100644 --- a/expr.c +++ b/expr.c @@ -402,6 +402,7 @@ evalexp (expr, flags, validp) tokstr = expression = (char *)NULL; expr_unwind (); + expr_depth = 0; /* XXX - make sure */ /* We copy in case we've called evalexp recursively */ FASTCOPY (oevalbuf, evalbuf, sizeof (evalbuf)); @@ -1117,6 +1118,7 @@ expr_streval (tok, e, lvalue) SHELL_VAR *v; char *value; intmax_t tval; + int initial_depth; #if defined (ARRAY_VARS) arrayind_t ind; int tflag, aflag; @@ -1128,6 +1130,8 @@ expr_streval (tok, e, lvalue) if (noeval) return (0); + initial_depth = expr_depth; + #if defined (ARRAY_VARS) tflag = assoc_expand_once && already_expanded; /* for a start */ #endif @@ -1181,6 +1185,13 @@ expr_streval (tok, e, lvalue) value = get_variable_value (v); #endif + if (expr_depth < initial_depth) + { + if (no_longjmp_on_fatal_error && interactive_shell) + sh_longjmp (evalbuf, 1); + return (0); + } + tval = (value && *value) ? subexpr (value) : 0; if (lvalue) diff --git a/jobs.c b/jobs.c index c6d234b2..079e096f 100644 --- a/jobs.c +++ b/jobs.c @@ -2782,7 +2782,8 @@ itrace("wait_for: blocking wait for %d returns %d child = %p", (int)pid, r, chil if (r == -1 && errno == ECHILD && this_shell_builtin == wait_builtin) { termination_state = -1; - /* XXX - restore sigint handler here? */ + /* XXX - restore sigint handler here */ + restore_sigint_handler (); goto wait_for_return; } diff --git a/subst.c b/subst.c index 3093309f..0bea6c26 100644 --- a/subst.c +++ b/subst.c @@ -8984,6 +8984,8 @@ param_expand (string, sindex, quoted, expanded_something, else { temp = string_list_dollar_at (list, quoted, 0); + /* Set W_SPLITSPACE to make sure the individual positional + parameters are split into separate arguments */ if (quoted == 0 && (ifs_is_set == 0 || ifs_is_null)) tflag |= W_SPLITSPACE; /* If we're not quoted but we still don't want word splitting, make @@ -10158,7 +10160,16 @@ finished_with_string: or we expanded "$@" with IFS null and we need to split the positional parameters into separate words. */ if (split_on_spaces) - list = list_string (istring, " ", 1); /* XXX quoted == 1? */ + { + /* If IFS is not set, and the word is not quoted, we want to split + the individual words on $' \t\n'. We rely on previous steps to + quote the portions of the word that should not be split */ + if (ifs_is_set == 0) + list = list_string (istring, " \t\n", 1); /* XXX quoted == 1? */ + else + list = list_string (istring, " ", 1); /* XXX quoted == 1? */ + } + /* If we have $@ (has_dollar_at != 0) and we are in a context where we don't want to split the result (W_NOSPLIT2), and we are not quoted, we have already separated the arguments with the first character of