From: Chet Ramey Date: Tue, 12 Apr 2022 13:57:43 +0000 (-0400) Subject: minor portability fixes; printf now uses double for floating point conversions by... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3be2a2ca9a22f6e33f96bc09a50a8ff3f7ddb17d;p=thirdparty%2Fbash.git minor portability fixes; printf now uses double for floating point conversions by default in posix mode --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 66d3cd6b4..185272bf6 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -3449,3 +3449,30 @@ lib/readline/{complete,histfile,histsearch,isearch,terminal}.c --- configure.ac - bumped version to bash-5.2-beta + +[bash-5.2-beta frozen] + + 4/8 + --- +lib/readline/input.c + - _rl_orig_sigset: need extern declaration if HAVE_SELECT is defined. + From https://savannah.gnu.org/support/?110634 + +examples/loadables/seq.c + - PRIdMAX: redefine if PRI_MACROS_BROKEN is defined. + From https://savannah.gnu.org/support/index.php?110635 + + 4/11 + ---- +configure.ac + - BASH_FUNC_STRTOIMAX: replace strtoimax if the system doesn't provide + a declaration in a standard header file. Uses new m4/strtoimax.m4. + From https://savannah.gnu.org/support/index.php?110633 + +builtins/printf.def + - getdouble: new function, parses string into `double' using strtod + - printf_builtin: check for the `L' length modifier and use long + doubles for the floating point conversion specifiers. If it's not + supplied, use `double' when in posix mode (as posix specifies) and + long double (if it's available, double if not) in default mode. + From a report from Paul Eggert diff --git a/MANIFEST b/MANIFEST index 4fe2e46c3..fef7eb1d5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -484,6 +484,7 @@ lib/tilde/Makefile.in f lib/tilde/tilde.c f lib/tilde/tilde.h f lib/tilde/shell.c f +m4/strtoimax.m4 f m4/stat-time.m4 f m4/timespec.m4 f m4/codeset.m4 f diff --git a/POSIX b/POSIX index d9368a2ff..3fd3c8828 100644 --- a/POSIX +++ b/POSIX @@ -240,7 +240,12 @@ The following list is what's changed when 'POSIX mode' is in effect: 'read', the trap handler executes and 'read' returns an exit status greater than 128. - 60. Bash removes an exited background process's status from the list + 60. The 'printf' builting uses 'double' (via 'strtod') to convert + arguments corresponding to floating point conversion specifiers, + instead of 'long double' if it's available. The 'L' length + modifier forces 'printf' to use 'long double' if it's available. + + 61. Bash removes an exited background process's status from the list of such statuses after the 'wait' builtin is used to obtain it. There is other POSIX behavior that Bash does not implement by default diff --git a/builtins/printf.def b/builtins/printf.def index 251454480..22560991d 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -215,13 +215,16 @@ static uintmax_t getuintmax PARAMS((void)); #if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN) typedef long double floatmax_t; +# define USE_LONG_DOUBLE 1 # define FLOATMAX_CONV "L" # define strtofltmax strtold #else typedef double floatmax_t; +# define USE_LONG_DOUBLE 0 # define FLOATMAX_CONV "" # define strtofltmax strtod #endif +static double getdouble PARAMS((void)); static floatmax_t getfloatmax PARAMS((void)); static intmax_t asciicode PARAMS((void)); @@ -247,7 +250,7 @@ printf_builtin (list) WORD_LIST *list; { int ch, fieldwidth, precision; - int have_fieldwidth, have_precision; + int have_fieldwidth, have_precision, use_Lmod; char convch, thisch, nextch, *format, *modstart, *precstart, *fmt, *start; #if defined (HANDLE_MULTIBYTE) char mbch[25]; /* 25 > MB_LEN_MAX, plus can handle 4-byte UTF-8 and large Unicode characters*/ @@ -422,8 +425,12 @@ printf_builtin (list) /* skip possible format modifiers */ modstart = fmt; + use_Lmod = 0; while (*fmt && strchr (LENMODS, *fmt)) - fmt++; + { + use_Lmod |= USE_LONG_DOUBLE && *fmt == 'L'; + fmt++; + } if (*fmt == 0) { @@ -694,11 +701,24 @@ printf_builtin (list) #endif { char *f; - floatmax_t p; - p = getfloatmax (); - f = mklong (start, FLOATMAX_CONV, sizeof(FLOATMAX_CONV) - 1); - PF (f, p); + if (use_Lmod || posixly_correct == 0) + { + floatmax_t p; + + p = getfloatmax (); + f = mklong (start, "L", 1); + PF (f, p); + } + else /* posixly_correct */ + { + double p; + + p = getdouble (); + f = mklong (start, "", 0); + PF (f, p); + } + break; } @@ -1248,6 +1268,33 @@ getuintmax () return (ret); } +static double +getdouble () +{ + double ret; + char *ep; + + if (garglist == 0) + return (0); + + if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"') + return asciicode (); + + errno = 0; + ret = strtod (garglist->word->word, &ep); + + if (*ep) + { + sh_invalidnum (garglist->word->word); + conversion_error = 1; + } + else if (errno == ERANGE) + printf_erange (garglist->word->word); + + garglist = garglist->next; + return (ret); +} + static floatmax_t getfloatmax () { diff --git a/configure b/configure index 0835ffa43..792e922ab 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac for Bash 5.2, version 5.039. +# From configure.ac for Bash 5.2, version 5.040. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.71 for bash 5.2-beta. # @@ -6659,6 +6659,11 @@ fi + + + + + # codeset.m4 serial 5 (gettext-0.18.2) @@ -15503,19 +15508,6 @@ else $as_nop ;; esac -fi -ac_fn_c_check_func "$LINENO" "strtoimax" "ac_cv_func_strtoimax" -if test "x$ac_cv_func_strtoimax" = xyes -then : - printf "%s\n" "#define HAVE_STRTOIMAX 1" >>confdefs.h - -else $as_nop - case " $LIBOBJS " in - *" strtoimax.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtoimax.$ac_objext" - ;; -esac - fi ac_fn_c_check_func "$LINENO" "strtoumax" "ac_cv_func_strtoumax" if test "x$ac_cv_func_strtoumax" = xyes @@ -15711,15 +15703,6 @@ printf "%s\n" "$bash_cv_strtold_broken" >&6; } fi -ac_fn_check_decl "$LINENO" "strtoimax" "ac_cv_have_decl_strtoimax" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_strtoimax" = xyes -then : - ac_have_decl=1 -else $as_nop - ac_have_decl=0 -fi -printf "%s\n" "#define HAVE_DECL_STRTOIMAX $ac_have_decl" >>confdefs.h - ac_fn_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_strtol" = xyes then : @@ -20417,6 +20400,60 @@ printf "%s\n" "#define HAVE_VSNPRINTF 0" >>confdefs.h +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for usable strtoimax" >&5 +printf %s "checking for usable strtoimax... " >&6; } +if test ${bash_cv_func_strtoimax+y} +then : + printf %s "(cached) " >&6 +else $as_nop + + HAVE_STRTOIMAX=0 HAVE_DECL_STRTOIMAX=0 + + ac_fn_c_check_func "$LINENO" "strtoimax" "ac_cv_func_strtoimax" +if test "x$ac_cv_func_strtoimax" = xyes +then : + printf "%s\n" "#define HAVE_STRTOIMAX 1" >>confdefs.h + +fi + + ac_fn_check_decl "$LINENO" "strtoimax" "ac_cv_have_decl_strtoimax" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_strtoimax" = xyes +then : + ac_have_decl=1 +else $as_nop + ac_have_decl=0 +fi +printf "%s\n" "#define HAVE_DECL_STRTOIMAX $ac_have_decl" >>confdefs.h + + + if test "$ac_cv_func_strtoimax" = "yes" ; then + HAVE_STRTOIMAX=1 + fi + if test "$ac_cv_have_decl_strtoimax" = "yes" ; then + HAVE_DECL_STRTOIMAX=1 + fi + + if test "$HAVE_STRTOIMAX" = 0 || test "$HAVE_DECL_STRTOIMAX" = 0 ; then + bash_cv_func_strtoimax=no REPLACE_STRTOIMAX=1 + else + bash_cv_func_strtoimax=yes + fi + +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_strtoimax" >&5 +printf "%s\n" "$bash_cv_func_strtoimax" >&6; } +if test $bash_cv_func_strtoimax = yes; then +case " $LIBOBJS " in + *" strtoimax.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtoimax.$ac_objext" + ;; +esac + +fi + + + if test "$ac_cv_func_putenv" = "yes"; then diff --git a/configure.ac b/configure.ac index 2cae05e34..aee938a31 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.2, version 5.039])dnl +AC_REVISION([for Bash 5.2, version 5.040])dnl define(bashvers, 5.2) define(relstatus, beta) @@ -713,6 +713,8 @@ AC_SUBST(SIZE) m4_include([m4/stat-time.m4]) m4_include([m4/timespec.m4]) +m4_include([m4/strtoimax.m4]) + dnl include files for gettext m4_include([m4/codeset.m4]) @@ -859,7 +861,7 @@ AC_CHECK_FUNCS(arc4random) AC_REPLACE_FUNCS(getcwd memset) AC_REPLACE_FUNCS(strcasecmp strcasestr strerror strftime strnlen strpbrk strstr) -AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax) +AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoumax) AC_REPLACE_FUNCS(dprintf) AC_REPLACE_FUNCS(strchrnul) AC_REPLACE_FUNCS(strdup) @@ -894,7 +896,6 @@ AC_CHECK_DECLS([strtold], [ fi ]) -AC_CHECK_DECLS(strtoimax) AC_CHECK_DECLS(strtol) AC_CHECK_DECLS(strtoll) AC_CHECK_DECLS(strtoul) @@ -1068,6 +1069,8 @@ BASH_FUNC_STRCOLL BASH_FUNC_SNPRINTF BASH_FUNC_VSNPRINTF +BASH_FUNC_STRTOIMAX + dnl If putenv or unsetenv is not present, set the right define so the dnl prototype and declaration in lib/sh/getenv.c will be standard-conformant diff --git a/doc/bash.info b/doc/bash.info index fcc7bbcf5..832c2507c 100644 --- a/doc/bash.info +++ b/doc/bash.info @@ -1,9 +1,9 @@ This is bash.info, produced by makeinfo version 6.8 from bashref.texi. This text is a brief description of the features that are present in the -Bash shell (version 5.2, 5 February 2022). +Bash shell (version 5.2, 11 April 2022). - This is Edition 5.2, last updated 5 February 2022, of 'The GNU Bash + This is Edition 5.2, last updated 11 April 2022, of 'The GNU Bash Reference Manual', for 'Bash', Version 5.2. Copyright (C) 1988-2022 Free Software Foundation, Inc. @@ -26,10 +26,10 @@ Bash Features ************* This text is a brief description of the features that are present in the -Bash shell (version 5.2, 5 February 2022). The Bash home page is +Bash shell (version 5.2, 11 April 2022). The Bash home page is . - This is Edition 5.2, last updated 5 February 2022, of 'The GNU Bash + This is Edition 5.2, last updated 11 April 2022, of 'The GNU Bash Reference Manual', for 'Bash', Version 5.2. Bash contains features that appear in other popular shells, and some @@ -1367,9 +1367,17 @@ status; otherwise the function's return status is the exit status of the last command executed before the 'return'. Variables local to the function may be declared with the 'local' -builtin. These variables are visible only to the function and the -commands it invokes. This is particularly important when a shell -function calls other functions. +builtin ("local variables"). Ordinarily, variables and their values are +shared between a function and its caller. These variables are visible +only to the function and the commands it invokes. This is particularly +important when a shell function calls other functions. + + In the following description, the "current scope" is a currently- +executing function. Previous scopes consist of that function's caller +and so on, back to the "global" scope, where the shell is not executing +any shell function. Consequently, a local variable at the current local +scope is a variable declared using the 'local' or 'declare' builtins in +the function that is currently executing. Local variables "shadow" variables with the same name declared at previous scopes. For instance, a local variable declared in a function @@ -1414,11 +1422,12 @@ script displays variable is local to the current scope, 'unset' will unset it; otherwise the unset will refer to the variable found in any calling scope as described above. If a variable at the current local scope is unset, it -will remain so until it is reset in that scope or until the function -returns. Once the function returns, any instance of the variable at a -previous scope will become visible. If the unset acts on a variable at -a previous scope, any instance of a variable with that name that had -been shadowed will become visible. +will remain so (appearing as unset) until it is reset in that scope or +until the function returns. Once the function returns, any instance of +the variable at a previous scope will become visible. If the unset acts +on a variable at a previous scope, any instance of a variable with that +name that had been shadowed will become visible (see below how +'localvar_unset'shell option changes this behavior). Function names and definitions may be listed with the '-f' option to the 'declare' ('typeset') builtin command (*note Bash Builtins::). The @@ -1867,11 +1876,11 @@ omitted, the operator tests only for existence. '${PARAMETER:OFFSET:LENGTH}' This is referred to as Substring Expansion. It expands to up to LENGTH characters of the value of PARAMETER starting at the - character specified by OFFSET. If PARAMETER is '@', an indexed - array subscripted by '@' or '*', or an associative array name, the - results differ as described below. If LENGTH is omitted, it - expands to the substring of the value of PARAMETER starting at the - character specified by OFFSET and extending to the end of the + character specified by OFFSET. If PARAMETER is '@' or '*', an + indexed array subscripted by '@' or '*', or an associative array + name, the results differ as described below. If LENGTH is omitted, + it expands to the substring of the value of PARAMETER starting at + the character specified by OFFSET and extending to the end of the value. LENGTH and OFFSET are arithmetic expressions (*note Shell Arithmetic::). @@ -1939,11 +1948,11 @@ omitted, the operator tests only for existence. $ echo ${array[0]: -7:-2} bcdef - If PARAMETER is '@', the result is LENGTH positional parameters - beginning at OFFSET. A negative OFFSET is taken relative to one - greater than the greatest positional parameter, so an offset of -1 - evaluates to the last positional parameter. It is an expansion - error if LENGTH evaluates to a number less than zero. + If PARAMETER is '@' or '*', the result is LENGTH positional + parameters beginning at OFFSET. A negative OFFSET is taken + relative to one greater than the greatest positional parameter, so + an offset of -1 evaluates to the last positional parameter. It is + an expansion error if LENGTH evaluates to a number less than zero. The following examples illustrate substring expansion using positional parameters: @@ -6660,6 +6669,10 @@ negative number, that number is interpreted as relative to one greater than the maximum index of NAME, so negative indices count back from the end of the array, and an index of -1 references the last element. + The '+=' operator will append to an array variable when assigning +using the compound assignment syntax; see *note Shell Parameters:: +above. + Any element of an array may be referenced using '${NAME[SUBSCRIPT]}'. The braces are required to avoid conflicts with the shell's filename expansion operators. If the SUBSCRIPT is '@' or '*', the word expands @@ -7235,7 +7248,12 @@ startup files. 'read', the trap handler executes and 'read' returns an exit status greater than 128. - 60. Bash removes an exited background process's status from the list + 60. The 'printf' builting uses 'double' (via 'strtod') to convert + arguments corresponding to floating point conversion specifiers, + instead of 'long double' if it's available. The 'L' length + modifier forces 'printf' to use 'long double' if it's available. + + 61. Bash removes an exited background process's status from the list of such statuses after the 'wait' builtin is used to obtain it. There is other POSIX behavior that Bash does not implement by default @@ -8156,12 +8174,13 @@ Variable Settings non-incremental history searches. The default is 'On'. 'enable-bracketed-paste' - When set to 'On', Readline will configure the terminal in a - way that will enable it to insert each paste into the editing - buffer as a single string of characters, instead of treating - each character as if it had been read from the keyboard. This - can prevent pasted characters from being interpreted as - editing commands. The default is 'On'. + When set to 'On', Readline configures the terminal to insert + each paste into the editing buffer as a single string of + characters, instead of treating each character as if it had + been read from the keyboard. This is called putting the + terminal into "bracketed paste mode"; it prevents Readline + from executing any editing commands bound to key sequences + appearing in the pasted text. The default is 'On'. 'enable-keypad' When set to 'on', Readline will try to enable the application @@ -11967,14 +11986,14 @@ D.3 Parameter and Variable Index * enable-bracketed-paste: Readline Init File Syntax. (line 185) * enable-keypad: Readline Init File Syntax. - (line 193) + (line 194) * ENV: Bash Variables. (line 279) * EPOCHREALTIME: Bash Variables. (line 284) * EPOCHSECONDS: Bash Variables. (line 292) * EUID: Bash Variables. (line 299) * EXECIGNORE: Bash Variables. (line 303) * expand-tilde: Readline Init File Syntax. - (line 204) + (line 205) * FCEDIT: Bash Variables. (line 316) * FIGNORE: Bash Variables. (line 320) * FUNCNAME: Bash Variables. (line 326) @@ -11988,15 +12007,15 @@ D.3 Parameter and Variable Index * HISTFILESIZE: Bash Variables. (line 402) * HISTIGNORE: Bash Variables. (line 413) * history-preserve-point: Readline Init File Syntax. - (line 208) + (line 209) * history-size: Readline Init File Syntax. - (line 214) + (line 215) * HISTSIZE: Bash Variables. (line 433) * HISTTIMEFORMAT: Bash Variables. (line 440) * HOME: Bourne Shell Variables. (line 13) * horizontal-scroll-mode: Readline Init File Syntax. - (line 223) + (line 224) * HOSTFILE: Bash Variables. (line 448) * HOSTNAME: Bash Variables. (line 459) * HOSTTYPE: Bash Variables. (line 462) @@ -12004,13 +12023,13 @@ D.3 Parameter and Variable Index (line 18) * IGNOREEOF: Bash Variables. (line 465) * input-meta: Readline Init File Syntax. - (line 232) + (line 233) * INPUTRC: Bash Variables. (line 475) * INSIDE_EMACS: Bash Variables. (line 479) * isearch-terminators: Readline Init File Syntax. - (line 240) + (line 241) * keymap: Readline Init File Syntax. - (line 247) + (line 248) * LANG: Creating Internationalized Scripts. (line 51) * LANG <1>: Bash Variables. (line 485) @@ -12032,15 +12051,15 @@ D.3 Parameter and Variable Index (line 27) * MAPFILE: Bash Variables. (line 540) * mark-modified-lines: Readline Init File Syntax. - (line 277) + (line 278) * mark-symlinked-directories: Readline Init File Syntax. - (line 282) + (line 283) * match-hidden-files: Readline Init File Syntax. - (line 287) + (line 288) * menu-complete-display-prefix: Readline Init File Syntax. - (line 294) + (line 295) * meta-flag: Readline Init File Syntax. - (line 232) + (line 233) * OLDPWD: Bash Variables. (line 544) * OPTARG: Bourne Shell Variables. (line 34) @@ -12049,9 +12068,9 @@ D.3 Parameter and Variable Index (line 38) * OSTYPE: Bash Variables. (line 551) * output-meta: Readline Init File Syntax. - (line 299) + (line 300) * page-completions: Readline Init File Syntax. - (line 305) + (line 306) * PATH: Bourne Shell Variables. (line 42) * PIPESTATUS: Bash Variables. (line 554) @@ -12074,19 +12093,19 @@ D.3 Parameter and Variable Index * READLINE_POINT: Bash Variables. (line 626) * REPLY: Bash Variables. (line 630) * revert-all-at-newline: Readline Init File Syntax. - (line 315) + (line 316) * SECONDS: Bash Variables. (line 633) * SHELL: Bash Variables. (line 642) * SHELLOPTS: Bash Variables. (line 647) * SHLVL: Bash Variables. (line 656) * show-all-if-ambiguous: Readline Init File Syntax. - (line 321) + (line 322) * show-all-if-unmodified: Readline Init File Syntax. - (line 327) + (line 328) * show-mode-in-prompt: Readline Init File Syntax. - (line 336) + (line 337) * skip-completed-text: Readline Init File Syntax. - (line 342) + (line 343) * SRANDOM: Bash Variables. (line 661) * TEXTDOMAIN: Creating Internationalized Scripts. (line 51) @@ -12097,11 +12116,11 @@ D.3 Parameter and Variable Index * TMPDIR: Bash Variables. (line 720) * UID: Bash Variables. (line 724) * vi-cmd-mode-string: Readline Init File Syntax. - (line 355) + (line 356) * vi-ins-mode-string: Readline Init File Syntax. - (line 366) + (line 367) * visible-stats: Readline Init File Syntax. - (line 377) + (line 378)  File: bash.info, Node: Function Index, Next: Concept Index, Prev: Variable Index, Up: Indexes @@ -12480,138 +12499,138 @@ D.5 Concept Index  Tag Table: -Node: Top892 -Node: Introduction2807 -Node: What is Bash?3020 -Node: What is a shell?4131 -Node: Definitions6666 -Node: Basic Shell Features9614 -Node: Shell Syntax10830 -Node: Shell Operation11853 -Node: Quoting13143 -Node: Escape Character14444 -Node: Single Quotes14926 -Node: Double Quotes15271 -Node: ANSI-C Quoting16546 -Node: Locale Translation17853 -Node: Creating Internationalized Scripts19161 -Node: Comments23275 -Node: Shell Commands23890 -Node: Reserved Words24825 -Node: Simple Commands25578 -Node: Pipelines26229 -Node: Lists29185 -Node: Compound Commands30977 -Node: Looping Constructs31986 -Node: Conditional Constructs34478 -Node: Command Grouping48819 -Node: Coprocesses50294 -Node: GNU Parallel52954 -Node: Shell Functions53868 -Node: Shell Parameters61156 -Node: Positional Parameters65541 -Node: Special Parameters66440 -Node: Shell Expansions69651 -Node: Brace Expansion71775 -Node: Tilde Expansion74506 -Node: Shell Parameter Expansion77124 -Node: Command Substitution95458 -Node: Arithmetic Expansion96810 -Node: Process Substitution97775 -Node: Word Splitting98892 -Node: Filename Expansion100833 -Node: Pattern Matching103579 -Node: Quote Removal108184 -Node: Redirections108476 -Node: Executing Commands118133 -Node: Simple Command Expansion118800 -Node: Command Search and Execution120907 -Node: Command Execution Environment123282 -Node: Environment126314 -Node: Exit Status127974 -Node: Signals129755 -Node: Shell Scripts133201 -Node: Shell Builtin Commands136225 -Node: Bourne Shell Builtins138260 -Node: Bash Builtins159718 -Node: Modifying Shell Behavior190571 -Node: The Set Builtin190913 -Node: The Shopt Builtin201511 -Node: Special Builtins217420 -Node: Shell Variables218396 -Node: Bourne Shell Variables218830 -Node: Bash Variables220931 -Node: Bash Features253744 -Node: Invoking Bash254754 -Node: Bash Startup Files260764 -Node: Interactive Shells265864 -Node: What is an Interactive Shell?266271 -Node: Is this Shell Interactive?266917 -Node: Interactive Shell Behavior267729 -Node: Bash Conditional Expressions271355 -Node: Shell Arithmetic275994 -Node: Aliases278935 -Node: Arrays281545 -Node: The Directory Stack287789 -Node: Directory Stack Builtins288570 -Node: Controlling the Prompt292827 -Node: The Restricted Shell295789 -Node: Bash POSIX Mode298396 -Node: Shell Compatibility Mode310043 -Node: Job Control318069 -Node: Job Control Basics318526 -Node: Job Control Builtins323525 -Node: Job Control Variables328922 -Node: Command Line Editing330075 -Node: Introduction and Notation331743 -Node: Readline Interaction333363 -Node: Readline Bare Essentials334551 -Node: Readline Movement Commands336331 -Node: Readline Killing Commands337288 -Node: Readline Arguments339203 -Node: Searching340244 -Node: Readline Init File342427 -Node: Readline Init File Syntax343685 -Node: Conditional Init Constructs366808 -Node: Sample Init File371001 -Node: Bindable Readline Commands374122 -Node: Commands For Moving375323 -Node: Commands For History377371 -Node: Commands For Text382362 -Node: Commands For Killing386008 -Node: Numeric Arguments389038 -Node: Commands For Completion390174 -Node: Keyboard Macros394362 -Node: Miscellaneous Commands395046 -Node: Readline vi Mode400982 -Node: Programmable Completion401886 -Node: Programmable Completion Builtins409663 -Node: A Programmable Completion Example420355 -Node: Using History Interactively425599 -Node: Bash History Facilities426280 -Node: Bash History Builtins429282 -Node: History Interaction434287 -Node: Event Designators437904 -Node: Word Designators439255 -Node: Modifiers441012 -Node: Installing Bash442820 -Node: Basic Installation443954 -Node: Compilers and Options447673 -Node: Compiling For Multiple Architectures448411 -Node: Installation Names450101 -Node: Specifying the System Type452207 -Node: Sharing Defaults452920 -Node: Operation Controls453590 -Node: Optional Features454545 -Node: Reporting Bugs465760 -Node: Major Differences From The Bourne Shell467032 -Node: GNU Free Documentation License483879 -Node: Indexes509053 -Node: Builtin Index509504 -Node: Reserved Word Index516328 -Node: Variable Index518773 -Node: Function Index535544 -Node: Concept Index549325 +Node: Top888 +Node: Introduction2799 +Node: What is Bash?3012 +Node: What is a shell?4123 +Node: Definitions6658 +Node: Basic Shell Features9606 +Node: Shell Syntax10822 +Node: Shell Operation11845 +Node: Quoting13135 +Node: Escape Character14436 +Node: Single Quotes14918 +Node: Double Quotes15263 +Node: ANSI-C Quoting16538 +Node: Locale Translation17845 +Node: Creating Internationalized Scripts19153 +Node: Comments23267 +Node: Shell Commands23882 +Node: Reserved Words24817 +Node: Simple Commands25570 +Node: Pipelines26221 +Node: Lists29177 +Node: Compound Commands30969 +Node: Looping Constructs31978 +Node: Conditional Constructs34470 +Node: Command Grouping48811 +Node: Coprocesses50286 +Node: GNU Parallel52946 +Node: Shell Functions53860 +Node: Shell Parameters61742 +Node: Positional Parameters66127 +Node: Special Parameters67026 +Node: Shell Expansions70237 +Node: Brace Expansion72361 +Node: Tilde Expansion75092 +Node: Shell Parameter Expansion77710 +Node: Command Substitution96058 +Node: Arithmetic Expansion97410 +Node: Process Substitution98375 +Node: Word Splitting99492 +Node: Filename Expansion101433 +Node: Pattern Matching104179 +Node: Quote Removal108784 +Node: Redirections109076 +Node: Executing Commands118733 +Node: Simple Command Expansion119400 +Node: Command Search and Execution121507 +Node: Command Execution Environment123882 +Node: Environment126914 +Node: Exit Status128574 +Node: Signals130355 +Node: Shell Scripts133801 +Node: Shell Builtin Commands136825 +Node: Bourne Shell Builtins138860 +Node: Bash Builtins160318 +Node: Modifying Shell Behavior191171 +Node: The Set Builtin191513 +Node: The Shopt Builtin202111 +Node: Special Builtins218020 +Node: Shell Variables218996 +Node: Bourne Shell Variables219430 +Node: Bash Variables221531 +Node: Bash Features254344 +Node: Invoking Bash255354 +Node: Bash Startup Files261364 +Node: Interactive Shells266464 +Node: What is an Interactive Shell?266871 +Node: Is this Shell Interactive?267517 +Node: Interactive Shell Behavior268329 +Node: Bash Conditional Expressions271955 +Node: Shell Arithmetic276594 +Node: Aliases279535 +Node: Arrays282145 +Node: The Directory Stack288533 +Node: Directory Stack Builtins289314 +Node: Controlling the Prompt293571 +Node: The Restricted Shell296533 +Node: Bash POSIX Mode299140 +Node: Shell Compatibility Mode311061 +Node: Job Control319087 +Node: Job Control Basics319544 +Node: Job Control Builtins324543 +Node: Job Control Variables329940 +Node: Command Line Editing331093 +Node: Introduction and Notation332761 +Node: Readline Interaction334381 +Node: Readline Bare Essentials335569 +Node: Readline Movement Commands337349 +Node: Readline Killing Commands338306 +Node: Readline Arguments340221 +Node: Searching341262 +Node: Readline Init File343445 +Node: Readline Init File Syntax344703 +Node: Conditional Init Constructs367899 +Node: Sample Init File372092 +Node: Bindable Readline Commands375213 +Node: Commands For Moving376414 +Node: Commands For History378462 +Node: Commands For Text383453 +Node: Commands For Killing387099 +Node: Numeric Arguments390129 +Node: Commands For Completion391265 +Node: Keyboard Macros395453 +Node: Miscellaneous Commands396137 +Node: Readline vi Mode402073 +Node: Programmable Completion402977 +Node: Programmable Completion Builtins410754 +Node: A Programmable Completion Example421446 +Node: Using History Interactively426690 +Node: Bash History Facilities427371 +Node: Bash History Builtins430373 +Node: History Interaction435378 +Node: Event Designators438995 +Node: Word Designators440346 +Node: Modifiers442103 +Node: Installing Bash443911 +Node: Basic Installation445045 +Node: Compilers and Options448764 +Node: Compiling For Multiple Architectures449502 +Node: Installation Names451192 +Node: Specifying the System Type453298 +Node: Sharing Defaults454011 +Node: Operation Controls454681 +Node: Optional Features455636 +Node: Reporting Bugs466851 +Node: Major Differences From The Bourne Shell468123 +Node: GNU Free Documentation License484970 +Node: Indexes510144 +Node: Builtin Index510595 +Node: Reserved Word Index517419 +Node: Variable Index519864 +Node: Function Index536635 +Node: Concept Index550416  End Tag Table diff --git a/doc/bashref.info b/doc/bashref.info index 4cbaf021e..cd44fc024 100644 --- a/doc/bashref.info +++ b/doc/bashref.info @@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 6.8 from bashref.texi. This text is a brief description of the features that are present in the -Bash shell (version 5.2, 24 February 2022). +Bash shell (version 5.2, 11 April 2022). - This is Edition 5.2, last updated 24 February 2022, of 'The GNU Bash + This is Edition 5.2, last updated 11 April 2022, of 'The GNU Bash Reference Manual', for 'Bash', Version 5.2. Copyright (C) 1988-2022 Free Software Foundation, Inc. @@ -27,10 +27,10 @@ Bash Features ************* This text is a brief description of the features that are present in the -Bash shell (version 5.2, 24 February 2022). The Bash home page is +Bash shell (version 5.2, 11 April 2022). The Bash home page is . - This is Edition 5.2, last updated 24 February 2022, of 'The GNU Bash + This is Edition 5.2, last updated 11 April 2022, of 'The GNU Bash Reference Manual', for 'Bash', Version 5.2. Bash contains features that appear in other popular shells, and some @@ -7249,7 +7249,12 @@ startup files. 'read', the trap handler executes and 'read' returns an exit status greater than 128. - 60. Bash removes an exited background process's status from the list + 60. The 'printf' builting uses 'double' (via 'strtod') to convert + arguments corresponding to floating point conversion specifiers, + instead of 'long double' if it's available. The 'L' length + modifier forces 'printf' to use 'long double' if it's available. + + 61. Bash removes an exited background process's status from the list of such statuses after the 'wait' builtin is used to obtain it. There is other POSIX behavior that Bash does not implement by default @@ -12495,138 +12500,138 @@ D.5 Concept Index  Tag Table: -Node: Top897 -Node: Introduction2817 -Node: What is Bash?3033 -Node: What is a shell?4147 -Node: Definitions6685 -Node: Basic Shell Features9636 -Node: Shell Syntax10855 -Node: Shell Operation11881 -Node: Quoting13174 -Node: Escape Character14478 -Node: Single Quotes14963 -Node: Double Quotes15311 -Node: ANSI-C Quoting16589 -Node: Locale Translation17899 -Node: Creating Internationalized Scripts19210 -Node: Comments23327 -Node: Shell Commands23945 -Node: Reserved Words24883 -Node: Simple Commands25639 -Node: Pipelines26293 -Node: Lists29252 -Node: Compound Commands31047 -Node: Looping Constructs32059 -Node: Conditional Constructs34554 -Node: Command Grouping48898 -Node: Coprocesses50376 -Node: GNU Parallel53039 -Node: Shell Functions53956 -Node: Shell Parameters61841 -Node: Positional Parameters66229 -Node: Special Parameters67131 -Node: Shell Expansions70345 -Node: Brace Expansion72472 -Node: Tilde Expansion75206 -Node: Shell Parameter Expansion77827 -Node: Command Substitution96178 -Node: Arithmetic Expansion97533 -Node: Process Substitution98501 -Node: Word Splitting99621 -Node: Filename Expansion101565 -Node: Pattern Matching104314 -Node: Quote Removal108922 -Node: Redirections109217 -Node: Executing Commands118877 -Node: Simple Command Expansion119547 -Node: Command Search and Execution121657 -Node: Command Execution Environment124035 -Node: Environment127070 -Node: Exit Status128733 -Node: Signals130517 -Node: Shell Scripts133966 -Node: Shell Builtin Commands136993 -Node: Bourne Shell Builtins139031 -Node: Bash Builtins160492 -Node: Modifying Shell Behavior191348 -Node: The Set Builtin191693 -Node: The Shopt Builtin202294 -Node: Special Builtins218206 -Node: Shell Variables219185 -Node: Bourne Shell Variables219622 -Node: Bash Variables221726 -Node: Bash Features254542 -Node: Invoking Bash255555 -Node: Bash Startup Files261568 -Node: Interactive Shells266671 -Node: What is an Interactive Shell?267081 -Node: Is this Shell Interactive?267730 -Node: Interactive Shell Behavior268545 -Node: Bash Conditional Expressions272174 -Node: Shell Arithmetic276816 -Node: Aliases279760 -Node: Arrays282373 -Node: The Directory Stack288764 -Node: Directory Stack Builtins289548 -Node: Controlling the Prompt293808 -Node: The Restricted Shell296773 -Node: Bash POSIX Mode299383 -Node: Shell Compatibility Mode311033 -Node: Job Control319062 -Node: Job Control Basics319522 -Node: Job Control Builtins324524 -Node: Job Control Variables329924 -Node: Command Line Editing331080 -Node: Introduction and Notation332751 -Node: Readline Interaction334374 -Node: Readline Bare Essentials335565 -Node: Readline Movement Commands337348 -Node: Readline Killing Commands338308 -Node: Readline Arguments340226 -Node: Searching341270 -Node: Readline Init File343456 -Node: Readline Init File Syntax344717 -Node: Conditional Init Constructs367916 -Node: Sample Init File372112 -Node: Bindable Readline Commands375236 -Node: Commands For Moving376440 -Node: Commands For History378491 -Node: Commands For Text383485 -Node: Commands For Killing387134 -Node: Numeric Arguments390167 -Node: Commands For Completion391306 -Node: Keyboard Macros395497 -Node: Miscellaneous Commands396184 -Node: Readline vi Mode402123 -Node: Programmable Completion403030 -Node: Programmable Completion Builtins410810 -Node: A Programmable Completion Example421505 -Node: Using History Interactively426752 -Node: Bash History Facilities427436 -Node: Bash History Builtins430441 -Node: History Interaction435449 -Node: Event Designators439069 -Node: Word Designators440423 -Node: Modifiers442183 -Node: Installing Bash443994 -Node: Basic Installation445131 -Node: Compilers and Options448853 -Node: Compiling For Multiple Architectures449594 -Node: Installation Names451287 -Node: Specifying the System Type453396 -Node: Sharing Defaults454112 -Node: Operation Controls454785 -Node: Optional Features455743 -Node: Reporting Bugs466961 -Node: Major Differences From The Bourne Shell468236 -Node: GNU Free Documentation License485086 -Node: Indexes510263 -Node: Builtin Index510717 -Node: Reserved Word Index517544 -Node: Variable Index519992 -Node: Function Index536766 -Node: Concept Index550550 +Node: Top891 +Node: Introduction2805 +Node: What is Bash?3021 +Node: What is a shell?4135 +Node: Definitions6673 +Node: Basic Shell Features9624 +Node: Shell Syntax10843 +Node: Shell Operation11869 +Node: Quoting13162 +Node: Escape Character14466 +Node: Single Quotes14951 +Node: Double Quotes15299 +Node: ANSI-C Quoting16577 +Node: Locale Translation17887 +Node: Creating Internationalized Scripts19198 +Node: Comments23315 +Node: Shell Commands23933 +Node: Reserved Words24871 +Node: Simple Commands25627 +Node: Pipelines26281 +Node: Lists29240 +Node: Compound Commands31035 +Node: Looping Constructs32047 +Node: Conditional Constructs34542 +Node: Command Grouping48886 +Node: Coprocesses50364 +Node: GNU Parallel53027 +Node: Shell Functions53944 +Node: Shell Parameters61829 +Node: Positional Parameters66217 +Node: Special Parameters67119 +Node: Shell Expansions70333 +Node: Brace Expansion72460 +Node: Tilde Expansion75194 +Node: Shell Parameter Expansion77815 +Node: Command Substitution96166 +Node: Arithmetic Expansion97521 +Node: Process Substitution98489 +Node: Word Splitting99609 +Node: Filename Expansion101553 +Node: Pattern Matching104302 +Node: Quote Removal108910 +Node: Redirections109205 +Node: Executing Commands118865 +Node: Simple Command Expansion119535 +Node: Command Search and Execution121645 +Node: Command Execution Environment124023 +Node: Environment127058 +Node: Exit Status128721 +Node: Signals130505 +Node: Shell Scripts133954 +Node: Shell Builtin Commands136981 +Node: Bourne Shell Builtins139019 +Node: Bash Builtins160480 +Node: Modifying Shell Behavior191336 +Node: The Set Builtin191681 +Node: The Shopt Builtin202282 +Node: Special Builtins218194 +Node: Shell Variables219173 +Node: Bourne Shell Variables219610 +Node: Bash Variables221714 +Node: Bash Features254530 +Node: Invoking Bash255543 +Node: Bash Startup Files261556 +Node: Interactive Shells266659 +Node: What is an Interactive Shell?267069 +Node: Is this Shell Interactive?267718 +Node: Interactive Shell Behavior268533 +Node: Bash Conditional Expressions272162 +Node: Shell Arithmetic276804 +Node: Aliases279748 +Node: Arrays282361 +Node: The Directory Stack288752 +Node: Directory Stack Builtins289536 +Node: Controlling the Prompt293796 +Node: The Restricted Shell296761 +Node: Bash POSIX Mode299371 +Node: Shell Compatibility Mode311295 +Node: Job Control319324 +Node: Job Control Basics319784 +Node: Job Control Builtins324786 +Node: Job Control Variables330186 +Node: Command Line Editing331342 +Node: Introduction and Notation333013 +Node: Readline Interaction334636 +Node: Readline Bare Essentials335827 +Node: Readline Movement Commands337610 +Node: Readline Killing Commands338570 +Node: Readline Arguments340488 +Node: Searching341532 +Node: Readline Init File343718 +Node: Readline Init File Syntax344979 +Node: Conditional Init Constructs368178 +Node: Sample Init File372374 +Node: Bindable Readline Commands375498 +Node: Commands For Moving376702 +Node: Commands For History378753 +Node: Commands For Text383747 +Node: Commands For Killing387396 +Node: Numeric Arguments390429 +Node: Commands For Completion391568 +Node: Keyboard Macros395759 +Node: Miscellaneous Commands396446 +Node: Readline vi Mode402385 +Node: Programmable Completion403292 +Node: Programmable Completion Builtins411072 +Node: A Programmable Completion Example421767 +Node: Using History Interactively427014 +Node: Bash History Facilities427698 +Node: Bash History Builtins430703 +Node: History Interaction435711 +Node: Event Designators439331 +Node: Word Designators440685 +Node: Modifiers442445 +Node: Installing Bash444256 +Node: Basic Installation445393 +Node: Compilers and Options449115 +Node: Compiling For Multiple Architectures449856 +Node: Installation Names451549 +Node: Specifying the System Type453658 +Node: Sharing Defaults454374 +Node: Operation Controls455047 +Node: Optional Features456005 +Node: Reporting Bugs467223 +Node: Major Differences From The Bourne Shell468498 +Node: GNU Free Documentation License485348 +Node: Indexes510525 +Node: Builtin Index510979 +Node: Reserved Word Index517806 +Node: Variable Index520254 +Node: Function Index537028 +Node: Concept Index550812  End Tag Table diff --git a/doc/bashref.texi b/doc/bashref.texi index c5e7e2b5b..75e291b19 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -8398,6 +8398,12 @@ has been set. If Bash receives a trapped signal while executing @code{read}, the trap handler executes and @code{read} returns an exit status greater than 128. +@item +The @code{printf} builting uses @code{double} (via @code{strtod}) to convert +arguments corresponding to floating point conversion specifiers, instead of +@code{long double} if it's available. The @samp{L} length modifier forces +@code{printf} to use @code{long double} if it's available. + @item Bash removes an exited background process's status from the list of such statuses after the @code{wait} builtin is used to obtain it. diff --git a/doc/version.texi b/doc/version.texi index 78e22b8e4..c04e2a729 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -2,10 +2,10 @@ Copyright (C) 1988-2022 Free Software Foundation, Inc. @end ignore -@set LASTCHANGE Thu Feb 24 14:43:35 EST 2022 +@set LASTCHANGE Mon Apr 11 17:04:12 EDT 2022 @set EDITION 5.2 @set VERSION 5.2 -@set UPDATED 24 February 2022 -@set UPDATED-MONTH February 2022 +@set UPDATED 11 April 2022 +@set UPDATED-MONTH April 2022 diff --git a/examples/loadables/seq.c b/examples/loadables/seq.c index e56240791..f8eec5bba 100644 --- a/examples/loadables/seq.c +++ b/examples/loadables/seq.c @@ -35,6 +35,18 @@ extern int errno; #endif +#if defined (PRI_MACROS_BROKEN) +# undef PRIdMAX +#endif + +#if !defined (PRIdMAX) +# if HAVE_LONG_LONG +# define PRIdMAX "lld" +# else +# define PRIdMAX "ld" +# endif +#endif + #if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN) typedef long double floatmax_t; # define FLOATMAX_CONV "L" diff --git a/lib/readline/input.c b/lib/readline/input.c index 44d148726..6f038d450 100644 --- a/lib/readline/input.c +++ b/lib/readline/input.c @@ -79,7 +79,7 @@ extern int errno; # define O_NDELAY O_NONBLOCK /* Posix style */ #endif -#if defined (HAVE_PSELECT) +#if defined (HAVE_PSELECT) || defined (HAVE_SELECT) extern sigset_t _rl_orig_sigset; #endif diff --git a/m4/strtoimax.m4 b/m4/strtoimax.m4 new file mode 100644 index 000000000..309857235 --- /dev/null +++ b/m4/strtoimax.m4 @@ -0,0 +1,35 @@ +dnl Copyright (C) 2022 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Make sure we replace strtoimax if we don't have a declaration +dnl We can use this as a template for future function checks + +AC_DEFUN([BASH_FUNC_STRTOIMAX], [ +AC_MSG_CHECKING([for usable strtoimax]) +AC_CACHE_VAL(bash_cv_func_strtoimax, +[ + HAVE_STRTOIMAX=0 HAVE_DECL_STRTOIMAX=0 + + AC_CHECK_FUNCS([strtoimax]) + AC_CHECK_DECLS([strtoimax]) + + if test "$ac_cv_func_strtoimax" = "yes" ; then + HAVE_STRTOIMAX=1 + fi + if test "$ac_cv_have_decl_strtoimax" = "yes" ; then + HAVE_DECL_STRTOIMAX=1 + fi + + if test "$HAVE_STRTOIMAX" = 0 || test "$HAVE_DECL_STRTOIMAX" = 0 ; then + bash_cv_func_strtoimax=no REPLACE_STRTOIMAX=1 + else + bash_cv_func_strtoimax=yes + fi +]) +AC_MSG_RESULT($bash_cv_func_strtoimax) +if test $bash_cv_func_strtoimax = yes; then +AC_LIBOBJ(strtoimax) +fi +]) diff --git a/tests/unicode1.sub b/tests/unicode1.sub index 0debe3d89..6fa5ffcca 100644 --- a/tests/unicode1.sub +++ b/tests/unicode1.sub @@ -110,11 +110,11 @@ fr_FR_ISO_8859_1=( ) # this locale causes problems all over the place -if locale -a | grep -i '^fr_FR\.ISO8859.*1' >/dev/null ; then +if locale -a | grep -i '^fr_FR\.ISO8859.*1$' >/dev/null ; then TestCodePage fr_FR.ISO8859-1 fr_FR_ISO_8859_1 else echo "unicode1.sub: warning: you do not have the fr_FR.ISO8859-1 locale installed;" >&2 - echo "unicode1.sub: that will cause some of these tests to fail." >&2 + echo "unicode1.sub: that will cause some of these tests to be skipped." >&2 fi