diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 3332fe76..5460fdf1 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -6803,3 +6803,37 @@ subst.c string_list (and then quote_string_for_globbing, since QGLOB_CVTNULL only handles pat[0] == CTLNUL). Fixes bug reported by Oguz + + 11/4 + ---- +configure.ac,config.h.in + - AC_HEADER_MAJOR: look for `major' and `minor' in various header files + and define MAJOR_IN_MAKEDEV or MAJOR_IN_SYSMACROS as appropriate. + From a patch from Eli Schwartz + +examples/loadables/finfo.c + - include and as appropriate for + definitions of major/minor + + 11/6 + ---- +redir.c + - heredoc_expand: if we are expanding the WORD in a here-string, use + expand_assignment_string_to_string so the expansions are consistent + in contexts where word splitting is not performed. From a bug report + by Robin A. Meade + + 11/7 + ---- +parse.y + - xparse_dolparen: if the command substitution is incomplete or doesn't + end in `)', print an error message instead of allowing EOS to + terminate the comsub. From a bug report from + Oguz + + 11/11 + ----- +lib/sh/unicode.c + - u32toutf8: fix a typo that assigned the wrong value to the first + byte of a six-byte UTF-8 character. Report and fix from + István Pásztor diff --git a/MANIFEST b/MANIFEST index a20b467b..edef9c81 100644 --- a/MANIFEST +++ b/MANIFEST @@ -967,6 +967,7 @@ tests/comsub-eof2.sub f tests/comsub-eof3.sub f tests/comsub-eof4.sub f tests/comsub-eof5.sub f +tests/comsub-eof6.sub f tests/comsub-eof.right f tests/comsub-posix.tests f tests/comsub-posix.right f @@ -1105,6 +1106,7 @@ tests/glob4.sub f tests/glob5.sub f tests/glob6.sub f tests/glob7.sub f +tests/glob8.sub f tests/glob.right f tests/globstar.tests f tests/globstar.right f diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 667ee5cc..84479f92 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -611,7 +611,7 @@ itrace("parse_string: longjmp executed: code = %d", code); break; } - out: +out: global_command = oglobal; nc = bash_input.location.string - ostring; diff --git a/config.h.in b/config.h.in index 92633057..b16c22e1 100644 --- a/config.h.in +++ b/config.h.in @@ -285,6 +285,11 @@ /* Define if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H +/* Define if major/minor/makedev is defined in */ +#undef MAJOR_IN_MAKEDEV + +/* Define if major/minor/makedev is defined in */ +#undef MAJOR_IN_SYSMACROS /* SYSTEM TYPES */ diff --git a/configure b/configure index 3a3aa332..44f55f6d 100755 --- a/configure +++ b/configure @@ -13258,6 +13258,56 @@ $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sys/types.h defines makedev" >&5 +$as_echo_n "checking whether sys/types.h defines makedev... " >&6; } +if ${ac_cv_header_sys_types_h_makedev+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +return makedev(0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_header_sys_types_h_makedev=yes +else + ac_cv_header_sys_types_h_makedev=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_types_h_makedev" >&5 +$as_echo "$ac_cv_header_sys_types_h_makedev" >&6; } + +if test $ac_cv_header_sys_types_h_makedev = no; then +ac_fn_c_check_header_mongrel "$LINENO" "sys/mkdev.h" "ac_cv_header_sys_mkdev_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_mkdev_h" = xyes; then : + +$as_echo "#define MAJOR_IN_MKDEV 1" >>confdefs.h + +fi + + + + if test $ac_cv_header_sys_mkdev_h = no; then + ac_fn_c_check_header_mongrel "$LINENO" "sys/sysmacros.h" "ac_cv_header_sys_sysmacros_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_sysmacros_h" = xyes; then : + +$as_echo "#define MAJOR_IN_SYSMACROS 1" >>confdefs.h + +fi + + + fi +fi + for ac_header in inttypes.h diff --git a/configure.ac b/configure.ac index cf5d1ed5..1b26587a 100644 --- a/configure.ac +++ b/configure.ac @@ -743,6 +743,7 @@ AM_GNU_GETTEXT([no-libtool], [need-ngettext], [lib/intl]) dnl header files AC_HEADER_DIRENT AC_HEADER_TIME +AC_HEADER_MAJOR BASH_HEADER_INTTYPES diff --git a/examples/loadables/finfo.c b/examples/loadables/finfo.c index 4273aa59..72f859f6 100644 --- a/examples/loadables/finfo.c +++ b/examples/loadables/finfo.c @@ -28,6 +28,12 @@ #endif #include +#ifdef MAJOR_IN_MKDEV +# include +#endif +#ifdef MAJOR_IN_SYSMACROS +# include +#endif #include "posixstat.h" #include #include diff --git a/lib/sh/unicode.c b/lib/sh/unicode.c index 99c422ab..948d09fd 100644 --- a/lib/sh/unicode.c +++ b/lib/sh/unicode.c @@ -1,6 +1,6 @@ /* unicode.c - functions to convert unicode characters */ -/* Copyright (C) 2010-2016 Free Software Foundation, Inc. +/* Copyright (C) 2010-2019 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -196,7 +196,7 @@ u32toutf8 (wc, s) } else if (wc < 0x080000000) { - s[0] = (wc >> 30) | 0xf8; + s[0] = (wc >> 30) | 0xfc; s[1] = ((wc >> 24) & 0x3f) | 0x80; s[2] = ((wc >> 18) & 0x3f) | 0x80; s[3] = ((wc >> 12) & 0x3f) | 0x80; diff --git a/parse.y b/parse.y index 6bab5dfa..35a78aa0 100644 --- a/parse.y +++ b/parse.y @@ -4415,7 +4415,7 @@ xparse_dolparen (base, string, indp, flags) { sh_parser_state_t ps; sh_input_line_state_t ls; - int orig_ind, nc, sflags, orig_eof_token; + int orig_ind, nc, sflags, orig_eof_token, start_lineno; char *ret, *ep, *ostring; #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) STRING_SAVER *saved_pushed_strings; @@ -4424,6 +4424,7 @@ xparse_dolparen (base, string, indp, flags) /*debug_parser(1);*/ orig_ind = *indp; ostring = string; + start_lineno = line_number; if (*string == 0) { @@ -4493,13 +4494,14 @@ xparse_dolparen (base, string, indp, flags) if (ep[-1] != '\n') itrace("xparse_dolparen:%d: ep[-1] != RPAREN (%d), ep = `%s'", line_number, ep[-1], ep); #endif + while (ep > ostring && ep[-1] == '\n') ep--; } nc = ep - ostring; *indp = ep - base - 1; - /*(*/ + /*((*/ #if DEBUG if (base[*indp] != ')') itrace("xparse_dolparen:%d: base[%d] != RPAREN (%d), base = `%s'", line_number, *indp, base[*indp], base); @@ -4507,6 +4509,13 @@ xparse_dolparen (base, string, indp, flags) itrace("xparse_dolparen:%d: *indp (%d) < orig_ind (%d), orig_string = `%s'", line_number, *indp, orig_ind, ostring); #endif + if (base[*indp] != ')') + { + /*(*/ + parser_error (start_lineno, _("unexpected EOF while looking for matching `%c'"), ')'); + jump_to_top_level (DISCARD); + } + if (flags & SX_NOALLOC) return (char *)NULL; diff --git a/redir.c b/redir.c index fc35f7ca..7de1aa03 100644 --- a/redir.c +++ b/redir.c @@ -367,7 +367,7 @@ heredoc_expand (redirectee, ri, lenp) /* Now that we've changed the variable search order to ignore the temp environment, see if we need to change the cached IFS values. */ sv_ifs ("IFS"); - document = (ri == r_reading_string) ? expand_string_unsplit_to_string (redirectee->word, 0) + document = (ri == r_reading_string) ? expand_assignment_string_to_string (redirectee->word, 0) : expand_string_to_string (redirectee->word, Q_HERE_DOCUMENT); expanding_redir = 0; /* Now we need to change the variable search order back to include the temp diff --git a/tests/comsub-eof.right b/tests/comsub-eof.right index 452a9c5f..42677985 100644 --- a/tests/comsub-eof.right +++ b/tests/comsub-eof.right @@ -11,3 +11,5 @@ contents hi ./comsub-eof5.sub: line 13: warning: here-document at line 11 delimited by end-of-file (wanted `EOF') hi +./comsub-eof6.sub: line 1: unexpected EOF while looking for matching `)' + diff --git a/tests/comsub-eof.tests b/tests/comsub-eof.tests index f96aeee9..398746aa 100644 --- a/tests/comsub-eof.tests +++ b/tests/comsub-eof.tests @@ -9,3 +9,5 @@ ${THIS_SH} ./comsub-eof3.sub ${THIS_SH} ./comsub-eof4.sub ${THIS_SH} ./comsub-eof5.sub + +${THIS_SH} ./comsub-eof6.sub diff --git a/tests/comsub-eof6.sub b/tests/comsub-eof6.sub new file mode 100644 index 00000000..c0e63ddd --- /dev/null +++ b/tests/comsub-eof6.sub @@ -0,0 +1,5 @@ +read foo < argv[2] = argv[3] = @@ -131,7 +133,7 @@ argv[2] = argv[3] = argv[4] = tmp/l1 tmp/l2 tmp/*4 tmp/l3 -./glob.tests: line 63: no match: tmp/*4 +./glob.tests: line 64: no match: tmp/*4 argv[1] = argv[1] = <*> argv[1] = diff --git a/tests/glob.tests b/tests/glob.tests index 1285530d..9005e4de 100644 --- a/tests/glob.tests +++ b/tests/glob.tests @@ -28,6 +28,7 @@ ${THIS_SH} ./glob4.sub ${THIS_SH} ./glob5.sub ${THIS_SH} ./glob6.sub ${THIS_SH} ./glob7.sub +${THIS_SH} ./glob8.sub MYDIR=$PWD # save where we are diff --git a/tests/glob8.sub b/tests/glob8.sub new file mode 100644 index 00000000..4ee5f7a0 --- /dev/null +++ b/tests/glob8.sub @@ -0,0 +1,29 @@ +# 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 . +# +TESTDIR=${TMPDIR}/glob-test-$$ +mkdir ${TESTDIR} +cd $TESTDIR || { + echo "$TESTDIR: cannot cd" >&2 + exit 1 +} + +trap 'cd $OLDPWD && rm -rf $TESTDIR' EXIT + +var='a\' +touch 'a*b' 'a\*b' + +printf '%s\n' $var\*b* + +var1=a\\$'\001' +printf '%s\n' $var1\*b* diff --git a/tests/new-exp.right b/tests/new-exp.right index bf3fc350..fe5c4618 100644 --- a/tests/new-exp.right +++ b/tests/new-exp.right @@ -672,4 +672,5 @@ PASS;1 foo;2 foo; after: PASS argv[1] = argv[1] = -./new-exp.tests: line 634: ABXD: parameter unset + +./new-exp.tests: line 640: ABXD: parameter unset diff --git a/tests/new-exp.tests b/tests/new-exp.tests index a73a5d93..20463ae8 100644 --- a/tests/new-exp.tests +++ b/tests/new-exp.tests @@ -626,6 +626,12 @@ a=/a recho "/${a%/*}" recho "/${a///a/}" +patfunc() +{ + echo ${1##*"${1##*}"} +} +patfunc foo + # caused core dumps because of bad bracket expression parsing in bash-5.0 eval : $'${x/#[0\xef\xbf\xbd\\Z[:]]}'