diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index dfe2bd8c..4ab72f6e 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -15197,3 +15197,59 @@ smatch.c unrecognized character class names, since the wide character ctype functions allow locales to define their own character class names (e.g., "hyphen"). Fixes issue reported by yangyajing + + 4/10 + ---- +configure.ac,cross-build/qnx.cache + - qnx: add a configure cache file for cross-building, treat qnx 7 like + qnx 6 in terms of cpp options. Fix from Brian Carnes + + +aclocal.m4 + - BASH_CHECK_DEV_STDIN: experimental change to test for /dev/stdin + independently of /dev/fd or /proc/self/fd. Suggested for QNX by + Brian Carnes + + + 4/11 + ---- +lib/glob/glob.c + - glob_testdir: return -2 if DIR is a symlink, to differentiate it from + any other kind of non-directory file + - glob_vector: if we have GX_ALLDIRS (globstar), we want to skip over + symlinks to directories, since we will pick up the real directory + later. Fixes incompatibility reported by Murukesh Mohanan + + +bashline.c + - bash_execute_unix_command: changes to make READLINE_POINT apply to + characters instead of bytes when in a multibyte locale. Report and + fix from Koichi Murase + + 4/12 + ---- +builtins/evalstring.c + - parse_and_execute_cleanup: now takes an argument which is the value + of running_trap at some point before parse_and_execute was called; + changed callers in sig.c, builtins/evalfile.c + +builtins/common.h + - parse_and_execute_cleanup: changed prototype + + 4/13 + ---- +builtins/evalstring.c + - parse_and_execute_cleanup: if the argument holding the previous state + of running_trap is the same value as the current running_trap state, + don't call run_trap_cleanup: assume that there is a caller who will + take care of the cleanup after this returns. Fixes recursive trap + call on "eval return" reported by Martijn Dekker + +parse.y + - read_a_line: if remove_quoted_newline is non-zero, indicating the + here-document delimiter is unquoted, we will be running the contents + of the here-document through word expansion and need to quote CTLESC + and CTLNUL in the input. Fixes bug with ^A in here document reported + by Jorge Alberto Baca Garcia + + diff --git a/MANIFEST b/MANIFEST index 00a57793..b95b151f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -210,6 +210,7 @@ builtins/bashgetopt.h f cross-build/cygwin32.cache f cross-build/x86-beos.cache f cross-build/opennt.cache f +cross-build/qnx.cache f include/ansi_stdlib.h f include/chartypes.h f include/filecntl.h f diff --git a/aclocal.m4 b/aclocal.m4 index 488408ea..6ea6f40f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1581,9 +1581,7 @@ fi AC_DEFUN(BASH_CHECK_DEV_STDIN, [AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available) AC_CACHE_VAL(bash_cv_dev_stdin, -[if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then - bash_cv_dev_stdin=present - elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then +[if (exec test -r /dev/stdin < /dev/null) ; then bash_cv_dev_stdin=present else bash_cv_dev_stdin=absent diff --git a/bashline.c b/bashline.c index 60f34997..91d44465 100644 --- a/bashline.c +++ b/bashline.c @@ -66,6 +66,7 @@ #include #include #include +#include #include @@ -4095,7 +4096,7 @@ bash_execute_unix_command (count, key) register int i, r; intmax_t mi; sh_parser_state_t ps; - char *cmd, *value, *ce; + char *cmd, *value, *ce, old_ch; SHELL_VAR *v; char ibuf[INT_STRLEN_BOUND(int) + 1]; @@ -4129,7 +4130,17 @@ bash_execute_unix_command (count, key) v = bind_variable ("READLINE_LINE", rl_line_buffer, 0); if (v) VSETATTR (v, att_exported); - value = inttostr (rl_point, ibuf, sizeof (ibuf)); + i = rl_point; +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1) + { + old_ch = rl_line_buffer[rl_point]; + rl_line_buffer[rl_point] = '\0'; + i = MB_STRLEN (rl_line_buffer); + rl_line_buffer[rl_point] = old_ch; + } +#endif + value = inttostr (i, ibuf, sizeof (ibuf)); v = bind_int_variable ("READLINE_POINT", value, 0); if (v) VSETATTR (v, att_exported); @@ -4146,6 +4157,10 @@ bash_execute_unix_command (count, key) if (v && legal_number (value_cell (v), &mi)) { i = mi; +#if defined (HANDLE_MULTIBYTE) + if (i > 0 && MB_CUR_MAX > 1) + i = _rl_find_next_mbchar (rl_line_buffer, 0, i, 0); +#endif if (i != rl_point) { rl_point = i; diff --git a/builtins/common.h b/builtins/common.h index 96a789d6..049192a6 100644 --- a/builtins/common.h +++ b/builtins/common.h @@ -200,7 +200,7 @@ extern WORD_LIST *get_directory_stack __P((int)); /* Functions from evalstring.c */ extern int parse_and_execute __P((char *, const char *, int)); extern int evalstring __P((char *, const char *, int)); -extern void parse_and_execute_cleanup __P((void)); +extern void parse_and_execute_cleanup __P((int)); extern int parse_string __P((char *, const char *, int, char **)); extern int should_suppress_fork __P((COMMAND *)); extern void optimize_fork __P((COMMAND *)); diff --git a/builtins/evalfile.c b/builtins/evalfile.c index 2c195e6a..32a7c8d6 100644 --- a/builtins/evalfile.c +++ b/builtins/evalfile.c @@ -278,7 +278,7 @@ file_error_and_exit: force parse_and_execute () to clean up. */ if (return_val) { - parse_and_execute_cleanup (); + parse_and_execute_cleanup (-1); result = return_catch_value; } else diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 46dc36d6..5073ca49 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -136,11 +136,17 @@ optimize_subshell_command (command) /* How to force parse_and_execute () to clean up after itself. */ void -parse_and_execute_cleanup () +parse_and_execute_cleanup (old_running_trap) + int old_running_trap; { - if (running_trap) + if (running_trap > 0) { - run_trap_cleanup (running_trap - 1); + /* We assume if we have a different value for running_trap than when + we started (the only caller that cares is evalstring()), the + original caller will perform the cleanup, and we should not step + on them. */ + if (running_trap != old_running_trap) + run_trap_cleanup (running_trap - 1); unfreeze_jobs_list (); } @@ -653,6 +659,10 @@ evalstring (string, from_file, flags) int flags; { volatile int r, rflag, rcatch; + volatile int was_trap; + + /* Are we running a trap when we execute this function? */ + was_trap = running_trap; rcatch = 0; rflag = return_catch_flag; @@ -672,7 +682,9 @@ evalstring (string, from_file, flags) if (rcatch) { - parse_and_execute_cleanup (); + /* We care about whether or not we are running the same trap we were + when we entered this function. */ + parse_and_execute_cleanup (was_trap); r = return_catch_value; } else diff --git a/configure b/configure index 47fd47ce..f0db2db7 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac for Bash 5.0, version 4.090. +# From configure.ac for Bash 5.0, version 4.091. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for bash 5.0-alpha. # @@ -2866,7 +2866,7 @@ sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF *-rhapsody*) opt_bash_malloc=no ;; # Apple Rhapsody (MacOS X) *-darwin*) opt_bash_malloc=no ;; # Apple Darwin (MacOS X) *-dgux*) opt_bash_malloc=no ;; # DG/UX machines -*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX 6.x +*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX [67].x *-machten4) opt_bash_malloc=no ;; # MachTen 4.x *-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins *-beos*) opt_bash_malloc=no ;; # they say it's suitable @@ -4911,6 +4911,9 @@ if test "x$cross_compiling" = "xyes"; then i[3456]86-*-beos*) cross_cache=${srcdir}/cross-build/x86-beos.cache ;; + *-qnx*) + cross_cache=${srcdir}/cross-build/qnx.cache + ;; *) echo "configure: cross-compiling for $host is not supported" >&2 ;; esac @@ -16081,9 +16084,7 @@ $as_echo_n "checking whether /dev/stdin stdout stderr are available... " >&6; } if ${bash_cv_dev_stdin+:} false; then : $as_echo_n "(cached) " >&6 else - if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then - bash_cv_dev_stdin=present - elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then + if (exec test -r /dev/stdin < /dev/null) ; then bash_cv_dev_stdin=present else bash_cv_dev_stdin=absent @@ -16174,7 +16175,7 @@ linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading *) $as_echo "#define PGRP_PIPE 1" >>confdefs.h ;; esac ;; -*qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;; +*qnx[67]*) LOCAL_LIBS="-lncurses" ;; *qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;; powerux*) LOCAL_LIBS="-lgen" ;; cygwin*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; diff --git a/configure.ac b/configure.ac index 43da66fc..d0ccffb4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ dnl -dnl Configure script for bash-4.4 +dnl Configure script for bash-5.0 dnl dnl report bugs to chet@po.cwru.edu dnl @@ -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 4.090])dnl +AC_REVISION([for Bash 5.0, version 4.091])dnl define(bashvers, 5.0) define(relstatus, alpha) @@ -82,7 +82,7 @@ sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF *-rhapsody*) opt_bash_malloc=no ;; # Apple Rhapsody (MacOS X) *-darwin*) opt_bash_malloc=no ;; # Apple Darwin (MacOS X) *-dgux*) opt_bash_malloc=no ;; # DG/UX machines -*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX 6.x +*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX [67].x *-machten4) opt_bash_malloc=no ;; # MachTen 4.x *-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins *-beos*) opt_bash_malloc=no ;; # they say it's suitable @@ -445,6 +445,9 @@ if test "x$cross_compiling" = "xyes"; then i[[3456]]86-*-beos*) cross_cache=${srcdir}/cross-build/x86-beos.cache ;; + *-qnx*) + cross_cache=${srcdir}/cross-build/qnx.cache + ;; *) echo "configure: cross-compiling for $host is not supported" >&2 ;; esac @@ -1108,7 +1111,7 @@ linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading 1.*|2.[[0123]]*) : ;; *) AC_DEFINE(PGRP_PIPE) ;; esac ;; -*qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;; +*qnx[[67]]*) LOCAL_LIBS="-lncurses" ;; *qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;; powerux*) LOCAL_LIBS="-lgen" ;; cygwin*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; diff --git a/cross-build/qnx.cache b/cross-build/qnx.cache new file mode 100644 index 00000000..3f630fd8 --- /dev/null +++ b/cross-build/qnx.cache @@ -0,0 +1,66 @@ +bash_cv_decl_strtoimax=${bash_cv_decl_strtoimax=yes} +bash_cv_decl_strtol=${bash_cv_decl_strtol=yes} +bash_cv_decl_strtoll=${bash_cv_decl_strtoll=yes} +bash_cv_decl_strtoul=${bash_cv_decl_strtoul=yes} +bash_cv_decl_strtoull=${bash_cv_decl_strtoull=yes} +bash_cv_decl_strtoumax=${bash_cv_decl_strtoumax=yes} +bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist=no} +bash_cv_dev_fd=${bash_cv_dev_fd=absent} +bash_cv_dev_stdin=${bash_cv_dev_stdin=present} +bash_cv_dirent_has_d_fileno=${bash_cv_dirent_has_d_fileno=no} +bash_cv_dirent_has_d_namlen=${bash_cv_dirent_has_d_namlen=no} +bash_cv_dirent_has_dino=${bash_cv_dirent_has_dino=yes} +bash_cv_dup2_broken=${bash_cv_dup2_broken=no} +bash_cv_fionread_in_ioctl=${bash_cv_fionread_in_ioctl=yes} +bash_cv_func_ctype_nonascii=${bash_cv_func_ctype_nonascii=no} +bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp=present} +bash_cv_func_snprintf=${bash_cv_func_snprintf=yes} +bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken=no} +bash_cv_func_vsnprintf=${bash_cv_func_vsnprintf=yes} +bash_cv_getcwd_malloc=${bash_cv_getcwd_malloc=yes} +bash_cv_getenv_redef=${bash_cv_getenv_redef=yes} +bash_cv_getpw_declared=${bash_cv_getpw_declared=yes} +bash_cv_have_gethostbyname=${bash_cv_have_gethostbyname=no} +bash_cv_have_socklib=${bash_cv_have_socklib=no} +bash_cv_have_strsignal=${bash_cv_have_strsignal=yes} +bash_cv_job_control_missing=${bash_cv_job_control_missing=present} +bash_cv_langinfo_codeset=${bash_cv_langinfo_codeset=no} +bash_cv_mail_dir=${bash_cv_mail_dir=unknown} +bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers=no} +bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust=no} +bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe=no} +bash_cv_printf_a_format=${bash_cv_printf_a_format=yes} +bash_cv_signal_vintage=${bash_cv_signal_vintage=posix} +bash_cv_speed_t_in_sys_types=${bash_cv_speed_t_in_sys_types=no} +bash_cv_std_putenv=${bash_cv_std_putenv=yes} +bash_cv_std_unsetenv=${bash_cv_std_unsetenv=yes} +bash_cv_strtold_broken=${bash_cv_strtold_broken=no} +bash_cv_struct_timeval=${bash_cv_struct_timeval=yes} +bash_cv_struct_timezone=${bash_cv_struct_timezone=yes} +bash_cv_struct_winsize_header=${bash_cv_struct_winsize_header=ioctl_h} +bash_cv_sys_errlist=${bash_cv_sys_errlist=no} +bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes=present} +bash_cv_sys_siglist=${bash_cv_sys_siglist=yes} +bash_cv_sys_struct_timespec_in_time_h=${bash_cv_sys_struct_timespec_in_time_h=yes} +bash_cv_termcap_lib=${bash_cv_termcap_lib=libtermcap} +bash_cv_tiocstat_in_ioctl=${bash_cv_tiocstat_in_ioctl=no} +bash_cv_type_clock_t=${bash_cv_type_clock_t=yes} +bash_cv_type_intmax_t=${bash_cv_type_intmax_t=yes} +bash_cv_type_long_long=${bash_cv_type_long_long='long long'} +bash_cv_type_quad_t=${bash_cv_type_quad_t=no} +bash_cv_type_rlimit=${bash_cv_type_rlimit=rlim_t} +bash_cv_type_sig_atomic_t=${bash_cv_type_sig_atomic_t=yes} +bash_cv_type_sigset_t=${bash_cv_type_sigset_t=yes} +bash_cv_type_socklen_t=${bash_cv_type_socklen_t=yes} +bash_cv_type_uintmax_t=${bash_cv_type_uintmax_t=yes} +bash_cv_type_unsigned_long_long=${bash_cv_type_unsigned_long_long='unsigned long long'} +bash_cv_type_wchar_t=${bash_cv_type_wchar_t=yes} +bash_cv_type_wctype_t=${bash_cv_type_wctype_t=yes} +bash_cv_type_wint_t=${bash_cv_type_wint_t=yes} +bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds=no} +bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist=no} +bash_cv_unusable_rtsigs=${bash_cv_unusable_rtsigs=no} +bash_cv_void_sighandler=${bash_cv_void_sighandler=yes} +bash_cv_wcontinued_broken=${bash_cv_wcontinued_broken=no} +bash_cv_wcwidth_broken=${bash_cv_wcwidth_broken=no} +bash_cv_wexitstatus_offset=${bash_cv_wexitstatus_offset=8} diff --git a/execute_cmd.c b/execute_cmd.c index 0ac26030..5180c1ed 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -4814,11 +4814,7 @@ execute_function (var, words, flags, fds_to_close, async, subshell) /* Shell functions inherit the RETURN trap if function tracing is on globally or on individually for this function. */ -#if 0 - if (return_trap && ((trace_p (var) == 0) && function_trace_mode == 0)) -#else if (return_trap && (signal_in_progress (DEBUG_TRAP) || ((trace_p (var) == 0) && function_trace_mode == 0))) -#endif { if (subshell == 0) { diff --git a/lib/glob/glob.c b/lib/glob/glob.c index 356857be..774435f1 100644 --- a/lib/glob/glob.c +++ b/lib/glob/glob.c @@ -477,7 +477,7 @@ dequote_pathname (pathname) # endif /* AFS */ #endif /* !HAVE_LSTAT */ -/* Return 0 if DIR is a directory, -1 otherwise. */ +/* Return 0 if DIR is a directory, -2 if DIR is a symlink, -1 otherwise. */ static int glob_testdir (dir, flags) char *dir; @@ -495,6 +495,11 @@ glob_testdir (dir, flags) if (r < 0) return (-1); +#if defined (S_ISLNK) + if (S_ISLNK (finfo.st_mode)) + return (-2); +#endif + if (S_ISDIR (finfo.st_mode) == 0) return (-1); @@ -800,6 +805,15 @@ glob_vector (pat, dir, flags) } } + /* When FLAGS includes GX_ALLDIRS, we want to skip a symlink + to a directory, since we will pick the directory up later. */ + if (isdir == -2 && glob_testdir (subdir, 0) == 0) + { + free (subdir); + continue; + } + + /* XXX - should we even add this if it's not a directory? */ nextlink = (struct globval *) malloc (sizeof (struct globval)); if (firstmalloc == 0) firstmalloc = nextlink; diff --git a/parse.y b/parse.y index b88962ef..d7701259 100644 --- a/parse.y +++ b/parse.y @@ -2041,7 +2041,8 @@ read_a_line (remove_quoted_newline) c = '\n'; } - /* `+2' in case the final character in the buffer is a newline. */ + /* `+2' in case the final character in the buffer is a newline or we + have to handle CTLESC or CTLNUL. */ RESIZE_MALLOCED_BUFFER (line_buffer, indx, 2, buffer_size, 128); /* IF REMOVE_QUOTED_NEWLINES is non-zero, we are reading a @@ -2072,7 +2073,14 @@ read_a_line (remove_quoted_newline) } } else - line_buffer[indx++] = c; + { + /* remove_quoted_newline is non-zero if the here-document delimiter + is unquoted. In this case, we will be expanding the lines and + need to make sure CTLESC and CTLNUL in the input are quoted. */ + if (remove_quoted_newline && (c == CTLESC || c == CTLNUL)) + line_buffer[indx++] = CTLESC; + line_buffer[indx++] = c; + } if (c == '\n') { diff --git a/sig.c b/sig.c index 75ff9298..ac2ff1f3 100644 --- a/sig.c +++ b/sig.c @@ -371,7 +371,7 @@ top_level_cleanup () { /* Clean up string parser environment. */ while (parse_and_execute_level) - parse_and_execute_cleanup (); + parse_and_execute_cleanup (-1); #if defined (PROCESS_SUBSTITUTION) unlink_fifo_list (); @@ -409,7 +409,7 @@ throw_to_top_level () /* Clean up string parser environment. */ while (parse_and_execute_level) - parse_and_execute_cleanup (); + parse_and_execute_cleanup (-1); if (running_trap > 0) run_trap_cleanup (running_trap - 1); diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 554f3d6e..58c375b7 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -1,4 +1,4 @@ -BUILD_DIR=/usr/local/build/bash/bash-current +BUILD_DIR=/usr/local/build/chet/bash/bash-current THIS_SH=$BUILD_DIR/bash PATH=$PATH:$BUILD_DIR