From: Chet Ramey Date: Thu, 29 Dec 2011 18:07:43 +0000 (-0500) Subject: commit bash-20110506 snapshot X-Git-Tag: bash-4.3-alpha~124 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bfd181e794d5bd9d351af55a10081bc728c4496d;p=thirdparty%2Fbash.git commit bash-20110506 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index b26e93992..b9c639811 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -11549,3 +11549,31 @@ lib/sh/eaccess.c of the actual file permissions), so reorganize code to check the file permissions as with eaccess. Report and fix from Johan Hattne + + 5/2 + --- +doc/{bash.1,bashref.texi} + - add forward reference to `Pattern Matching' from `Pathname + Expansion', suggested by Greg Wooledge + + 5/5 + --- +pcomplib.c + - the bash_completion project now distributes over 200 completions + for various programs, with no end in sight, so increase the value + of COMPLETE_HASH_BUCKETS from 32 to 128 + +pathexp.c + - quote_string_for_globbing: make sure CTLESC quoting CTLESC is + translated into \ even if the flags include QGLOB_REGEXP. + We don't want to process the second CTLESC as a quote character. + Fixes bug reported by Shawn Bohrer + + 5/6 + --- +builtins/printf.def + - change PRETURN to not call fflush if ferror(stdout) is true + - if a call to one of the stdio functions or printstr leaves + ferror(stdout) true, and PRETURN is going to be called, let PRETURN + print the error message rather than doubling up the messages. Fixes + problem reported by Roman Rakus diff --git a/MANIFEST b/MANIFEST index 880609753..4449ac0f6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -845,6 +845,7 @@ tests/dstack2.tests f tests/dstack2.right f tests/errors.tests f tests/errors.right f +tests/errors1.sub f tests/execscript f tests/exec.right f tests/exec1.sub f 755 diff --git a/builtins/printf.def b/builtins/printf.def index 9eca21521..6dac76010 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -158,7 +158,8 @@ extern int errno; else if (vbuf) \ vbuf[0] = 0; \ terminate_immediately--; \ - fflush (stdout); \ + if (ferror (stdout) == 0) \ + fflush (stdout); \ if (ferror (stdout)) \ { \ sh_wrerror (); \ @@ -481,8 +482,11 @@ printf_builtin (list) n = printstr (start, timebuf, strlen (timebuf), fieldwidth, precision); /* XXX - %s for now */ if (n < 0) { - sh_wrerror (); - clearerr (stdout); + if (ferror (stdout) == 0) + { + sh_wrerror (); + clearerr (stdout); + } PRETURN (EXECUTION_FAILURE); } break; @@ -522,8 +526,11 @@ printf_builtin (list) r = printstr (start, xp, rlen, fieldwidth, precision); if (r < 0) { - sh_wrerror (); - clearerr (stdout); + if (ferror (stdout) == 0) + { + sh_wrerror (); + clearerr (stdout); + } retval = EXECUTION_FAILURE; } free (xp); @@ -645,8 +652,7 @@ printf_builtin (list) if (ferror (stdout)) { - sh_wrerror (); - clearerr (stdout); + /* PRETURN will print error message. */ PRETURN (EXECUTION_FAILURE); } } diff --git a/doc/bash.1 b/doc/bash.1 index a5e62a2d7..61c46b4e2 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -3124,7 +3124,11 @@ If one of these characters appears, then the word is regarded as a .IR pattern , and replaced with an alphabetically sorted list of -file names matching the pattern. +file names matching the pattern +(see +.SM +.B "Pattern Matching" +below). If no matching file names are found, and the shell option .B nullglob diff --git a/doc/bashref.texi b/doc/bashref.texi index df2620fc4..7c1bbb3a0 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -2044,7 +2044,8 @@ After word splitting, unless the @option{-f} option has been set If one of these characters appears, then the word is regarded as a @var{pattern}, and replaced with an alphabetically sorted list of -file names matching the pattern. If no matching file names are found, +file names matching the pattern (@pxref{Pattern Matching}). +If no matching file names are found, and the shell option @code{nullglob} is disabled, the word is left unchanged. If the @code{nullglob} option is set, and no matches are found, the word diff --git a/pathexp.c b/pathexp.c index 42f21e4c8..f23995684 100644 --- a/pathexp.c +++ b/pathexp.c @@ -196,7 +196,7 @@ quote_string_for_globbing (pathname, qflags) { if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/') continue; - if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0) + if (pathname[i+1] != CTLESC && (qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0) continue; temp[j++] = '\\'; i++; diff --git a/pcomplib.c b/pcomplib.c index fe337e4ae..7361bb173 100644 --- a/pcomplib.c +++ b/pcomplib.c @@ -37,7 +37,7 @@ #include "shell.h" #include "pcomplete.h" -#define COMPLETE_HASH_BUCKETS 32 /* must be power of two */ +#define COMPLETE_HASH_BUCKETS 128 /* must be power of two */ #define STRDUP(x) ((x) ? savestring (x) : (char *)NULL) diff --git a/sig.h b/sig.h index 68b5497ce..dd3f81008 100644 --- a/sig.h +++ b/sig.h @@ -96,13 +96,11 @@ do { \ sigprocmask (SIG_BLOCK, &nvar, &ovar); \ } while (0) -#define UNBLOCK_SIGNAL(ovar) sigprocmask (SIG_SETMASK, &ovar, (sigset_t)NULL) +#define UNBLOCK_SIGNAL(ovar) sigprocmask (SIG_SETMASK, &ovar, (sigset_t *) NULL) #if defined (HAVE_POSIX_SIGNALS) -# define BLOCK_CHILD(nvar, ovar) \ - BLOCK_SIGNAL (SIGCHLD, nvar, ovar) -# define UNBLOCK_CHILD(ovar) \ - sigprocmask (SIG_SETMASK, &ovar, (sigset_t *) NULL) +# define BLOCK_CHILD(nvar, ovar) BLOCK_SIGNAL (SIGCHLD, nvar, ovar) +# define UNBLOCK_CHILD(ovar) UNBLOCK_SIGNAL(ovar) #else /* !HAVE_POSIX_SIGNALS */ # define BLOCK_CHILD(nvar, ovar) ovar = sigblock (sigmask (SIGCHLD)) # define UNBLOCK_CHILD(ovar) sigsetmask (ovar) diff --git a/tests/errors.right b/tests/errors.right index 7dd80c415..b3e0125fc 100644 --- a/tests/errors.right +++ b/tests/errors.right @@ -98,4 +98,13 @@ trap: usage: trap [-lp] [[arg] signal_spec ...] ./errors.tests: line 250: kill: `': not a pid or valid job spec kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] ./errors.tests: line 255: set: trackall: invalid option name -./errors.tests: line 262: `!!': not a valid identifier +./errors1.sub: line 1: .: -i: invalid option +.: usage: . filename [arguments] +./errors1.sub: line 9: shift: -4: shift count out of range +./errors1.sub: line 5: return: -1: invalid option +return: usage: return [n] +./errors1.sub: line 14: break: -1: loop count out of range +./errors1.sub: line 20: return: -2: invalid option +return: usage: return [n] +after f +./errors.tests: line 264: `!!': not a valid identifier diff --git a/tests/errors.tests b/tests/errors.tests index 4ead467b1..e339f60df 100644 --- a/tests/errors.tests +++ b/tests/errors.tests @@ -254,6 +254,8 @@ kill -INT # bad shell option names set -o trackall # bash is not ksh +${THIS_SH} ./errors1.sub + # this must be last! # in posix mode, a function name must be a valid identifier # this can't go in posix2.tests, since it causes the shell to exit diff --git a/tests/errors1.sub b/tests/errors1.sub new file mode 100644 index 000000000..8e7440b59 --- /dev/null +++ b/tests/errors1.sub @@ -0,0 +1,27 @@ +. -i /dev/tty + +f() +{ + return -1 +} + +set -- a b c +shift -4 + +f + +for f in 1 2 3; do + break -1 +done + + +f() +{ + return -25 +} + +f +echo after f +exit -25 + +exit -56 diff --git a/tests/read.right b/tests/read.right index d9632a8bb..73cb7042f 100644 --- a/tests/read.right +++ b/tests/read.right @@ -44,6 +44,7 @@ abcde ./read3.sub: line 4: read: -1: invalid number abc ab +abc # while read -u 3 var do diff --git a/tests/read3.sub b/tests/read3.sub index 22088cbf3..af41e3f27 100644 --- a/tests/read3.sub +++ b/tests/read3.sub @@ -15,5 +15,10 @@ echo ab | { echo $xyz } +echo abc | { + read -N 4 -d$'\n' foo + echo $foo +} + read -n 1 < $0 echo "$REPLY"