From db26b1cf58aab63c39fd5665590cad3cb75eab72 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Mon, 16 Sep 2019 15:31:57 -0400 Subject: [PATCH] commit bash-20190913 snapshot --- CWRU/CWRU.chlog | 30 ++++++++++++++ MANIFEST | 2 +- aclocal.m4 | 47 ++++++++++++++++++++-- configure | 82 +++++++++++++++++++++++++++++++------- configure.ac | 7 +++- execute_cmd.c | 3 +- m4/intdiv0.m4 | 6 +-- m4/intl.m4 | 3 ++ shell.c | 4 +- tests/precedence.tests | 90 ++++++++++++++++++++++++++++++++++++++++++ tests/procsub.right | 1 - tests/procsub.tests | 5 ++- tests/run-precedence | 2 +- 13 files changed, 251 insertions(+), 31 deletions(-) create mode 100755 tests/precedence.tests diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 67a00b97..441f21bb 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -6530,3 +6530,33 @@ bashline.c - edit_and_execute_command: reset the readahead token after calling restore_parser_state, in case some call to reset_parser set token_to_read. Fixes bug reported by null + + 9/9 + --- +execute_cmd.c + - execute_command_internal: if we're executing a command list + (executing_list != 0), save the old fifo list and close any new + FIFOs that the command opens. Fixes bug reported by + Kamil Cukrowski + + 9/10 + ---- +aclocal.m4,m4/intdiv0.m4 + - make sure `exit' is used consistently with included + - make sure `main' isn't declared to implicitly return int + - include before using ulimit + - include before testing string functions + - fixes from Florian Weimer + +configure.ac + - setresuid,setresgid: use AC_CHECK_FUNCS instead of AC_CHECK_DECL, + which always fails + +shell.c + - disable_priv_mode: use HAVE_SETRESUID and HAVE_SETRESGID instead of + the HAVE_DECL variants, which always fail configure tests + +m4/intl.m4 + - gt_INTL_SUBDIR_CORE: add back check for localeconv, removed in + newer gettext releases + diff --git a/MANIFEST b/MANIFEST index eaa6c60b..9180b5b4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1243,7 +1243,7 @@ tests/posixpat.right f tests/posixpipe.tests f tests/posixpipe.right f tests/prec.right f -tests/precedence f +tests/precedence.tests f tests/printf.tests f tests/printf.right f tests/printf1.sub f diff --git a/aclocal.m4 b/aclocal.m4 index c42dbf3b..a9627429 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -139,6 +139,7 @@ typedef int (*_bashfunc)(const char *, ...); typedef int (*_bashfunc)(); #endif #include +int main() { _bashfunc pf; @@ -200,6 +201,7 @@ AC_CACHE_VAL(bash_cv_under_sys_siglist, #ifndef UNDER_SYS_SIGLIST_DECLARED extern char *_sys_siglist[]; #endif +int main() { char *msg = (char *)_sys_siglist[2]; @@ -228,6 +230,7 @@ AC_CACHE_VAL(bash_cv_sys_siglist, #if !HAVE_DECL_SYS_SIGLIST extern char *sys_siglist[]; #endif +int main() { char *msg = sys_siglist[2]; @@ -281,6 +284,7 @@ AC_CACHE_VAL(bash_cv_dup2_broken, #include #include #include +int main() { int fd1, fd2, fl; @@ -308,7 +312,8 @@ AC_DEFUN(BASH_FUNC_STRSIGNAL, [AC_MSG_CHECKING([for the existence of strsignal]) AC_CACHE_VAL(bash_cv_have_strsignal, [AC_TRY_LINK([#include -#include ], +#include +#include ], [char *s = (char *)strsignal(2);], bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)]) AC_MSG_RESULT($bash_cv_have_strsignal) @@ -329,6 +334,9 @@ AC_CACHE_VAL(bash_cv_opendir_not_robust, #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ +#ifdef HAVE_SYS_STAT_H +#include +#endif #if defined(HAVE_DIRENT_H) # include #else @@ -344,6 +352,7 @@ AC_CACHE_VAL(bash_cv_opendir_not_robust, # endif #endif /* HAVE_DIRENT_H */ #include +int main() { DIR *dir; @@ -524,6 +533,7 @@ AC_TRY_RUN([ #include #include #include +int main() { #ifdef HAVE_QUAD_T @@ -609,6 +619,7 @@ getenv (name) { return "42"; } +int main() { char *s; @@ -695,6 +706,11 @@ AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS, [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize) AC_CACHE_VAL(bash_cv_ulimit_maxfds, [AC_TRY_RUN([ +#include +#ifdef HAVE_ULIMIT_H +#include +#endif +int main() { long maxfds = ulimit(4, 0L); @@ -718,7 +734,9 @@ AC_CACHE_VAL(bash_cv_getcwd_malloc, #ifdef HAVE_UNISTD_H #include #endif +#include +int main() { char *xpwd; @@ -768,12 +786,13 @@ AC_CACHE_VAL(bash_cv_fnm_extmatch, [AC_TRY_RUN([ #include +int main() { #ifdef FNM_EXTMATCH - exit (0); + return (0); #else - exit (1); + return (1); #endif } ], bash_cv_fnm_extmatch=yes, bash_cv_fnm_extmatch=no, @@ -799,6 +818,7 @@ AC_CACHE_VAL(bash_cv_func_sigsetjmp, #include #include +int main() { #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) @@ -847,7 +867,10 @@ AC_CACHE_VAL(bash_cv_func_strcoll_broken, #if defined (HAVE_LOCALE_H) #include #endif +#include +#include +int main(c, v) int c; char *v[]; @@ -947,6 +970,7 @@ AC_CACHE_VAL(bash_cv_struct_stat_st_blocks, #include ], [ +int main() { static struct stat a; @@ -1254,7 +1278,11 @@ AC_CACHE_VAL(bash_cv_pgrp_pipe, #ifdef HAVE_UNISTD_H # include #endif +#ifdef HAVE_SYS_WAIT_H +# include +#endif #include +int main() { # ifdef GETPGRP_VOID @@ -1350,6 +1378,7 @@ int s; nsigint++; } +int main() { nsigint = 0; @@ -1433,9 +1462,11 @@ AC_CACHE_VAL(bash_cv_sys_named_pipes, #ifdef HAVE_UNISTD_H #include #endif +#include #include /* Add more tests in here as appropriate. */ +int main() { int fd, err; @@ -1673,6 +1704,7 @@ AC_CACHE_VAL(bash_cv_unusable_rtsigs, # define NSIG 64 #endif +int main () { int n_sigs = 2 * NSIG; @@ -1787,6 +1819,7 @@ bash_cv_wcwidth_broken, #include #include +int main(c, v) int c; char **v; @@ -1855,6 +1888,7 @@ AC_CACHE_VAL(ac_cv_rl_version, extern int rl_gnu_readline_p; +int main() { FILE *fp; @@ -1944,7 +1978,9 @@ AC_CACHE_VAL(bash_cv_func_ctype_nonascii, #endif #include #include +#include +int main(c, v) int c; char *v[]; @@ -1987,10 +2023,12 @@ AC_CACHE_VAL(bash_cv_wcontinued_broken, #include #include #include +#include #ifndef errno extern int errno; #endif +int main() { int x; @@ -2058,6 +2096,7 @@ AC_DEFUN([BASH_FUNC_SNPRINTF], #include #include +int main() { int n; @@ -2114,6 +2153,7 @@ foo(format, va_alist) return n; } +int main() { int n; @@ -2143,6 +2183,7 @@ AC_CACHE_VAL(bash_cv_wexitstatus_offset, #include +int main(c, v) int c; char **v; diff --git a/configure b/configure index 088118ba..3a3aa332 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac for Bash 5.0, version 5.011. +# From configure.ac for Bash 5.0, version 5.014. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for bash 5.0-maint. # @@ -5396,6 +5396,7 @@ else extern int rl_gnu_readline_p; +int main() { FILE *fp; @@ -7886,13 +7887,13 @@ static void sigfpe_handler (int sig) { /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ - _exit (sig != SIGFPE); + exit (sig != SIGFPE); } int x = 1; int y = 0; int z; -int nan; +int xnan; int main () { @@ -7907,7 +7908,7 @@ int main () #endif z = x / y; - nan = y / y; + xnan = y / y; exit (2); } @@ -10665,6 +10666,18 @@ if eval test \"x\$"$as_ac_var"\" = x"yes"; then : #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF +fi +done + + + for ac_func in localeconv +do : + ac_fn_c_check_func "$LINENO" "localeconv" "ac_cv_func_localeconv" +if test "x$ac_cv_func_localeconv" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LOCALECONV 1 +_ACEOF + fi done @@ -14240,17 +14253,6 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SETREGID $ac_have_decl _ACEOF -ac_fn_c_check_decl "$LINENO" "" "ac_cv_have_decl_" "$ac_includes_default" -if test "x$ac_cv_have_decl_" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ $ac_have_decl -_ACEOF -(setresuid, setresgid) ac_fn_c_check_decl "$LINENO" "strcpy" "ac_cv_have_decl_strcpy" "$ac_includes_default" if test "x$ac_cv_have_decl_strcpy" = xyes; then : ac_have_decl=1 @@ -14274,6 +14276,19 @@ cat >>confdefs.h <<_ACEOF _ACEOF +for ac_func in setresuid setresgid +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + ac_fn_c_check_decl "$LINENO" "strtold" "ac_cv_have_decl_strtold" "$ac_includes_default" if test "x$ac_cv_have_decl_strtold" = xyes; then : ac_have_decl=1 @@ -15415,6 +15430,7 @@ else #include #include +int main(c, v) int c; char **v; @@ -16857,7 +16873,9 @@ else #endif #include #include +#include +int main(c, v) int c; char *v[]; @@ -16917,6 +16935,7 @@ else #include #include #include +int main() { int fd1, fd2, fl; @@ -16968,7 +16987,11 @@ else #ifdef HAVE_UNISTD_H # include #endif +#ifdef HAVE_SYS_WAIT_H +# include +#endif #include +int main() { # ifdef GETPGRP_VOID @@ -17186,6 +17209,7 @@ else #if !HAVE_DECL_SYS_SIGLIST extern char *sys_siglist[]; #endif +int main() { char *msg = sys_siglist[2]; @@ -17268,6 +17292,7 @@ else #ifndef UNDER_SYS_SIGLIST_DECLARED extern char *_sys_siglist[]; #endif +int main() { char *msg = (char *)_sys_siglist[2]; @@ -17673,6 +17698,7 @@ else #include #include #include +int main() { #ifdef HAVE_QUAD_T @@ -18200,6 +18226,7 @@ else #include +int main(c, v) int c; char **v; @@ -18528,6 +18555,7 @@ else /* end confdefs.h. */ #include #include +#include int main () { @@ -18572,6 +18600,9 @@ else #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ +#ifdef HAVE_SYS_STAT_H +#include +#endif #if defined(HAVE_DIRENT_H) # include #else @@ -18587,6 +18618,7 @@ else # endif #endif /* HAVE_DIRENT_H */ #include +int main() { DIR *dir; @@ -18638,6 +18670,11 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include +#ifdef HAVE_ULIMIT_H +#include +#endif +int main() { long maxfds = ulimit(4, 0L); @@ -18716,6 +18753,7 @@ getenv (name) { return "42"; } +int main() { char *s; @@ -18767,7 +18805,9 @@ else #ifdef HAVE_UNISTD_H #include #endif +#include +int main() { char *xpwd; @@ -18824,6 +18864,7 @@ else #include #include +int main() { #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) @@ -18892,7 +18933,10 @@ else #if defined (HAVE_LOCALE_H) #include #endif +#include +#include +int main(c, v) int c; char *v[]; @@ -18964,6 +19008,7 @@ else #include #include +int main() { int n; @@ -19043,6 +19088,7 @@ foo(format, va_alist) return n; } +int main() { int n; @@ -19346,6 +19392,7 @@ int s; nsigint++; } +int main() { nsigint = 0; @@ -19467,9 +19514,11 @@ else #ifdef HAVE_UNISTD_H #include #endif +#include #include /* Add more tests in here as appropriate. */ +int main() { int fd, err; @@ -19664,10 +19713,12 @@ else #include #include #include +#include #ifndef errno extern int errno; #endif +int main() { int x; @@ -19784,6 +19835,7 @@ else # define NSIG 64 #endif +int main () { int n_sigs = 2 * NSIG; diff --git a/configure.ac b/configure.ac index a15b4171..cf5d1ed5 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script. # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AC_REVISION([for Bash 5.0, version 5.011])dnl +AC_REVISION([for Bash 5.0, version 5.014])dnl define(bashvers, 5.0) define(relstatus, maint) @@ -850,10 +850,13 @@ AC_CHECK_DECLS([confstr]) AC_CHECK_DECLS([printf]) AC_CHECK_DECLS([sbrk]) AC_CHECK_DECLS([setregid]) -AC_CHECK_DECLS[(setresuid, setresgid]) +dnl AC_CHECK_DECLS[(setresuid]) +dnl AC_CHECK_DECLS[(setresgid]) AC_CHECK_DECLS([strcpy]) AC_CHECK_DECLS([strsignal]) +AC_CHECK_FUNCS(setresuid setresgid) + dnl Extra test to detect the horribly broken HP/UX 11.00 strtold(3) AC_CHECK_DECLS([strtold], [ AC_MSG_CHECKING([for broken strtold]) diff --git a/execute_cmd.c b/execute_cmd.c index e2c9baac..9b5d5b5f 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -753,7 +753,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, reap_procsubs (); # endif - if (variable_context != 0) /* XXX - also if sourcelevel != 0? */ + if (variable_context != 0 || executing_list) /* XXX - also if sourcelevel != 0? */ { ofifo = num_fifos (); ofifo_list = copy_fifo_list ((int *)&osize); @@ -2694,6 +2694,7 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close) } executing_list++; QUIT; + #if 1 execute_command (command->value.Connection->first); #else diff --git a/m4/intdiv0.m4 b/m4/intdiv0.m4 index e63fcf10..40dd43b3 100644 --- a/m4/intdiv0.m4 +++ b/m4/intdiv0.m4 @@ -38,13 +38,13 @@ static void sigfpe_handler (int sig) { /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ - _exit (sig != SIGFPE); + exit (sig != SIGFPE); } int x = 1; int y = 0; int z; -int nan; +int xnan; int main () { @@ -59,7 +59,7 @@ int main () #endif z = x / y; - nan = y / y; + xnan = y / y; exit (2); } ]])], diff --git a/m4/intl.m4 b/m4/intl.m4 index 5cb15cf2..b481c505 100644 --- a/m4/intl.m4 +++ b/m4/intl.m4 @@ -243,6 +243,9 @@ AC_DEFUN([gt_INTL_SUBDIR_CORE], stpcpy strcasecmp strdup strtoul tsearch argz_count argz_stringify \ argz_next __fsetlocking]) + dnl ADDED FOR BASH + AC_CHECK_FUNCS([localeconv]) + dnl Use the *_unlocked functions only if they are declared. dnl (because some of them were defined without being declared in Solaris dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built diff --git a/shell.c b/shell.c index daa68304..7dc3ab27 100644 --- a/shell.c +++ b/shell.c @@ -1305,7 +1305,7 @@ disable_priv_mode () { int e; -#if HAVE_DECL_SETRESUID +#if HAVE_SETRESUID if (setresuid (current_user.uid, current_user.uid, current_user.uid) < 0) #else if (setuid (current_user.uid) < 0) @@ -1318,7 +1318,7 @@ disable_priv_mode () exit (e); #endif } -#if HAVE_DECL_SETRESGID +#if HAVE_SETRESGID if (setresgid (current_user.gid, current_user.gid, current_user.gid) < 0) #else if (setgid (current_user.gid) < 0) diff --git a/tests/precedence.tests b/tests/precedence.tests new file mode 100755 index 00000000..111bd231 --- /dev/null +++ b/tests/precedence.tests @@ -0,0 +1,90 @@ +# @(#)precedence_test 1.0 91/07/24 Maarten Litmaath + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# test of relative precedences for `&&' and `||' operators + +echo "\`Say' echos its argument. Its return value is of no interest." +case `echo -n` in + '') Say () { echo -n "$*" ; } ;; + *) Say () { echo "$*\c" ; } ;; +esac + +echo "\`Truth' echos its argument and returns a TRUE result." +Truth () { + Say $1; + return 0; +} + +echo "\`False' echos its argument and returns a FALSE result." +False () { + Say $1; + return 1; +} + +echo "" + +cmd1='$open $test1 && $test2 $close || $test3' +cmd2='$test1 || $open $test2 && $test3 $close' + +grouping_sh= +grouping_C='( )' + +test3='Say 3' + +for i in 1 2 +do + eval proto=\$cmd$i + + for test1 in 'Truth 1' 'False 1' + do + for test2 in 'Truth 2' 'False 2' + do + for precedence in sh C + do + eval set x \$grouping_$precedence + shift + open=${1-' '} + close=${2-' '} + eval cmd=\""$proto"\" + Say "$cmd output=" + output=`eval "$cmd"` + Say "$output" + read correct || { echo 'Input fubar. Abort.' >&2; exit 1; } + test "X$output" = "X$correct" || echo " correct=$correct" + echo '' + done + + echo '' + done + done +done << EOF +12 +12 +123 +123 +13 +13 +13 +13 +13 +1 +13 +1 +123 +123 +12 +12 +EOF diff --git a/tests/procsub.right b/tests/procsub.right index cf1dbb10..a8ebe80b 100644 --- a/tests/procsub.right +++ b/tests/procsub.right @@ -1,7 +1,6 @@ test1 foo test2 -test3 test4 8 test5 diff --git a/tests/procsub.tests b/tests/procsub.tests index 49ec9498..136ab98f 100644 --- a/tests/procsub.tests +++ b/tests/procsub.tests @@ -17,8 +17,9 @@ eval cat <(echo test1) eval "echo foo;cat" <(echo test2) -unset f -f=<(echo test3); cat "$f" +# this doesn't work, and it never should have +#unset f +#f=<(echo test3); cat "$f" unset f eval f=<(echo test4) "; cat \$f" diff --git a/tests/run-precedence b/tests/run-precedence index de33224e..06ac343f 100644 --- a/tests/run-precedence +++ b/tests/run-precedence @@ -1,2 +1,2 @@ -${THIS_SH} ./precedence > ${BASH_TSTOUT} +${THIS_SH} ./precedence.tests > ${BASH_TSTOUT} diff ${BASH_TSTOUT} prec.right && rm -f ${BASH_TSTOUT}