]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix some exec builtin duplicate error messages; add LIBRARY_SOURCE back to tags and...
authorChet Ramey <chet.ramey@case.edu>
Fri, 1 Nov 2024 18:12:16 +0000 (14:12 -0400)
committerChet Ramey <chet.ramey@case.edu>
Fri, 1 Nov 2024 18:12:16 +0000 (14:12 -0400)
.gitignore
CWRU/CWRU.chlog
Makefile.in
builtins/exec.def
lib/sh/Makefile.in
tests/exec.right
tests/exec16.sub
tests/exec3.sub
variables.c

index aabc4c1061ccf94df656a6521cd89cc5fe342d59..2e75295127280be65b8ebad6bf615bc44991e8c5 100644 (file)
@@ -17,6 +17,7 @@
 .*~
 
 config.h
+buildconf.h
 config.status
 config.cache
 config.log
index 268b4781cc9eecde3381a919cb61b46cef0b1b9b..39b971f466864860573b4f6cf5334414ff66a453 100644 (file)
@@ -10555,3 +10555,14 @@ configure.ac,Makefile.in,support/Makefile.in,doc/Makefile.in
        - remove some unused variables: BASE_CFLAGS_FOR_BUILD, DEBUGGER_DIR,
          INTLOBJS, TEXINDEX, TEX, MALLOC, SIGNAMES_SUPPORT
          From a report by Martin D Kealey <martin@kurahaupo.gen.nz>
+
+                                  10/28
+                                  -----
+builtins/exec.def
+       - exec_builtin: don't try to print an error message in the cases
+         where shell_execve prints one, in case we have execfail set
+         Report from Emanuele Torre <torreemanuele6@gmail.com>
+
+Makefile.in
+       - LIBRARY_SOURCE: add back in to tags targets, add definition
+         Suggestion from Mike Jonkmans <bashbug@jonkmans.nl>
index 8b62b13e6c4d89f07becc0501ede6f40c9acc90a..d55a1843d9d20a24229f4954d861aeda41f9136a 100644 (file)
@@ -463,6 +463,9 @@ LIBDEP = $(GLOB_DEP) $(SHLIB_DEP) $(INTL_DEP) $(READLINE_DEP) $(HISTORY_DEP) \
 LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(GLOB_LDFLAGS) \
                  $(TILDE_LDFLAGS) $(MALLOC_LDFLAGS) $(SHLIB_LDFLAGS)
 
+LIBRARY_SOURCE = $(SHLIB_SOURCE) $(GLOB_SOURCE) \
+       $(READLINE_SOURCE) $(MALLOC_SOURCE)
+
 #
 # The shell itself
 #
@@ -875,11 +878,11 @@ info dvi ps: force
 force:
 
 # unused
-TAGS:  $(SOURCES) $(BUILTIN_C_SRC)
-       ( cd $(topdir) && $(ETAGS) $(ETAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) )
+TAGS:  $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
+       ( cd $(topdir) && $(ETAGS) $(ETAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) )
 
-tags:  $(SOURCES) $(BUILTIN_C_SRC)
-       ( cd $(topdir) && $(CTAGS) $(CTAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) )
+tags:  $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
+       ( cd $(topdir) && $(CTAGS) $(CTAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) )
 
 # Targets that actually do things not part of the build
 
index 618882c80c5cb4884eba9cec02ff38eb29c2b8f3..461864b5b5039b1b96ded91bae836c1fdc5d4ce0 100644 (file)
@@ -233,16 +233,23 @@ exec_builtin (WORD_LIST *list)
   if (cleanenv == 0)
     adjust_shell_level (1);
 
-  if (exit_value == EX_NOTFOUND)       /* no duplicate error message */
+  /* These are the return statuses for which shell_execve will print a message. */
+  if (exit_value == EX_NOTFOUND || exit_value == EX_BINARY_FILE || exit_value == EX_NOEXEC)
     goto failed_exec;
-  else if (executable_file (command) == 0)
+  /* These are the errno values for which shell_execve will print a message. */
+#if defined (EISDIR)
+  else if (opt == EISDIR || opt == E2BIG || opt == ENOMEM)
+#else
+  else if (opt == E2BIG || opt == ENOMEM)
+#endif
+    goto failed_exec;
+  else /* catchall */
     {
+      builtin_error ("%s: %s: %s", command, _("cannot execute"), strerror (opt));
+      if (executable_file (command) == 0)
+       exit_value = EX_NOEXEC; /* As per Posix.2, 3.14.6 */
       errno = opt;
-      builtin_error ("%s: %s: %s", command, _("cannot execute"), strerror (errno));
-      exit_value = EX_NOEXEC;  /* As per Posix.2, 3.14.6 */
     }
-  else
-    file_error (command);
 
 failed_exec:
   FREE (command);
index dc7ccbec11ebf48dc997644ac36802137f824d9e..8e658cd31f35141c15e61d01319710dd0cbecaf4 100644 (file)
@@ -144,8 +144,8 @@ mostlyclean: clean
 
 # Dependencies
 
-${BUILD_DIR}/version.h: ${BUILD_DIR}/config.h ${BUILD_DIR}/Makefile Makefile
-       -( cd ${BUILD_DIR} && ${MAKE} ${BASH_MAKEFLAGS} version.h )
+#${BUILD_DIR}/version.h: ${BUILD_DIR}/config.h ${BUILD_DIR}/Makefile Makefile
+#      -( cd ${BUILD_DIR} && ${MAKE} ${BASH_MAKEFLAGS} version.h )
 
 ${BUILD_DIR}/pathnames.h: ${BUILD_DIR}/config.h ${BUILD_DIR}/Makefile Makefile
        -( cd ${BUILD_DIR} && ${MAKE} ${BASH_MAKEFLAGS} pathnames.h )
index e65d8cbf6516f972d82bcc8bf7e83b43d11eb27d..0e908d9428707f7c7ef5d61511fda3aaf91c2461 100644 (file)
@@ -29,8 +29,9 @@ trap -- 'echo EXIT' EXIT
 trap -- '' SIGTERM
 trap -- 'echo USR1' SIGUSR1
 USR1
-./exec3.sub: line 27: /tmp/bash-notthere: No such file or directory
-./exec3.sub: after failed exec: 127
+./exec3.sub: line 38: /tmp/bash-notthere: No such file or directory
+./exec3.sub: ENOENT: after failed exec: 127
+./exec3.sub: line 43: exec: bash-notthere: not found
 trap -- 'echo EXIT' EXIT
 trap -- '' SIGTERM
 trap -- 'echo USR1' SIGUSR1
index e9d803042baf724fa948a9b17302551b1f3e97d4..3695fdeb217aefe10e0627752bb8b920bffd0656 100644 (file)
@@ -10,6 +10,7 @@ set +e
 set +e
 
 ! { set -e ; false ; echo reached async group; } &
+wait
 set +e
 
 set -e
index 81b53b72bd88340e6b8395d502ff677ae96c5bf3..0def1bd87f8674b30c797bd6d0e06df7bd3a5ef7 100644 (file)
 # added tests for changes in 10/2021 for preserving the traps across a failed
 # exec
 
+: ${THIS_SH:=./bash}
+: ${TMPDIR:=/var/tmp}
+TDIR=$TMPDIR/execdir-$$
+
+mkdir $TDIR || exit 1
+cp $THIS_SH $TDIR || exit 1
+cd $TDIR || exit 1
+
 shopt -s execfail
 
 trap 'echo EXIT' EXIT 
@@ -24,14 +32,63 @@ trap
 
 kill -s USR1 $$                # should run the trap
 
+# ENOENT -- No such file or directory
+# full pathname
+rm -f /tmp/bash-notthere
 exec /tmp/bash-notthere
-
 # make sure we're still around
-echo $0: after failed exec: $?
+echo $0: ENOENT: after failed exec: $?
+# relative pathname
+rm -f bash-notthere
+exec bash-notthere 
+
+# EACCES - permission denied
+rm -f x.sh x.output
+echo 'echo bar' > x.sh
+exec ./x.sh 2>x.output
+string=$(< x.output)
+# check for right error message and that we survived the failed exec
+case $string in
+*denied)       ;;
+*)     echo "$0: EACCES: error message mismatch: $string" ;;
+esac
+rm -f x.sh x.output
+
+# E2BIG - Argument list too long
+unset BASH_ENV
+
+rm -f x.sh x.output
+echo "export var='$(echo {1..1000500})' ;
+exec ${THIS_SH}" > ./x.sh
+chmod 755 ./x.sh
+${THIS_SH} ./x.sh 2>x.output
+string=$(< x.output)
+# check for right error message and that we survived the failed exec
+case $string in
+*list\ too\ long)      ;;
+*)     echo "$0: E2BIG: error message mismatch: $string" ;;
+esac
+rm -f x.sh x.output
+
+# EISDIR - is a directory
+rm -f x.sh x.output
+mkdir xdir-$$
+exec ./xdir-$$ 2>x.output
+rmdir ./xdir-$$
+string=$(< x.output)
+# check for right error message and that we survived the failed exec
+case $string in
+*[Ii]s\ a\ directory)  ;;
+*)     echo "$0: EISDIR: error message mismatch: $string" ;;
+esac
+rm -f x.sh x.output
 
 trap
 kill -s USR1 $$                # should run the trap
 kill -s TERM $$                # should still be ignored
 
+cd $OLDPWD
+rm -rf $TDIR
+
 # this should run the exit trap
 exit 0
index f1f7f51116790aac11809f14d0ccfd3d0509f9f4..3639487f9952e25cbaa9b4eec639af23be93641d 100644 (file)
@@ -59,8 +59,6 @@
 #include "alias.h"
 #include "jobs.h"
 
-#include "version.h"
-
 #include "builtins/getopt.h"
 #include "builtins/common.h"
 #include "builtins/builtext.h"
@@ -6472,7 +6470,7 @@ sv_shcompat (const char *name)
     {
 compat_error:
       internal_error (_("%s: %s: compatibility value out of range"), name, val);
-      shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
+      shell_compatibility_level = default_compatibility_level;
       set_compatibility_opts ();
       return;
     }