fix some exec builtin duplicate error messages; add LIBRARY_SOURCE back to tags and TAGS make targets

This commit is contained in:
Chet Ramey
2024-11-01 14:12:16 -04:00
parent 4917f2859c
commit fffa5d0e7c
9 changed files with 98 additions and 19 deletions
+1
View File
@@ -17,6 +17,7 @@
.*~
config.h
buildconf.h
config.status
config.cache
config.log
+11
View 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>
+7 -4
View 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
+13 -6
View 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);
+2 -2
View 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 )
+3 -2
View 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
+1
View File
@@ -10,6 +10,7 @@ set +e
set +e
! { set -e ; false ; echo reached async group; } &
wait
set +e
set -e
+59 -2
View File
@@ -15,6 +15,14 @@
# 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
+1 -3
View 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;
}