diff --git a/CHANGES b/CHANGES index a90dfd7a..7a33d78a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,451 @@ +This document details the changes between this version, bash-5.1-alpha, and +the previous version, bash-5.0-release. + +1. Changes to Bash + +a. Fixed a bug that caused a posix-mode shell to not exit if the return builtin + was executed outside a function or dot script. + +b. Fixed a bug where `declare +f' could potentially turn off the function + attribute. + +c. Restored bash-4.4 pathname expansion behavior when a word to be expanded had + only backslashes, not any of the other globbing characters. This came after + an extensive POSIX group discussion (interp #1234). + +d. There are more changes to avoid performing word expansions multiple times on + arithmetic expressions. + +e. Fixed a bug with alias expansion when the alias ends with a TAB. + +f. Fixed a bug that caused programmable completion to return an error if the + shell function name supplied as an argument to `complete -F' was invalid. + +g. There are several fixes to buffer overflows found as the result of fuzzing + with random input. + +h. Fixed a bug that caused the edit-and-execute-command editing command to + start with the previous history line if invoked on an empty line. + +i. Fixed a bug that potentially caused `bind --help' to change readline's + output stream. + +j. Turning off posix mode now restores the vi-insertion mode binding for TAB + that was in effect when posix mode was enabled. + +k. Restore the previous state of job control being enabled if `exec' fails in + an interactive shell. + +l. Fixed a bug that caused the terminal's process group to be set incorrectly + if job control was turned off before starting an interactive shell. + +m. Fixed a bug that caused a crash when HISTSIZE=0. + +n. Fixed a word expansion bug that caused null strings on the rhs of expansions + to be discarded incorrectly. + +o. History list management does a better job of handling the situation where + the number of history entries from the current shell session is greater than + the number of entries in the history list. + +p. Fixed a bug that caused the `fc' builtin to attempt to dereference a newly- + freed history entry. + +q. Fixed a bug that made the `Q' variable transformation not work well with + `set -u'. + +r. There are several word expansion fixes for expanding $* and $@ in contexts + where word splitting is not going to be performed, since each positional + parameter must expand to a separate word. + +s. Fixed a bug that could cause ^D to exit bash immediately even if there were + stopped jobs. + +t. Fixed a bug with double-quoting and backslash-quoting strings containing + multibyte characters for reuse. + +u. Fixed a bug that caused the line number to be reported incorrectly if the + shell executed a (command) subshell. + +v. Fixed a bug that caused the shell to fail to reap process substitutions + when they went out of scope, which had unpredictable results. + +w. Fixed a bug that caused null strings in arguments to [[ conditional command + operators to compare incorrectly. + +x. Changed the behavior of `wait' without arguments to only wait for background + processes the current shell instance started, not background children it may + have inherited. + +y. Fixed a bug that could cause command substitution to leave file descriptors + open if the shell received many SIGINTs. + +z. Bash now behaves better if the `**' filename expansion operator encounters a + symbolic link to a directory, avoiding more cases where it might return + duplicate pathnames. + +aa. Programmable completion now canonicalizes directory names in the same way + as bash word completion, so `..' is handled consistently. + +bb. Fixed a bug when using RETURN as the delimiter to the read builtin; it + caused readline to set the binding for RETURN incorrectly. + +cc. Fixed a bug that caused `history -d' to delay printing an out-of-range + error message. + +dd. Fixed a bug with `bash -c command' where `command' ends with an expanded + alias. + +ee. Fixed a bug that could result in `history -n' adding spurious line feeds to + commands in the history list. + +ff. The $RANDOM random number generator now XORs the top and bottom halves of + the internal 32-bit value to introduce more randomness. + +gg. Fixed several problems caused by running the DEBUG trap on simple commands + executed as part of a pipeline. + +ii. Fixed a bug that didn't allow `bind -r' to remove the binding for \C-@. + +jj. Several fixes to the bash-backward-shellword bindable readline command to + behave better when at the last character on the line. + +kk. If `set -x' is enabled, bash doesn't print a command twice if it's run by + the `command' builtin. + +ll. Fixed a bug with printing function definitions containing here documents. + +mm. Fixed a bug that could cause the `bind' builtin to set $? to -1. + +nn. Fixed a bug that didn't reset the timezone information correctly when the + TZ variable was unset. + +oo. Fixed several issues with assigning an associative array variable using a + compound assignment that expands the value of the same variable. + +pp. Fixed several places where the shell set $? without setting PIPESTATUS. + +qq. Fixed a problem with glob bracket expressions containing invalid character + classes, collating symbols, or equivalence classes -- they should not + require a closing right bracket. + +rr. Fixed a bug where running a builtin in a subshell did not run the EXIT trap. + +ss. Fixed several problems with posix-mode variable assignments preceding + shell function calls and posix special builtins, so that they create and + modify variables at the current scope. + +tt. Fix history initialization so `bash +o history' works as expected. + +uu. Fixed a bug in the bindable edit-and-execute-command command that could + interfere with the shell's parsing state. + +vv. Fixed an issue with nested traps running command substitutions in command + lines with command substitutions. + +ww. Fixed a bug with globbing pathnames that contain invalid multibyte + characters (sequences that don't correspond to a character in the current + locale). + +xx. Fixed a bug that caused the shell not to exit if a function definition + failed while errexit was enabled. + +yy. Process substitution processes now get their input from /dev/null, since + they are asynchronous, not interactive, and not jobs. + +zz. Setting nocaseglob no longer turns on case-insensitive regexp matching. + +aaa. Fixed a bug that resulted in extra blank lines being added to some history + entries containing here-documents. + +bbb. Fixed a bug that resulted in incorrect matching of some patterns in word + expansion if they expanded to the empty string. + +ccc. Fixed here-string expansion so it behaves the same as expansion of the + rhs of an assignment statement. + +ddd. Changed here-document parsing to no longer allow the end of the here + document to delimit a command substitution. + +eee. Several fixes to history expansion: multiple :p modifiers work, a ^ word + designator works as part of a range, and a `-' is treated as part of a + search string if it immediately follows a `!'. + +fff. Fixed a bug in pattern substitution with null matches in a string + containing multibyte characters. + +ggg. Unbinding a key sequence bound with `bind -x' now removes the key sequence + from the additional keymap `bind -x' uses. + +hhh. Fixed a bug with command start detection for completion so that it doesn't + mistake brace expansion for the start of a command. + +iii. Fixed a bug that caused local variables with the same name as variables + appearing in a function's temporary environment to not be marked as local. + +jjj. Fixed a bug that could cause SIGCHLD to be blocked when executing return + or exec in the rightmost pipeline element with lastpipe enabled. + +kkk. Fixed a bug that could result in commands without the execute bit set + being added to the command hash table. + +lll. Fixed a bug that allowed non-digits to follow the `#' in a `base#number' + integer constant. + +mmm. Fixed a bug that made `time -- command' attempt to execute `--'. + +nnn. Fixed a couple of bugs with variable transformation using arrays + subscripted with `*' or `@'. + +ooo. A failure to create a variable using `declare' in a function no longer + causes the function to return immediately. + +ppp. Fixed a bug that could cause the := word expansion to add a non-null + value if attempting to assign a null string when double-quoted. + +qqq. Fixed a bug that could cause backslashes quoting double quotes in here + document bodies to not be removed when expanding the body. + +rrr. Fixed a bug that caused commands following a subshell while the shell is + reading input from stdin but not interactive, while job control is + enabled, to be executed twice. + +sss. Fixed a bug where receiving SIGTERM from a different process while + readline was active could cause the shell to terminate. + +ttt. In posix mode, running a trap after the read builtin now sees the exit + status of the read builtin (e.g., 130 after a SIGINT) in $?. + +uuu. Fixed a bug with nameref variables referencing array subscripts used in + arithmetic expressions. + +vvv. Fixed a bug that caused the pipeline process group id to be reset in the + middle of a command list run by a shell started to run a command + substitution. + +www. Restricted shells can no longer read and write history files with pathnames + containing slashes. + +xxx. Fixed a couple of problems with 0 and -0 used as arguments to `fc' when + not listing commands from the history. + +yyy. When `test' is supplied four or more arguments, treat an argument that + looks like an operator (e.g., -e), but is in a place where only a string + is valid, as a string, as it would be when using the POSIX rules, instead + of an operator with a missing argument. + +2. Changes to Readline + +a. There are a number of fixes that were found as the result of fuzzing with + random input. + +b. Changed the revert-all-at-newline behavior to make sure to start at the end + of the history list when doing it, instead of the line where the user hit + return. + +c. When parsing `set' commands from the inputrc file or an application, readline + now allows trailing whitespace. + +d. Fixed a bug that left a file descriptor open to the history file if the + file size was 0. + +e. Fixed a problem with binding key sequences containing meta characters. + +f. Fixed a bug that caused the wrong line to be displayed if the user tried to + move back beyond the beginning of the history list, or forward past the end + of the history list. + +g. If readline catches SIGTSTP, it now sets a hook that allows the calling + application to handle it if it desires. + +h. Fixed a redisplay problem with a prompt string containing embedded newlines. + +i. Fixed a problem with completing filenames containing invalid multibyte + sequences when case-insensitive comparisons are enabled. + +j. Fixed a redisplay problem with prompt strings containing invisible multibyte + characters. + +k. Fixed a problem with multibyte characters mapped to editing commands that + modify the search string in incremental search. + +l. Fixed a bug with maintaining the key sequence while resolving a bound + command in the presence of ambiguous sequences (sequences with a common + prefix), in most cases while attempting to unbind it. + +m. Fixed several buffer overflows found as the result of fuzzing. + +n. Reworked backslash handling when translating key sequences for key binding + to be more uniform and consistent, which introduces a slight backwards + incompatibility. + +o. Fixed a bug with saving the history that resulted in errors not being + propagated to the calling application when the history file is not writable. + +p. Readline only calls chown(2) on a newly-written history file if it really + needs to, instead of having it be a no-op. + +q. Readline now behaves better when operate-and-get-next is used when the + history list is `full': when there are already $HISTSIZE entries. + +3. New Features in Bash + +a. `bind -x' now supports different bindings for different editing modes and + keymaps. + +b. Bash attempts to optimize the number of times it forks when executing + commands in subshells and from `bash -c'. + +c. Here documents and here strings now use pipes for the expanded document if + it's smaller than the pipe buffer size, reverting to temporary files if it's + larger. + +d. There are new loadable builtins: mktemp, accept, mkfifo, csv, cut/lcut + +e. In posix mode, `trap -p' now displays signals whose disposition is SIG_DFL + and those that were SIG_IGN when the shell starts. + +f. The shell now expands the history number (e.g., in PS1) even if it is not + currently saving commands to the history list. + +g. `read -e' may now be used with arbitrary file descriptors (`read -u N'). + +h. The `select' builtin now runs traps if its internal call to the read builtin + is interrupted by a signal. + +i. SRANDOM: a new variable that expands to a 32-bit random number that is not + produced by an LCRNG, and uses /dev/urandom or arc4random if available. + +j. shell-transpose-words: a new bindable readline command that uses the same + definition of word as shell-forward-word, etc. + +k. The shell now adds default bindings for shell-forward-word, + shell-backward-word, shell-transpose-words, and shell-kill-word. + +l. Bash now allows ARGV0 appearing in the initial shell environment to set $0. + +m. If `unset' is executed without option arguments, bash tries to unset a shell + function if a name argument cannot be a shell variable name because it's not + an identifier. + +n. The `test -N' operator uses nanosecond timestamp granularity if it's + available. + +o. Bash posix mode now treats assignment statements preceding shell function + definitions the same as in its default mode, since POSIX has changed and + no longer requires those assignments to persist after the function returns + (POSIX interp 654). + +p. BASH_REMATCH is no longer readonly. + +q. wait: has a new -p VARNAME option, which stores the PID returned by `wait -n' + or `wait' without arguments. + +r. Sorting the results of pathname expansion now uses byte-by-byte comparisons + if two strings collate equally to impose a total order; the result of a + POSIX interpretation. + +s. Bash now allows SIGINT trap handlers to execute recursively. + +t. Bash now saves and restores state around setting and unsetting posix mode, + instead of having unsetting posix mode set a known state. + +u. Process substitution is now available in posix mode. + +v. READLINE_MARK: a new variable available while executing commands bound with + `bind -x', contains the value of the mark. + +w. Bash removes SIGCHLD from the set of blocked signals if it's blocked at shell + startup. + +x. `test -v N' can now test whether or not positional parameter N is set. + +y. `local' now honors the `-p' option to display all local variables at the + current context. + +z. The `@a' variable transformation now prints attributes for unset array + variables. + +aa. The `@A' variable transformation now prints a declare command that sets a + variable's attributes if the variable has attributes but is unset. + +bb. `declare' and `local' now have a -I option that inherits attributes and + value from a variable with the same name at a previous scope. + +cc. When run from a -c command, `jobs' now reports the status of completed jobs. + +dd. New `U', `u', and `L' parameter transformations to convert to uppercase, + convert first character to uppercase, and convert to lowercase, + respectively. + +ee. PROMPT_COMMANDS: a new array variable, each element of which can contain a + command to be executed like PROMPT_COMMAND. + +ff. `ulimit' has a -R option to report and set the RLIMIT_RTTIME resource. + +gg. Associative arrays may be assigned using a list of key-value pairs within + a compound assignment. Compound assignments where the words are not of + the form [key]=value are assumed to be key-value assignments. A missing or + empty key is an error; a missing value is treated as NULL. Assignments may + not mix the two forms. + +hh. New `K' parameter transformation to display associative arrays as key- + value pairs. + +ii. Writing history to syslog now handles messages longer than the syslog max + length by writing multiple messages with a sequence number. + +jj. SECONDS and RANDOM may now be assigned using arithmetic expressions, since + they are nominally integer variables. LINENO is not an integer variable. + +kk. Bash temporarily suppresses the verbose option when running the DEBUG trap + while running a command from the `fc' builtin. + +ll. `wait -n' now accepts a list of job specifications as arguments and will + wait for the first one in the list to change state. + +mm. The associative array implementation can now dynamically increase the + size of the hash table based on insertion patterns. + +nn. Posix-mode shells no longer allow the closing right paren in a command + substitution to delimit a pending here-document -- the newline is required. + +oo. HISTFILE is now readonly in a restricted shell. + +4. New Features in Readline + +a. If a second consecutive completion attempt produces matches where the first + did not, treat it as a new completion attempt and insert a match as + appropriate. + +b. Bracketed paste mode works in more places: incremental search strings, vi + overstrike mode, character search, and reading numeric arguments. + +c. Readline automatically switches to horizontal scrolling if the terminal has + only one line. + +d. Unbinding all key sequences bound to a particular readline function now + descends into keymaps for multi-key sequences. + +e. rl-clear-display: new bindable command that clears the screen and, if + possible, the scrollback buffer (bound to emacs mode M-C-l by default). + +f. New active mark and face feature: when enabled, it will highlight the text + inserted by a bracketed paste (the `active region') and the text found by + incremental and non-incremental history searches. + +g. Readline sets the mark in several additional commands. + +h. Bracketed paste mode is enabled by default (for now). + +i. Readline tries to take advantage of the more regular structure of UTF-8 + characters to identify the beginning and end of characters when moving + through the line buffer. + +j. The bindable operate-and-get-next command (and its default bindings) are + now part of readline instead of a bash-specific addition. + +------------------------------------------------------------------------------ This document details the changes between this version, bash-5.0-release, and the previous version, bash-5.0-rc1. diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 1a2b10ee..e93a215c 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -8360,3 +8360,23 @@ test.c - test_command: if there are unconsumed arguments, call test_syntax_error with a `syntax error' argument if the first remaining argument starts with a `-'. Better than a generic `too many arguments' error + + 5/19 + ---- +configure.ac,config.h.in + - getrandom: add test, define HAVE_GETRANDOM + - getentropy: add test, define HAVE_GETENTROPY + +variables.c + - get_urand32: use getrandom; provide imperfect emulation that uses + getentropy if available, and falls back to reading /dev/urandom if + that's not available. The idea is to use /dev/urandom as little as + possible + + 5/20 + ---- +configure.ac + - updated version to 5.1-alpha + +lib/readline/readline.h + - updated defines to readline version 8.1 diff --git a/array.h b/array.h index a610de7c..dc9f564e 100644 --- a/array.h +++ b/array.h @@ -1,7 +1,7 @@ /* array.h -- definitions for the interface exported by array.c that allows the rest of the shell to manipulate array variables. */ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. +/* Copyright (C) 1997-2009 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -43,53 +43,53 @@ typedef struct array_element { struct array_element *next, *prev; } ARRAY_ELEMENT; -typedef int sh_ae_map_func_t PARAMS((ARRAY_ELEMENT *, void *)); +typedef int sh_ae_map_func_t __P((ARRAY_ELEMENT *, void *)); /* Basic operations on entire arrays */ -extern ARRAY *array_create PARAMS((void)); -extern void array_flush PARAMS((ARRAY *)); -extern void array_dispose PARAMS((ARRAY *)); -extern ARRAY *array_copy PARAMS((ARRAY *)); -extern ARRAY *array_slice PARAMS((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *)); -extern void array_walk PARAMS((ARRAY *, sh_ae_map_func_t *, void *)); +extern ARRAY *array_create __P((void)); +extern void array_flush __P((ARRAY *)); +extern void array_dispose __P((ARRAY *)); +extern ARRAY *array_copy __P((ARRAY *)); +extern ARRAY *array_slice __P((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *)); +extern void array_walk __P((ARRAY *, sh_ae_map_func_t *, void *)); -extern ARRAY_ELEMENT *array_shift PARAMS((ARRAY *, int, int)); -extern int array_rshift PARAMS((ARRAY *, int, char *)); -extern ARRAY_ELEMENT *array_unshift_element PARAMS((ARRAY *)); -extern int array_shift_element PARAMS((ARRAY *, char *)); +extern ARRAY_ELEMENT *array_shift __P((ARRAY *, int, int)); +extern int array_rshift __P((ARRAY *, int, char *)); +extern ARRAY_ELEMENT *array_unshift_element __P((ARRAY *)); +extern int array_shift_element __P((ARRAY *, char *)); -extern ARRAY *array_quote PARAMS((ARRAY *)); -extern ARRAY *array_quote_escapes PARAMS((ARRAY *)); -extern ARRAY *array_dequote PARAMS((ARRAY *)); -extern ARRAY *array_dequote_escapes PARAMS((ARRAY *)); -extern ARRAY *array_remove_quoted_nulls PARAMS((ARRAY *)); +extern ARRAY *array_quote __P((ARRAY *)); +extern ARRAY *array_quote_escapes __P((ARRAY *)); +extern ARRAY *array_dequote __P((ARRAY *)); +extern ARRAY *array_dequote_escapes __P((ARRAY *)); +extern ARRAY *array_remove_quoted_nulls __P((ARRAY *)); -extern char *array_subrange PARAMS((ARRAY *, arrayind_t, arrayind_t, int, int, int)); -extern char *array_patsub PARAMS((ARRAY *, char *, char *, int)); -extern char *array_modcase PARAMS((ARRAY *, char *, int, int)); +extern char *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int, int, int)); +extern char *array_patsub __P((ARRAY *, char *, char *, int)); +extern char *array_modcase __P((ARRAY *, char *, int, int)); /* Basic operations on array elements. */ -extern ARRAY_ELEMENT *array_create_element PARAMS((arrayind_t, char *)); -extern ARRAY_ELEMENT *array_copy_element PARAMS((ARRAY_ELEMENT *)); -extern void array_dispose_element PARAMS((ARRAY_ELEMENT *)); +extern ARRAY_ELEMENT *array_create_element __P((arrayind_t, char *)); +extern ARRAY_ELEMENT *array_copy_element __P((ARRAY_ELEMENT *)); +extern void array_dispose_element __P((ARRAY_ELEMENT *)); -extern int array_insert PARAMS((ARRAY *, arrayind_t, char *)); -extern ARRAY_ELEMENT *array_remove PARAMS((ARRAY *, arrayind_t)); -extern char *array_reference PARAMS((ARRAY *, arrayind_t)); +extern int array_insert __P((ARRAY *, arrayind_t, char *)); +extern ARRAY_ELEMENT *array_remove __P((ARRAY *, arrayind_t)); +extern char *array_reference __P((ARRAY *, arrayind_t)); /* Converting to and from arrays */ -extern WORD_LIST *array_to_word_list PARAMS((ARRAY *)); -extern ARRAY *array_from_word_list PARAMS((WORD_LIST *)); -extern WORD_LIST *array_keys_to_word_list PARAMS((ARRAY *)); +extern WORD_LIST *array_to_word_list __P((ARRAY *)); +extern ARRAY *array_from_word_list __P((WORD_LIST *)); +extern WORD_LIST *array_keys_to_word_list __P((ARRAY *)); -extern ARRAY *array_assign_list PARAMS((ARRAY *, WORD_LIST *)); +extern ARRAY *array_assign_list __P((ARRAY *, WORD_LIST *)); -extern char **array_to_argv PARAMS((ARRAY *)); +extern char **array_to_argv __P((ARRAY *)); -extern char *array_to_kvpair PARAMS((ARRAY *, int)); -extern char *array_to_assign PARAMS((ARRAY *, int)); -extern char *array_to_string PARAMS((ARRAY *, char *, int)); -extern ARRAY *array_from_string PARAMS((char *, char *)); +extern char *array_to_kvpair __P((ARRAY *, int)); +extern char *array_to_assign __P((ARRAY *, int)); +extern char *array_to_string __P((ARRAY *, char *, int)); +extern ARRAY *array_from_string __P((char *, char *)); /* Flags for array_shift */ #define AS_DISPOSE 0x01 diff --git a/config.h.in b/config.h.in index b16c22e1..ab316d46 100644 --- a/config.h.in +++ b/config.h.in @@ -634,6 +634,9 @@ /* Define if you have the getcwd function. */ #undef HAVE_GETCWD +/* Define if you have the getentropy function. */ +#undef HAVE_GETENTROPY + /* Define if you have the getdtablesize function. */ #undef HAVE_GETDTABLESIZE @@ -661,6 +664,9 @@ /* Define if you have the getpwuid function. */ #undef HAVE_GETPWUID +/* Define if you have the getrandom function. */ +#undef HAVE_GETRANDOM + /* Define if you have the getrlimit function. */ #undef HAVE_GETRLIMIT @@ -1065,6 +1071,9 @@ /* Define if you have the header file. */ #undef HAVE_SYS_PTEM_H +/* Define if you have the header file. */ +#undef HAVE_SYS_RANDOM_H + /* Define if you have the header file. */ #undef HAVE_SYS_RESOURCE_H diff --git a/configure b/configure index a9287a14..4b40f576 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac for Bash 5.0, version 5.015. +# From configure.ac for Bash 5.0, version 5.017. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for bash 5.0-maint. # @@ -13342,7 +13342,7 @@ fi done for ac_header in sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \ - sys/mman.h sys/param.h sys/socket.h sys/stat.h \ + sys/mman.h sys/param.h sys/random.h sys/socket.h sys/stat.h \ sys/time.h sys/times.h sys/types.h sys/wait.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -13874,10 +13874,10 @@ else fi -for ac_func in dup2 eaccess fcntl getdtablesize getgroups gethostname \ - getpagesize getpeername getrlimit getrusage gettimeofday \ - kill killpg lstat pselect readlink select setdtablesize \ - setitimer tcgetpgrp uname ulimit waitpid +for ac_func in dup2 eaccess fcntl getdtablesize getentropy getgroups \ + gethostname getpagesize getpeername getrandom getrlimit \ + getrusage gettimeofday kill killpg lstat pselect readlink \ + select setdtablesize setitimer tcgetpgrp uname ulimit waitpid 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" diff --git a/configure.ac b/configure.ac index 019c6629..4bcdd530 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ dnl -dnl Configure script for bash-5.0 +dnl Configure script for bash-5.1 dnl dnl report bugs to chet@po.cwru.edu dnl @@ -21,10 +21,10 @@ 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.015])dnl +AC_REVISION([for Bash 5.1, version 5.017])dnl -define(bashvers, 5.0) -define(relstatus, maint) +define(bashvers, 5.1) +define(relstatus, alpha) AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org]) @@ -753,7 +753,7 @@ AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \ stdbool.h stddef.h stdint.h netdb.h pwd.h grp.h strings.h \ regex.h syslog.h ulimit.h) AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \ - sys/mman.h sys/param.h sys/socket.h sys/stat.h \ + sys/mman.h sys/param.h sys/random.h sys/socket.h sys/stat.h \ sys/time.h sys/times.h sys/types.h sys/wait.h) AC_CHECK_HEADERS(netinet/in.h arpa/inet.h) @@ -819,10 +819,10 @@ dnl checks for missing libc functions AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING)) dnl checks for system calls -AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getgroups gethostname \ - getpagesize getpeername getrlimit getrusage gettimeofday \ - kill killpg lstat pselect readlink select setdtablesize \ - setitimer tcgetpgrp uname ulimit waitpid) +AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getentropy getgroups \ + gethostname getpagesize getpeername getrandom getrlimit \ + getrusage gettimeofday kill killpg lstat pselect readlink \ + select setdtablesize setitimer tcgetpgrp uname ulimit waitpid) AC_REPLACE_FUNCS(rename) dnl checks for c library functions diff --git a/doc/bash.1 b/doc/bash.1 index 70871cbe..b5031441 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -1187,6 +1187,9 @@ not been present. .PP A double-quoted string preceded by a dollar sign (\fB$\fP\(dq\fIstring\fP\(dq) will cause the string to be translated according to the current locale. +The \fIgettext\fP infrastructure performs the message catalog lookup and +translation, using the \fBLC_MESSAGES\fP and \fBTEXTDOMAIN\fP shell +variables. If the current locale is \fBC\fP or \fBPOSIX\fP, or if there are no translations available, the dollar sign is ignored. diff --git a/doc/bashref.texi b/doc/bashref.texi index 394d0b02..1308d852 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -535,6 +535,10 @@ been present. A double-quoted string preceded by a dollar sign (@samp{$}) will cause the string to be translated according to the current locale. +The @var{gettext} infrastructure performs the message catalog lookup and +translation, using the @code{LC_MESSAGES} and @code{TEXTDOMAIN} shell +variables, as explained below. See the gettext documentation for additional +details. If the current locale is @code{C} or @code{POSIX}, or if there are no translations available, the dollar sign is ignored. diff --git a/examples/loadables/TODO b/examples/loadables/TODO index 12767acd..1b8ca44d 100644 --- a/examples/loadables/TODO +++ b/examples/loadables/TODO @@ -1,5 +1,3 @@ cmp wc paste - -cut diff --git a/general.h b/general.h index 7e4db8e6..28b45cab 100644 --- a/general.h +++ b/general.h @@ -1,6 +1,6 @@ /* general.h -- defines that everybody likes to use. */ -/* Copyright (C) 1993-2020 Free Software Foundation, Inc. +/* Copyright (C) 1993-2016 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -62,7 +62,7 @@ extern char *strchr (), *strrchr (); #endif #if !defined (strcpy) && (defined (HAVE_DECL_STRCPY) && !HAVE_DECL_STRCPY) -extern char *strcpy PARAMS((char *, const char *)); +extern char *strcpy __P((char *, const char *)); #endif #if !defined (savestring) @@ -205,43 +205,43 @@ typedef char **CPPFunction (); /* no longer used */ /* Shell function typedefs with prototypes */ /* `Generic' function pointer typedefs */ -typedef int sh_intfunc_t PARAMS((int)); -typedef int sh_ivoidfunc_t PARAMS((void)); -typedef int sh_icpfunc_t PARAMS((char *)); -typedef int sh_icppfunc_t PARAMS((char **)); -typedef int sh_iptrfunc_t PARAMS((PTR_T)); +typedef int sh_intfunc_t __P((int)); +typedef int sh_ivoidfunc_t __P((void)); +typedef int sh_icpfunc_t __P((char *)); +typedef int sh_icppfunc_t __P((char **)); +typedef int sh_iptrfunc_t __P((PTR_T)); -typedef void sh_voidfunc_t PARAMS((void)); -typedef void sh_vintfunc_t PARAMS((int)); -typedef void sh_vcpfunc_t PARAMS((char *)); -typedef void sh_vcppfunc_t PARAMS((char **)); -typedef void sh_vptrfunc_t PARAMS((PTR_T)); +typedef void sh_voidfunc_t __P((void)); +typedef void sh_vintfunc_t __P((int)); +typedef void sh_vcpfunc_t __P((char *)); +typedef void sh_vcppfunc_t __P((char **)); +typedef void sh_vptrfunc_t __P((PTR_T)); -typedef int sh_wdesc_func_t PARAMS((WORD_DESC *)); -typedef int sh_wlist_func_t PARAMS((WORD_LIST *)); +typedef int sh_wdesc_func_t __P((WORD_DESC *)); +typedef int sh_wlist_func_t __P((WORD_LIST *)); -typedef int sh_glist_func_t PARAMS((GENERIC_LIST *)); +typedef int sh_glist_func_t __P((GENERIC_LIST *)); -typedef char *sh_string_func_t PARAMS((char *)); /* like savestring, et al. */ +typedef char *sh_string_func_t __P((char *)); /* like savestring, et al. */ -typedef int sh_msg_func_t PARAMS((const char *, ...)); /* printf(3)-like */ -typedef void sh_vmsg_func_t PARAMS((const char *, ...)); /* printf(3)-like */ +typedef int sh_msg_func_t __P((const char *, ...)); /* printf(3)-like */ +typedef void sh_vmsg_func_t __P((const char *, ...)); /* printf(3)-like */ /* Specific function pointer typedefs. Most of these could be done with #defines. */ -typedef void sh_sv_func_t PARAMS((char *)); /* sh_vcpfunc_t */ -typedef void sh_free_func_t PARAMS((PTR_T)); /* sh_vptrfunc_t */ -typedef void sh_resetsig_func_t PARAMS((int)); /* sh_vintfunc_t */ +typedef void sh_sv_func_t __P((char *)); /* sh_vcpfunc_t */ +typedef void sh_free_func_t __P((PTR_T)); /* sh_vptrfunc_t */ +typedef void sh_resetsig_func_t __P((int)); /* sh_vintfunc_t */ -typedef int sh_ignore_func_t PARAMS((const char *)); /* sh_icpfunc_t */ +typedef int sh_ignore_func_t __P((const char *)); /* sh_icpfunc_t */ -typedef int sh_assign_func_t PARAMS((const char *)); -typedef int sh_wassign_func_t PARAMS((WORD_DESC *, int)); +typedef int sh_assign_func_t __P((const char *)); +typedef int sh_wassign_func_t __P((WORD_DESC *, int)); -typedef int sh_load_func_t PARAMS((char *)); -typedef void sh_unload_func_t PARAMS((char *)); +typedef int sh_load_func_t __P((char *)); +typedef void sh_unload_func_t __P((char *)); -typedef int sh_builtin_func_t PARAMS((WORD_LIST *)); /* sh_wlist_func_t */ +typedef int sh_builtin_func_t __P((WORD_LIST *)); /* sh_wlist_func_t */ #endif /* SH_FUNCTION_TYPEDEF */ @@ -295,77 +295,77 @@ typedef int QSFUNC (); #if 0 /* Declarations for functions defined in xmalloc.c */ -extern PTR_T xmalloc PARAMS((size_t)); -extern PTR_T xrealloc PARAMS((void *, size_t)); -extern void xfree PARAMS((void *)); +extern PTR_T xmalloc __P((size_t)); +extern PTR_T xrealloc __P((void *, size_t)); +extern void xfree __P((void *)); #endif /* Declarations for functions defined in general.c */ -extern void posix_initialize PARAMS((int)); +extern void posix_initialize __P((int)); -extern int num_posix_options PARAMS((void)); -extern char *get_posix_options PARAMS((char *)); -extern void set_posix_options PARAMS((const char *)); +extern int num_posix_options __P((void)); +extern char *get_posix_options __P((char *)); +extern void set_posix_options __P((const char *)); -extern void save_posix_options PARAMS((void)); +extern void save_posix_options __P((void)); #if defined (RLIMTYPE) -extern RLIMTYPE string_to_rlimtype PARAMS((char *)); -extern void print_rlimtype PARAMS((RLIMTYPE, int)); +extern RLIMTYPE string_to_rlimtype __P((char *)); +extern void print_rlimtype __P((RLIMTYPE, int)); #endif -extern int all_digits PARAMS((const char *)); -extern int legal_number PARAMS((const char *, intmax_t *)); -extern int legal_identifier PARAMS((const char *)); -extern int importable_function_name PARAMS((const char *, size_t)); -extern int exportable_function_name PARAMS((const char *)); -extern int check_identifier PARAMS((WORD_DESC *, int)); -extern int valid_nameref_value PARAMS((const char *, int)); -extern int check_selfref PARAMS((const char *, char *, int)); -extern int legal_alias_name PARAMS((const char *, int)); -extern int line_isblank PARAMS((const char *)); -extern int assignment PARAMS((const char *, int)); +extern int all_digits __P((const char *)); +extern int legal_number __P((const char *, intmax_t *)); +extern int legal_identifier __P((const char *)); +extern int importable_function_name __P((const char *, size_t)); +extern int exportable_function_name __P((const char *)); +extern int check_identifier __P((WORD_DESC *, int)); +extern int valid_nameref_value __P((const char *, int)); +extern int check_selfref __P((const char *, char *, int)); +extern int legal_alias_name __P((const char *, int)); +extern int line_isblank __P((const char *)); +extern int assignment __P((const char *, int)); -extern int sh_unset_nodelay_mode PARAMS((int)); -extern int sh_setclexec PARAMS((int)); -extern int sh_validfd PARAMS((int)); -extern int fd_ispipe PARAMS((int)); -extern void check_dev_tty PARAMS((void)); -extern int move_to_high_fd PARAMS((int, int, int)); -extern int check_binary_file PARAMS((const char *, int)); +extern int sh_unset_nodelay_mode __P((int)); +extern int sh_setclexec __P((int)); +extern int sh_validfd __P((int)); +extern int fd_ispipe __P((int)); +extern void check_dev_tty __P((void)); +extern int move_to_high_fd __P((int, int, int)); +extern int check_binary_file __P((const char *, int)); #ifdef _POSIXSTAT_H_ -extern int same_file PARAMS((const char *, const char *, struct stat *, struct stat *)); +extern int same_file __P((const char *, const char *, struct stat *, struct stat *)); #endif -extern int sh_openpipe PARAMS((int *)); -extern int sh_closepipe PARAMS((int *)); +extern int sh_openpipe __P((int *)); +extern int sh_closepipe __P((int *)); -extern int file_exists PARAMS((const char *)); -extern int file_isdir PARAMS((const char *)); -extern int file_iswdir PARAMS((const char *)); -extern int path_dot_or_dotdot PARAMS((const char *)); -extern int absolute_pathname PARAMS((const char *)); -extern int absolute_program PARAMS((const char *)); +extern int file_exists __P((const char *)); +extern int file_isdir __P((const char *)); +extern int file_iswdir __P((const char *)); +extern int path_dot_or_dotdot __P((const char *)); +extern int absolute_pathname __P((const char *)); +extern int absolute_program __P((const char *)); -extern char *make_absolute PARAMS((const char *, const char *)); -extern char *base_pathname PARAMS((char *)); -extern char *full_pathname PARAMS((char *)); -extern char *polite_directory_format PARAMS((char *)); -extern char *trim_pathname PARAMS((char *, int)); -extern char *printable_filename PARAMS((char *, int)); +extern char *make_absolute __P((const char *, const char *)); +extern char *base_pathname __P((char *)); +extern char *full_pathname __P((char *)); +extern char *polite_directory_format __P((char *)); +extern char *trim_pathname __P((char *, int)); +extern char *printable_filename __P((char *, int)); -extern char *extract_colon_unit PARAMS((char *, int *)); +extern char *extract_colon_unit __P((char *, int *)); -extern void tilde_initialize PARAMS((void)); -extern char *bash_tilde_find_word PARAMS((const char *, int, int *)); -extern char *bash_tilde_expand PARAMS((const char *, int)); +extern void tilde_initialize __P((void)); +extern char *bash_tilde_find_word __P((const char *, int, int *)); +extern char *bash_tilde_expand __P((const char *, int)); -extern int group_member PARAMS((gid_t)); -extern char **get_group_list PARAMS((int *)); -extern int *get_group_array PARAMS((int *)); +extern int group_member __P((gid_t)); +extern char **get_group_list __P((int *)); +extern int *get_group_array __P((int *)); -extern char *conf_standard_path PARAMS((void)); -extern int default_columns PARAMS((void)); +extern char *conf_standard_path __P((void)); +extern int default_columns __P((void)); #endif /* _GENERAL_H_ */ diff --git a/lib/readline/readline.h b/lib/readline/readline.h index 8e6ec537..78fa39d0 100644 --- a/lib/readline/readline.h +++ b/lib/readline/readline.h @@ -39,9 +39,9 @@ extern "C" { #endif /* Hex-encoded Readline version number. */ -#define RL_READLINE_VERSION 0x0800 /* Readline 8.0 */ +#define RL_READLINE_VERSION 0x0801 /* Readline 8.0 */ #define RL_VERSION_MAJOR 8 -#define RL_VERSION_MINOR 0 +#define RL_VERSION_MINOR 1 /* Readline data structures. */ diff --git a/unwind_prot.c b/unwind_prot.c index 664e3a9b..c9196dc1 100644 --- a/unwind_prot.c +++ b/unwind_prot.c @@ -3,7 +3,7 @@ /* I can't stand it anymore! Please can't we just write the whole Unix system in lisp or something? */ -/* Copyright (C) 1987-2020 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -76,15 +76,15 @@ typedef union uwp { } sv; } UNWIND_ELT; -static void without_interrupts PARAMS((VFunction *, char *, char *)); -static void unwind_frame_discard_internal PARAMS((char *, char *)); -static void unwind_frame_run_internal PARAMS((char *, char *)); -static void add_unwind_protect_internal PARAMS((Function *, char *)); -static void remove_unwind_protect_internal PARAMS((char *, char *)); -static void run_unwind_protects_internal PARAMS((char *, char *)); -static void clear_unwind_protects_internal PARAMS((char *, char *)); -static inline void restore_variable PARAMS((SAVED_VAR *)); -static void unwind_protect_mem_internal PARAMS((char *, char *)); +static void without_interrupts __P((VFunction *, char *, char *)); +static void unwind_frame_discard_internal __P((char *, char *)); +static void unwind_frame_run_internal __P((char *, char *)); +static void add_unwind_protect_internal __P((Function *, char *)); +static void remove_unwind_protect_internal __P((char *, char *)); +static void run_unwind_protects_internal __P((char *, char *)); +static void clear_unwind_protects_internal __P((char *, char *)); +static inline void restore_variable __P((SAVED_VAR *)); +static void unwind_protect_mem_internal __P((char *, char *)); static UNWIND_ELT *unwind_protect_list = (UNWIND_ELT *)NULL; diff --git a/unwind_prot.h b/unwind_prot.h index 97b3af90..cbfc97ca 100644 --- a/unwind_prot.h +++ b/unwind_prot.h @@ -1,6 +1,6 @@ /* unwind_prot.h - Macros and functions for hacking unwind protection. */ -/* Copyright (C) 1993-2020 Free Software Foundation, Inc. +/* Copyright (C) 1993-2009 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -21,26 +21,26 @@ #if !defined (_UNWIND_PROT_H) #define _UNWIND_PROT_H -extern void uwp_init PARAMS((void)); +extern void uwp_init __P((void)); /* Run a function without interrupts. */ -extern void begin_unwind_frame PARAMS((char *)); -extern void discard_unwind_frame PARAMS((char *)); -extern void run_unwind_frame PARAMS((char *)); +extern void begin_unwind_frame __P((char *)); +extern void discard_unwind_frame __P((char *)); +extern void run_unwind_frame __P((char *)); extern void add_unwind_protect (); /* Not portable to arbitrary C99 hosts. */ -extern void remove_unwind_protect PARAMS((void)); -extern void run_unwind_protects PARAMS((void)); -extern void clear_unwind_protect_list PARAMS((int)); -extern int have_unwind_protects PARAMS((void)); -extern int unwind_protect_tag_on_stack PARAMS((const char *)); -extern void uwp_init PARAMS((void)); +extern void remove_unwind_protect __P((void)); +extern void run_unwind_protects __P((void)); +extern void clear_unwind_protect_list __P((int)); +extern int have_unwind_protects __P((void)); +extern int unwind_protect_tag_on_stack __P((const char *)); +extern void uwp_init __P((void)); /* Define for people who like their code to look a certain way. */ #define end_unwind_frame() /* How to protect a variable. */ #define unwind_protect_var(X) unwind_protect_mem ((char *)&(X), sizeof (X)) -extern void unwind_protect_mem PARAMS((char *, int)); +extern void unwind_protect_mem __P((char *, int)); /* Backwards compatibility */ #define unwind_protect_int unwind_protect_var diff --git a/variables.c b/variables.c index b06b606f..87b389c6 100644 --- a/variables.c +++ b/variables.c @@ -32,6 +32,10 @@ # endif /* !__QNXNTO__ */ #endif /* __QNX__ */ +#if defined (HAVE_SYS_RANDOM_H) +# include +#endif + #if defined (HAVE_UNISTD_H) # include #endif @@ -1474,23 +1478,56 @@ urandom_close () urandfd = -1; } +#if !defined (HAVE_GETRANDOM) +/* Imperfect emulation of getrandom(2). */ +#ifndef GRND_NONBLOCK +# define GRND_NONBLOCK 1 +# define GRND_RANDOM 2 +#endif + +static ssize_t +getrandom (buf, len, flags) + void *buf; + size_t len; + unsigned int flags; +{ + int oflags; + ssize_t r; + static int urand_unavail = 0; + +#if HAVE_GETENTROPY + r = getentropy (buf, len); + return (r == 0) ? len : -1; +#endif + + if (urandfd == -1 && urand_unavail == 0) + { + oflags = O_RDONLY; + if (flags & GRND_NONBLOCK) + oflags |= O_NONBLOCK; + urandfd = open ("/dev/urandom", oflags, 0); + if (urandfd >= 0) + SET_CLOSE_ON_EXEC (urandfd); + else + { + urand_unavail = 1; + return -1; + } + } + if (urandfd >= 0 && (r = read (urandfd, buf, len)) == len) + return (r); + return -1; +} +#endif + static u_bits32_t get_urandom32 () { u_bits32_t ret; - int n; - static int urand_unavail = 0; - if (urandfd == -1 && urand_unavail == 0) - { - urandfd = open ("/dev/urandom", O_RDONLY, 0); - if (urandfd >= 0) - SET_CLOSE_ON_EXEC (urandfd); - else - urand_unavail = 1; - } - if (urandfd >= 0 && (n = read (urandfd, (char *)&ret, sizeof (ret))) == sizeof (ret)) + if (getrandom ((void *)&ret, sizeof (ret), GRND_NONBLOCK) == sizeof (ret)) return (last_rand32 = ret); + #if defined (HAVE_ARC4RANDOM) ret = arc4random (); #else diff --git a/xmalloc.h b/xmalloc.h index 55d2e3d0..083fd7a4 100644 --- a/xmalloc.h +++ b/xmalloc.h @@ -1,6 +1,6 @@ /* xmalloc.h -- defines for the `x' memory allocation functions */ -/* Copyright (C) 2001-2020 Free Software Foundation, Inc. +/* Copyright (C) 2001-2009 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -36,14 +36,14 @@ #endif /* PTR_T */ /* Allocation functions in xmalloc.c */ -extern PTR_T xmalloc PARAMS((size_t)); -extern PTR_T xrealloc PARAMS((void *, size_t)); -extern void xfree PARAMS((void *)); +extern PTR_T xmalloc __P((size_t)); +extern PTR_T xrealloc __P((void *, size_t)); +extern void xfree __P((void *)); #if defined(USING_BASH_MALLOC) && !defined (DISABLE_MALLOC_WRAPPERS) -extern PTR_T sh_xmalloc PARAMS((size_t, const char *, int)); -extern PTR_T sh_xrealloc PARAMS((void *, size_t, const char *, int)); -extern void sh_xfree PARAMS((void *, const char *, int)); +extern PTR_T sh_xmalloc __P((size_t, const char *, int)); +extern PTR_T sh_xrealloc __P((void *, size_t, const char *, int)); +extern void sh_xfree __P((void *, const char *, int)); #define xmalloc(x) sh_xmalloc((x), __FILE__, __LINE__) #define xrealloc(x, n) sh_xrealloc((x), (n), __FILE__, __LINE__) @@ -54,7 +54,7 @@ extern void sh_xfree PARAMS((void *, const char *, int)); #endif #define free(x) sh_xfree((x), __FILE__, __LINE__) -extern PTR_T sh_malloc PARAMS((size_t, const char *, int)); +extern PTR_T sh_malloc __P((size_t, const char *, int)); #ifdef malloc #undef malloc