mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-27 15:43:18 +02:00
fix for line numbers for nested function declarations; fix execve error for ENOENT
This commit is contained in:
@@ -4062,3 +4062,19 @@ parse.y
|
||||
execute_cmd.c
|
||||
- execute_cond_node: reset extended_glob to the value of extglob_flag,
|
||||
since we're executing a command here
|
||||
|
||||
10/8
|
||||
----
|
||||
parse.y
|
||||
- save_dstart: when we set the value of function_dstart, save the old
|
||||
value in save_dstart (read_token, read_token_word); restore it in
|
||||
the grammar production after calling make_function_def. This gives
|
||||
you correct line numbers for one level of function nesting.
|
||||
Report from Daniel Castro <danicc097@gmail.com>
|
||||
|
||||
10/10
|
||||
-----
|
||||
execute_cmd.c
|
||||
- shell_execve: rearrange code so that we check for a bad interpreter
|
||||
before printing a generic ENOENT error message. Report from
|
||||
Kirill Elagin <kirelagin@gmail.com>
|
||||
|
||||
+11
-7
@@ -5983,11 +5983,6 @@ shell_execve (command, args, env)
|
||||
errno = i;
|
||||
file_error (command);
|
||||
}
|
||||
else if (i == ENOENT)
|
||||
{
|
||||
errno = i;
|
||||
internal_error (_("%s: cannot execute: required file not found"), command);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The file has the execute bits set, but the kernel refuses to
|
||||
@@ -6015,9 +6010,18 @@ shell_execve (command, args, env)
|
||||
FREE (interp);
|
||||
return (EX_NOEXEC);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
errno = i;
|
||||
file_error (command);
|
||||
if (i == ENOENT)
|
||||
{
|
||||
errno = i;
|
||||
internal_error (_("%s: cannot execute: required file not found"), command);
|
||||
}
|
||||
else
|
||||
{
|
||||
errno = i;
|
||||
file_error (command);
|
||||
}
|
||||
}
|
||||
return (last_command_exit_value);
|
||||
}
|
||||
|
||||
@@ -4338,7 +4338,6 @@ notify_of_job_status ()
|
||||
if (termsig && WIFSIGNALED (s) && termsig != SIGINT && termsig != SIGPIPE)
|
||||
#endif
|
||||
{
|
||||
itrace("notify_of_job_status: printing status of foreground job %d", job);
|
||||
fprintf (stderr, "%s", j_strsignal (termsig));
|
||||
|
||||
if (WIFCORED (s))
|
||||
|
||||
@@ -846,6 +846,8 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
|
||||
case, we just want to compare the two as strings. */
|
||||
return (STRCOMPARE (p - 1, pe, s, se));
|
||||
|
||||
glob_recursion_depth++;
|
||||
|
||||
switch (xc)
|
||||
{
|
||||
case L('+'): /* match one or more occurrences */
|
||||
|
||||
@@ -60,6 +60,7 @@ extern int fnmatch (const char *, const char *, int);
|
||||
#endif
|
||||
|
||||
int glob_asciirange = GLOBASCII_DEFAULT;
|
||||
int glob_recursion_depth;
|
||||
|
||||
#if FNMATCH_EQUIV_FALLBACK
|
||||
/* Construct a string w1 = "c1" and a pattern w2 = "[[=c2=]]" and pass them
|
||||
@@ -609,6 +610,8 @@ xstrmatch (pattern, string, flags)
|
||||
wchar_t *wpattern, *wstring;
|
||||
size_t plen, slen, mplen, mslen;
|
||||
|
||||
glob_recursion_depth = 0;
|
||||
|
||||
if (MB_CUR_MAX == 1)
|
||||
return (internal_strmatch ((unsigned char *)pattern, (unsigned char *)string, flags));
|
||||
|
||||
@@ -633,6 +636,8 @@ xstrmatch (pattern, string, flags)
|
||||
|
||||
return ret;
|
||||
#else
|
||||
glob_recursion_depth = 0;
|
||||
|
||||
return (internal_strmatch ((unsigned char *)pattern, (unsigned char *)string, flags));
|
||||
#endif /* !HANDLE_MULTIBYTE */
|
||||
}
|
||||
|
||||
@@ -291,9 +291,11 @@ static int shell_input_line_terminator;
|
||||
|
||||
/* The line number in a script on which a function definition starts. */
|
||||
static int function_dstart;
|
||||
static int save_dstart = -1;
|
||||
|
||||
/* The line number in a script on which a function body starts. */
|
||||
static int function_bstart;
|
||||
static int save_bstart = -1;
|
||||
|
||||
/* The line number in a script at which an arithmetic for command starts. */
|
||||
static int arith_for_lineno;
|
||||
@@ -945,13 +947,13 @@ case_command: CASE WORD newline_list IN newline_list ESAC
|
||||
;
|
||||
|
||||
function_def: WORD '(' ')' newline_list function_body
|
||||
{ $$ = make_function_def ($1, $5, function_dstart, function_bstart); }
|
||||
{ $$ = make_function_def ($1, $5, function_dstart, function_bstart); function_dstart = save_dstart; }
|
||||
| FUNCTION WORD '(' ')' newline_list function_body
|
||||
{ $$ = make_function_def ($2, $6, function_dstart, function_bstart); }
|
||||
{ $$ = make_function_def ($2, $6, function_dstart, function_bstart); function_dstart = save_dstart; }
|
||||
| FUNCTION WORD function_body
|
||||
{ $$ = make_function_def ($2, $3, function_dstart, function_bstart); }
|
||||
{ $$ = make_function_def ($2, $3, function_dstart, function_bstart); function_dstart = save_dstart; }
|
||||
| FUNCTION WORD '\n' newline_list function_body
|
||||
{ $$ = make_function_def ($2, $5, function_dstart, function_bstart); }
|
||||
{ $$ = make_function_def ($2, $5, function_dstart, function_bstart); function_dstart = save_dstart; }
|
||||
;
|
||||
|
||||
function_body: shell_command
|
||||
@@ -3557,6 +3559,7 @@ read_token (command)
|
||||
#if defined (ALIAS)
|
||||
parser_state &= ~PST_ALEXPNEXT;
|
||||
#endif /* ALIAS */
|
||||
save_dstart = function_dstart;
|
||||
function_dstart = line_number;
|
||||
}
|
||||
|
||||
@@ -5319,6 +5322,7 @@ got_token:
|
||||
{
|
||||
case FUNCTION:
|
||||
parser_state |= PST_ALLOWOPNBRC;
|
||||
save_dstart = function_dstart;
|
||||
function_dstart = line_number;
|
||||
break;
|
||||
case CASE:
|
||||
|
||||
Reference in New Issue
Block a user