From f4b417c62a4f272c4cf9a074d0f7a3a97201f9db Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 17 Apr 2012 11:23:35 +0200 Subject: Update to upstream bash 4.2 This upgrades bash to from 4.1-rc to 4.2-release. See CWRU/changelog for changes. Change-Id: I926269c300cf44fa25964b5b375a148fcf11c4b7 --- builtins/exec.def | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'builtins/exec.def') diff --git a/builtins/exec.def b/builtins/exec.def index 0837a98..5d1e625 100644 --- a/builtins/exec.def +++ b/builtins/exec.def @@ -1,7 +1,7 @@ This file is exec.def, from which is created exec.c. It implements the builtin "exec" in Bash. -Copyright (C) 1987-2009 Free Software Foundation, Inc. +Copyright (C) 1987-2010 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -76,6 +76,7 @@ extern int errno; extern int subshell_environment; extern REDIRECT *redirection_undo_list; +extern char *exec_argv0; int no_exit_on_failed_exec; @@ -102,7 +103,7 @@ exec_builtin (list) char *argv0, *command, **args, **env, *newname, *com2; cleanenv = login = 0; - argv0 = (char *)NULL; + exec_argv0 = argv0 = (char *)NULL; reset_internal_getopt (); while ((opt = internal_getopt (list, "cla:")) != -1) @@ -147,8 +148,20 @@ exec_builtin (list) if (command == 0) { - sh_notfound (args[0]); - exit_value = EX_NOTFOUND; /* As per Posix.2, 3.14.6 */ + if (file_isdir (args[0])) + { +#if defined (EISDIR) + builtin_error (_("%s: cannot execute: %s"), args[0], strerror (EISDIR)); +#else + builtin_error (_("%s: cannot execute: %s"), args[0], strerror (errno)); +#endif + exit_value = EX_NOEXEC; + } + else + { + sh_notfound (args[0]); + exit_value = EX_NOTFOUND; /* As per Posix.2, 3.14.6 */ + } goto failed_exec; } @@ -164,6 +177,7 @@ exec_builtin (list) { free (args[0]); args[0] = login ? mkdashname (argv0) : savestring (argv0); + exec_argv0 = savestring (args[0]); } else if (login) { @@ -198,7 +212,7 @@ exec_builtin (list) end_job_control (); #endif /* JOB_CONTROL */ - shell_execve (command, args, env); + exit_value = shell_execve (command, args, env); /* We have to set this to NULL because shell_execve has called realloc() to stuff more items at the front of the array, which may have caused @@ -207,7 +221,9 @@ exec_builtin (list) if (cleanenv == 0) adjust_shell_level (1); - if (executable_file (command) == 0) + if (exit_value == EX_NOTFOUND) /* no duplicate error message */ + goto failed_exec; + else if (executable_file (command) == 0) { builtin_error (_("%s: cannot execute: %s"), command, strerror (errno)); exit_value = EX_NOEXEC; /* As per Posix.2, 3.14.6 */ -- cgit v1.1