From: Chet Ramey Date: Tue, 27 Feb 2024 19:40:31 +0000 (-0500) Subject: internal fixes for declare; additional tests for broken wcwidth() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9b2a8c6d655beb5a0f3ca8708a48ff13e1849bc5;p=thirdparty%2Fbash.git internal fixes for declare; additional tests for broken wcwidth() --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 9b6b711f..903af24c 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -8731,3 +8731,22 @@ lib/readline/bind.c signal. If we are at a point where readline has installed its signal handlers, check for signals readline handles From a patch from Grisha Levit + + 2/21 + ---- +subst.c + - make_internal_declare: now takes two strings of option arguments: + those to turn on (`-') and those to turn off (`+') + - expand_declaration_argument: simplify the code; handle `-' and `+' + optionsns; always call make_internal_declare + From a patch from Grisha Levit + + 2/22 + ---- +aclocal.m4 + - add additional character to test for broken wcwidth (0x200b) + +lib/readline/display.c + - update_line: use IS_COMBINING_CHAR instead of UNICODE_COMBINING_CHAR + plus WCWIDTH; it doesn't make sense on systems where wcwidth isn't + broken diff --git a/aclocal.m4 b/aclocal.m4 index 67ffa5b5..37066ce6 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1816,6 +1816,9 @@ main(int c, char **v) setlocale(LC_ALL, "en_US.UTF-8"); w = wcwidth (0x0301); + if (w != 0) + exit (0); + w = wcwidth (0x200b); exit (w == 0); /* exit 0 if wcwidth broken */ } ]])], [bash_cv_wcwidth_broken=yes], [bash_cv_wcwidth_broken=no], diff --git a/builtins/ulimit.def b/builtins/ulimit.def index 1c3ad1fa..0301089b 100644 --- a/builtins/ulimit.def +++ b/builtins/ulimit.def @@ -63,9 +63,10 @@ current soft limit, the current hard limit, and no limit, respectively. Otherwise, the current value of the specified resource is printed. If no option is given, then -f is assumed. -Values are in 1024-byte increments, except for -t, which is in seconds, --p, which is in increments of 512 bytes, and -u, which is an unscaled -number of processes. +Values are in 1024-byte increments, except for -t, which is in seconds; +-p, which is in increments of 512 bytes; -R, which is in microseconds; +-b, which is in bytes; and -e, -i, -k, -n, -q, -r, -u, -x, and -P, +which accept unscaled values. Exit Status: Returns success unless an invalid option is supplied or an error occurs. diff --git a/configure b/configure index d3ca0ace..20811bdb 100755 --- a/configure +++ b/configure @@ -16888,6 +16888,9 @@ main(int c, char **v) setlocale(LC_ALL, "en_US.UTF-8"); w = wcwidth (0x0301); + if (w != 0) + exit (0); + w = wcwidth (0x200b); exit (w == 0); /* exit 0 if wcwidth broken */ } diff --git a/doc/bash.0 b/doc/bash.0 index 4bc30d2d..399f3ca7 100644 --- a/doc/bash.0 +++ b/doc/bash.0 @@ -1263,17 +1263,19 @@ PPAARRAAMMEETTEERRSS HHIISSTTSSIIZZEE after reading any startup files. HHIISSTTIIGGNNOORREE A colon-separated list of patterns used to decide which command - lines should be saved on the history list. Each pattern is an- - chored at the beginning of the line and must match the complete - line (bbaasshh will not implicitly append a "**"). Each pattern is - tested against the line after the checks specified by HHIISSTTCCOONN-- - TTRROOLL are applied. In addition to the normal shell pattern - matching characters, "&&" matches the previous history line. A - backslash will escape the "&&"; the backslash is removed before - attempting a match. The second and subsequent lines of a multi- - line compound command are not tested, and are added to the his- - tory regardless of the value of HHIISSTTIIGGNNOORREE. The pattern match- - ing honors the setting of the eexxttgglloobb shell option. + lines should be saved on the history list. If a command line + matches one of the patterns in the value of HHIISSTTIIGGNNOORREE, it is + not saved on the history list. Each pattern is anchored at the + beginning of the line and must match the complete line (bbaasshh + will not implicitly append a "**"). Each pattern is tested + against the line after the checks specified by HHIISSTTCCOONNTTRROOLL are + applied. In addition to the normal shell pattern matching char- + acters, "&&" matches the previous history line. A backslash will + escape the "&&"; the backslash is removed before attempting a + match. The second and subsequent lines of a multi-line compound + command are not tested, and are added to the history regardless + of the value of HHIISSTTIIGGNNOORREE. The pattern matching honors the + setting of the eexxttgglloobb shell option. HHIISSTTSSIIZZEE The number of commands to remember in the command history (see HHIISSTTOORRYY below). If the value is 0, commands are not saved in @@ -6891,4 +6893,4 @@ BBUUGGSS There may be only one active coprocess at a time. -GNU Bash 5.3 2024 February 5 _B_A_S_H(1) +GNU Bash 5.3 2024 February 19 _B_A_S_H(1) diff --git a/doc/bash.info b/doc/bash.info index a217e31c..bff351ee 100644 --- a/doc/bash.info +++ b/doc/bash.info @@ -1,9 +1,9 @@ This is bash.info, produced by makeinfo version 7.1 from bashref.texi. This text is a brief description of the features that are present in the -Bash shell (version 5.3, 2 February 2024). +Bash shell (version 5.3, 19 February 2024). - This is Edition 5.3, last updated 2 February 2024, of ‘The GNU Bash + This is Edition 5.3, last updated 19 February 2024, of ‘The GNU Bash Reference Manual’, for ‘Bash’, Version 5.3. Copyright © 1988-2023 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.3, 2 February 2024). The Bash home page is +Bash shell (version 5.3, 19 February 2024). The Bash home page is . - This is Edition 5.3, last updated 2 February 2024, of ‘The GNU Bash + This is Edition 5.3, last updated 19 February 2024, of ‘The GNU Bash Reference Manual’, for ‘Bash’, Version 5.3. Bash contains features that appear in other popular shells, and some @@ -5792,17 +5792,19 @@ Variables::). ‘HISTIGNORE’ A colon-separated list of patterns used to decide which command - lines should be saved on the history list. Each pattern is - anchored at the beginning of the line and must match the complete - line (Bash will not implicitly append a ‘*’). Each pattern is - tested against the line after the checks specified by ‘HISTCONTROL’ - are applied. In addition to the normal shell pattern matching - characters, ‘&’ matches the previous history line. ‘&’ may be - escaped using a backslash; the backslash is removed before - attempting a match. The second and subsequent lines of a - multi-line compound command are not tested, and are added to the - history regardless of the value of ‘HISTIGNORE’. The pattern - matching honors the setting of the ‘extglob’ shell option. + lines should be saved on the history list. If a command line + matches one of the patterns in the value of ‘HISTIGNORE’, it is not + saved on the history list. Each pattern is anchored at the + beginning of the line and must match the complete line (Bash will + not implicitly append a ‘*’). Each pattern is tested against the + line after the checks specified by ‘HISTCONTROL’ are applied. In + addition to the normal shell pattern matching characters, ‘&’ + matches the previous history line. ‘&’ may be escaped using a + backslash; the backslash is removed before attempting a match. The + second and subsequent lines of a multi-line compound command are + not tested, and are added to the history regardless of the value of + ‘HISTIGNORE’. The pattern matching honors the setting of the + ‘extglob’ shell option. ‘HISTIGNORE’ subsumes the function of ‘HISTCONTROL’. A pattern of ‘&’ is identical to ‘ignoredups’, and a pattern of ‘[ ]*’ is @@ -12423,46 +12425,46 @@ D.3 Parameter and Variable Index (line 214) * history-size: Readline Init File Syntax. (line 220) -* HISTSIZE: Bash Variables. (line 478) -* HISTTIMEFORMAT: Bash Variables. (line 485) +* HISTSIZE: Bash Variables. (line 480) +* HISTTIMEFORMAT: Bash Variables. (line 487) * HOME: Bourne Shell Variables. (line 13) * horizontal-scroll-mode: Readline Init File Syntax. (line 229) -* HOSTFILE: Bash Variables. (line 494) -* HOSTNAME: Bash Variables. (line 505) -* HOSTTYPE: Bash Variables. (line 508) +* HOSTFILE: Bash Variables. (line 496) +* HOSTNAME: Bash Variables. (line 507) +* HOSTTYPE: Bash Variables. (line 510) * IFS: Bourne Shell Variables. (line 18) -* IGNOREEOF: Bash Variables. (line 511) +* IGNOREEOF: Bash Variables. (line 513) * input-meta: Readline Init File Syntax. (line 238) -* INPUTRC: Bash Variables. (line 521) -* INSIDE_EMACS: Bash Variables. (line 525) +* INPUTRC: Bash Variables. (line 523) +* INSIDE_EMACS: Bash Variables. (line 527) * isearch-terminators: Readline Init File Syntax. (line 248) * keymap: Readline Init File Syntax. (line 255) * LANG: Creating Internationalized Scripts. (line 51) -* LANG <1>: Bash Variables. (line 531) -* LC_ALL: Bash Variables. (line 535) -* LC_COLLATE: Bash Variables. (line 539) -* LC_CTYPE: Bash Variables. (line 546) +* LANG <1>: Bash Variables. (line 533) +* LC_ALL: Bash Variables. (line 537) +* LC_COLLATE: Bash Variables. (line 541) +* LC_CTYPE: Bash Variables. (line 548) * LC_MESSAGES: Creating Internationalized Scripts. (line 51) -* LC_MESSAGES <1>: Bash Variables. (line 551) -* LC_NUMERIC: Bash Variables. (line 555) -* LC_TIME: Bash Variables. (line 559) -* LINENO: Bash Variables. (line 563) -* LINES: Bash Variables. (line 568) -* MACHTYPE: Bash Variables. (line 574) +* LC_MESSAGES <1>: Bash Variables. (line 553) +* LC_NUMERIC: Bash Variables. (line 557) +* LC_TIME: Bash Variables. (line 561) +* LINENO: Bash Variables. (line 565) +* LINES: Bash Variables. (line 570) +* MACHTYPE: Bash Variables. (line 576) * MAIL: Bourne Shell Variables. (line 22) -* MAILCHECK: Bash Variables. (line 578) +* MAILCHECK: Bash Variables. (line 580) * MAILPATH: Bourne Shell Variables. (line 27) -* MAPFILE: Bash Variables. (line 586) +* MAPFILE: Bash Variables. (line 588) * mark-modified-lines: Readline Init File Syntax. (line 285) * mark-symlinked-directories: Readline Init File Syntax. @@ -12473,46 +12475,46 @@ D.3 Parameter and Variable Index (line 302) * meta-flag: Readline Init File Syntax. (line 238) -* OLDPWD: Bash Variables. (line 590) +* OLDPWD: Bash Variables. (line 592) * OPTARG: Bourne Shell Variables. (line 34) -* OPTERR: Bash Variables. (line 593) +* OPTERR: Bash Variables. (line 595) * OPTIND: Bourne Shell Variables. (line 38) -* OSTYPE: Bash Variables. (line 597) +* OSTYPE: Bash Variables. (line 599) * output-meta: Readline Init File Syntax. (line 307) * page-completions: Readline Init File Syntax. (line 315) * PATH: Bourne Shell Variables. (line 42) -* PIPESTATUS: Bash Variables. (line 600) -* POSIXLY_CORRECT: Bash Variables. (line 605) -* PPID: Bash Variables. (line 615) -* PROMPT_COMMAND: Bash Variables. (line 619) -* PROMPT_DIRTRIM: Bash Variables. (line 625) -* PS0: Bash Variables. (line 631) +* PIPESTATUS: Bash Variables. (line 602) +* POSIXLY_CORRECT: Bash Variables. (line 607) +* PPID: Bash Variables. (line 617) +* PROMPT_COMMAND: Bash Variables. (line 621) +* PROMPT_DIRTRIM: Bash Variables. (line 627) +* PS0: Bash Variables. (line 633) * PS1: Bourne Shell Variables. (line 48) * PS2: Bourne Shell Variables. (line 53) -* PS3: Bash Variables. (line 636) -* PS4: Bash Variables. (line 641) -* PWD: Bash Variables. (line 649) -* RANDOM: Bash Variables. (line 652) -* READLINE_ARGUMENT: Bash Variables. (line 658) -* READLINE_LINE: Bash Variables. (line 662) -* READLINE_MARK: Bash Variables. (line 666) -* READLINE_POINT: Bash Variables. (line 672) -* REPLY: Bash Variables. (line 676) +* PS3: Bash Variables. (line 638) +* PS4: Bash Variables. (line 643) +* PWD: Bash Variables. (line 651) +* RANDOM: Bash Variables. (line 654) +* READLINE_ARGUMENT: Bash Variables. (line 660) +* READLINE_LINE: Bash Variables. (line 664) +* READLINE_MARK: Bash Variables. (line 668) +* READLINE_POINT: Bash Variables. (line 674) +* REPLY: Bash Variables. (line 678) * revert-all-at-newline: Readline Init File Syntax. (line 325) * search-ignore-case: Readline Init File Syntax. (line 332) -* SECONDS: Bash Variables. (line 679) -* SHELL: Bash Variables. (line 688) -* SHELLOPTS: Bash Variables. (line 693) -* SHLVL: Bash Variables. (line 702) +* SECONDS: Bash Variables. (line 681) +* SHELL: Bash Variables. (line 690) +* SHELLOPTS: Bash Variables. (line 695) +* SHLVL: Bash Variables. (line 704) * show-all-if-ambiguous: Readline Init File Syntax. (line 337) * show-all-if-unmodified: Readline Init File Syntax. @@ -12521,15 +12523,15 @@ D.3 Parameter and Variable Index (line 352) * skip-completed-text: Readline Init File Syntax. (line 358) -* SRANDOM: Bash Variables. (line 707) +* SRANDOM: Bash Variables. (line 709) * TEXTDOMAIN: Creating Internationalized Scripts. (line 51) * TEXTDOMAINDIR: Creating Internationalized Scripts. (line 51) -* TIMEFORMAT: Bash Variables. (line 716) -* TMOUT: Bash Variables. (line 754) -* TMPDIR: Bash Variables. (line 766) -* UID: Bash Variables. (line 770) +* TIMEFORMAT: Bash Variables. (line 718) +* TMOUT: Bash Variables. (line 756) +* TMPDIR: Bash Variables. (line 768) +* UID: Bash Variables. (line 772) * vi-cmd-mode-string: Readline Init File Syntax. (line 371) * vi-ins-mode-string: Readline Init File Syntax. @@ -12921,138 +12923,138 @@ D.5 Concept Index  Tag Table: -Node: Top899 -Node: Introduction2838 -Node: What is Bash?3051 -Node: What is a shell?4192 -Node: Definitions6771 -Node: Basic Shell Features9947 -Node: Shell Syntax11167 -Node: Shell Operation12194 -Node: Quoting13492 -Node: Escape Character14805 -Node: Single Quotes15303 -Node: Double Quotes15652 -Node: ANSI-C Quoting16995 -Node: Locale Translation18380 -Node: Creating Internationalized Scripts19724 -Node: Comments23922 -Node: Shell Commands24557 -Node: Reserved Words25496 -Node: Simple Commands26361 -Node: Pipelines27020 -Node: Lists30083 -Node: Compound Commands31955 -Node: Looping Constructs32964 -Node: Conditional Constructs35508 -Node: Command Grouping50412 -Node: Coprocesses51899 -Node: GNU Parallel54595 -Node: Shell Functions55513 -Node: Shell Parameters63619 -Node: Positional Parameters68152 -Node: Special Parameters69087 -Node: Shell Expansions72394 -Node: Brace Expansion74583 -Node: Tilde Expansion77246 -Node: Shell Parameter Expansion80012 -Node: Command Substitution99036 -Node: Arithmetic Expansion102569 -Node: Process Substitution103534 -Node: Word Splitting104671 -Node: Filename Expansion106812 -Node: Pattern Matching109908 -Node: Quote Removal115141 -Node: Redirections115445 -Node: Executing Commands125254 -Node: Simple Command Expansion125921 -Node: Command Search and Execution128032 -Node: Command Execution Environment130440 -Node: Environment133749 -Node: Exit Status135453 -Node: Signals137238 -Node: Shell Scripts140852 -Node: Shell Builtin Commands143944 -Node: Bourne Shell Builtins146055 -Node: Bash Builtins170459 -Node: Modifying Shell Behavior205064 -Node: The Set Builtin205406 -Node: The Shopt Builtin216921 -Node: Special Builtins233657 -Node: Shell Variables234646 -Node: Bourne Shell Variables235080 -Node: Bash Variables237273 -Node: Bash Features273695 -Node: Invoking Bash274709 -Node: Bash Startup Files281108 -Node: Interactive Shells286420 -Node: What is an Interactive Shell?286828 -Node: Is this Shell Interactive?287494 -Node: Interactive Shell Behavior288318 -Node: Bash Conditional Expressions292072 -Node: Shell Arithmetic297246 -Node: Aliases300328 -Node: Arrays303283 -Node: The Directory Stack310082 -Node: Directory Stack Builtins310879 -Node: Controlling the Prompt315328 -Node: The Restricted Shell318466 -Node: Bash POSIX Mode321253 -Node: Shell Compatibility Mode338734 -Node: Job Control347220 -Node: Job Control Basics347677 -Node: Job Control Builtins352851 -Node: Job Control Variables358811 -Node: Command Line Editing359988 -Node: Introduction and Notation361692 -Node: Readline Interaction363336 -Node: Readline Bare Essentials364524 -Node: Readline Movement Commands366342 -Node: Readline Killing Commands367339 -Node: Readline Arguments369317 -Node: Searching370374 -Node: Readline Init File372603 -Node: Readline Init File Syntax373885 -Node: Conditional Init Constructs398823 -Node: Sample Init File403188 -Node: Bindable Readline Commands406309 -Node: Commands For Moving407534 -Node: Commands For History409634 -Node: Commands For Text414717 -Node: Commands For Killing418792 -Node: Numeric Arguments421593 -Node: Commands For Completion422745 -Node: Keyboard Macros427061 -Node: Miscellaneous Commands427762 -Node: Readline vi Mode434416 -Node: Programmable Completion435368 -Node: Programmable Completion Builtins443325 -Node: A Programmable Completion Example454891 -Node: Using History Interactively460236 -Node: Bash History Facilities460917 -Node: Bash History Builtins464029 -Node: History Interaction469272 -Node: Event Designators473597 -Node: Word Designators475180 -Node: Modifiers477166 -Node: Installing Bash479075 -Node: Basic Installation480209 -Node: Compilers and Options484088 -Node: Compiling For Multiple Architectures484838 -Node: Installation Names486587 -Node: Specifying the System Type488821 -Node: Sharing Defaults489567 -Node: Operation Controls490281 -Node: Optional Features491300 -Node: Reporting Bugs503102 -Node: Major Differences From The Bourne Shell504451 -Node: GNU Free Documentation License522260 -Node: Indexes547437 -Node: Builtin Index547888 -Node: Reserved Word Index554986 -Node: Variable Index557431 -Node: Function Index574562 -Node: Concept Index588418 +Node: Top901 +Node: Introduction2842 +Node: What is Bash?3055 +Node: What is a shell?4196 +Node: Definitions6775 +Node: Basic Shell Features9951 +Node: Shell Syntax11171 +Node: Shell Operation12198 +Node: Quoting13496 +Node: Escape Character14809 +Node: Single Quotes15307 +Node: Double Quotes15656 +Node: ANSI-C Quoting16999 +Node: Locale Translation18384 +Node: Creating Internationalized Scripts19728 +Node: Comments23926 +Node: Shell Commands24561 +Node: Reserved Words25500 +Node: Simple Commands26365 +Node: Pipelines27024 +Node: Lists30087 +Node: Compound Commands31959 +Node: Looping Constructs32968 +Node: Conditional Constructs35512 +Node: Command Grouping50416 +Node: Coprocesses51903 +Node: GNU Parallel54599 +Node: Shell Functions55517 +Node: Shell Parameters63623 +Node: Positional Parameters68156 +Node: Special Parameters69091 +Node: Shell Expansions72398 +Node: Brace Expansion74587 +Node: Tilde Expansion77250 +Node: Shell Parameter Expansion80016 +Node: Command Substitution99040 +Node: Arithmetic Expansion102573 +Node: Process Substitution103538 +Node: Word Splitting104675 +Node: Filename Expansion106816 +Node: Pattern Matching109912 +Node: Quote Removal115145 +Node: Redirections115449 +Node: Executing Commands125258 +Node: Simple Command Expansion125925 +Node: Command Search and Execution128036 +Node: Command Execution Environment130444 +Node: Environment133753 +Node: Exit Status135457 +Node: Signals137242 +Node: Shell Scripts140856 +Node: Shell Builtin Commands143948 +Node: Bourne Shell Builtins146059 +Node: Bash Builtins170463 +Node: Modifying Shell Behavior205068 +Node: The Set Builtin205410 +Node: The Shopt Builtin216925 +Node: Special Builtins233661 +Node: Shell Variables234650 +Node: Bourne Shell Variables235084 +Node: Bash Variables237277 +Node: Bash Features273827 +Node: Invoking Bash274841 +Node: Bash Startup Files281240 +Node: Interactive Shells286552 +Node: What is an Interactive Shell?286960 +Node: Is this Shell Interactive?287626 +Node: Interactive Shell Behavior288450 +Node: Bash Conditional Expressions292204 +Node: Shell Arithmetic297378 +Node: Aliases300460 +Node: Arrays303415 +Node: The Directory Stack310214 +Node: Directory Stack Builtins311011 +Node: Controlling the Prompt315460 +Node: The Restricted Shell318598 +Node: Bash POSIX Mode321385 +Node: Shell Compatibility Mode338866 +Node: Job Control347352 +Node: Job Control Basics347809 +Node: Job Control Builtins352983 +Node: Job Control Variables358943 +Node: Command Line Editing360120 +Node: Introduction and Notation361824 +Node: Readline Interaction363468 +Node: Readline Bare Essentials364656 +Node: Readline Movement Commands366474 +Node: Readline Killing Commands367471 +Node: Readline Arguments369449 +Node: Searching370506 +Node: Readline Init File372735 +Node: Readline Init File Syntax374017 +Node: Conditional Init Constructs398955 +Node: Sample Init File403320 +Node: Bindable Readline Commands406441 +Node: Commands For Moving407666 +Node: Commands For History409766 +Node: Commands For Text414849 +Node: Commands For Killing418924 +Node: Numeric Arguments421725 +Node: Commands For Completion422877 +Node: Keyboard Macros427193 +Node: Miscellaneous Commands427894 +Node: Readline vi Mode434548 +Node: Programmable Completion435500 +Node: Programmable Completion Builtins443457 +Node: A Programmable Completion Example455023 +Node: Using History Interactively460368 +Node: Bash History Facilities461049 +Node: Bash History Builtins464161 +Node: History Interaction469404 +Node: Event Designators473729 +Node: Word Designators475312 +Node: Modifiers477298 +Node: Installing Bash479207 +Node: Basic Installation480341 +Node: Compilers and Options484220 +Node: Compiling For Multiple Architectures484970 +Node: Installation Names486719 +Node: Specifying the System Type488953 +Node: Sharing Defaults489699 +Node: Operation Controls490413 +Node: Optional Features491432 +Node: Reporting Bugs503234 +Node: Major Differences From The Bourne Shell504583 +Node: GNU Free Documentation License522392 +Node: Indexes547569 +Node: Builtin Index548020 +Node: Reserved Word Index555118 +Node: Variable Index557563 +Node: Function Index574694 +Node: Concept Index588550  End Tag Table diff --git a/doc/bashref.info b/doc/bashref.info index b3c92877..2b6e0325 100644 --- a/doc/bashref.info +++ b/doc/bashref.info @@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 7.1 from bashref.texi. This text is a brief description of the features that are present in the -Bash shell (version 5.3, 2 February 2024). +Bash shell (version 5.3, 19 February 2024). - This is Edition 5.3, last updated 2 February 2024, of ‘The GNU Bash + This is Edition 5.3, last updated 19 February 2024, of ‘The GNU Bash Reference Manual’, for ‘Bash’, Version 5.3. Copyright © 1988-2023 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.3, 2 February 2024). The Bash home page is +Bash shell (version 5.3, 19 February 2024). The Bash home page is . - This is Edition 5.3, last updated 2 February 2024, of ‘The GNU Bash + This is Edition 5.3, last updated 19 February 2024, of ‘The GNU Bash Reference Manual’, for ‘Bash’, Version 5.3. Bash contains features that appear in other popular shells, and some @@ -5793,17 +5793,19 @@ Variables::). ‘HISTIGNORE’ A colon-separated list of patterns used to decide which command - lines should be saved on the history list. Each pattern is - anchored at the beginning of the line and must match the complete - line (Bash will not implicitly append a ‘*’). Each pattern is - tested against the line after the checks specified by ‘HISTCONTROL’ - are applied. In addition to the normal shell pattern matching - characters, ‘&’ matches the previous history line. ‘&’ may be - escaped using a backslash; the backslash is removed before - attempting a match. The second and subsequent lines of a - multi-line compound command are not tested, and are added to the - history regardless of the value of ‘HISTIGNORE’. The pattern - matching honors the setting of the ‘extglob’ shell option. + lines should be saved on the history list. If a command line + matches one of the patterns in the value of ‘HISTIGNORE’, it is not + saved on the history list. Each pattern is anchored at the + beginning of the line and must match the complete line (Bash will + not implicitly append a ‘*’). Each pattern is tested against the + line after the checks specified by ‘HISTCONTROL’ are applied. In + addition to the normal shell pattern matching characters, ‘&’ + matches the previous history line. ‘&’ may be escaped using a + backslash; the backslash is removed before attempting a match. The + second and subsequent lines of a multi-line compound command are + not tested, and are added to the history regardless of the value of + ‘HISTIGNORE’. The pattern matching honors the setting of the + ‘extglob’ shell option. ‘HISTIGNORE’ subsumes the function of ‘HISTCONTROL’. A pattern of ‘&’ is identical to ‘ignoredups’, and a pattern of ‘[ ]*’ is @@ -12424,46 +12426,46 @@ D.3 Parameter and Variable Index (line 214) * history-size: Readline Init File Syntax. (line 220) -* HISTSIZE: Bash Variables. (line 478) -* HISTTIMEFORMAT: Bash Variables. (line 485) +* HISTSIZE: Bash Variables. (line 480) +* HISTTIMEFORMAT: Bash Variables. (line 487) * HOME: Bourne Shell Variables. (line 13) * horizontal-scroll-mode: Readline Init File Syntax. (line 229) -* HOSTFILE: Bash Variables. (line 494) -* HOSTNAME: Bash Variables. (line 505) -* HOSTTYPE: Bash Variables. (line 508) +* HOSTFILE: Bash Variables. (line 496) +* HOSTNAME: Bash Variables. (line 507) +* HOSTTYPE: Bash Variables. (line 510) * IFS: Bourne Shell Variables. (line 18) -* IGNOREEOF: Bash Variables. (line 511) +* IGNOREEOF: Bash Variables. (line 513) * input-meta: Readline Init File Syntax. (line 238) -* INPUTRC: Bash Variables. (line 521) -* INSIDE_EMACS: Bash Variables. (line 525) +* INPUTRC: Bash Variables. (line 523) +* INSIDE_EMACS: Bash Variables. (line 527) * isearch-terminators: Readline Init File Syntax. (line 248) * keymap: Readline Init File Syntax. (line 255) * LANG: Creating Internationalized Scripts. (line 51) -* LANG <1>: Bash Variables. (line 531) -* LC_ALL: Bash Variables. (line 535) -* LC_COLLATE: Bash Variables. (line 539) -* LC_CTYPE: Bash Variables. (line 546) +* LANG <1>: Bash Variables. (line 533) +* LC_ALL: Bash Variables. (line 537) +* LC_COLLATE: Bash Variables. (line 541) +* LC_CTYPE: Bash Variables. (line 548) * LC_MESSAGES: Creating Internationalized Scripts. (line 51) -* LC_MESSAGES <1>: Bash Variables. (line 551) -* LC_NUMERIC: Bash Variables. (line 555) -* LC_TIME: Bash Variables. (line 559) -* LINENO: Bash Variables. (line 563) -* LINES: Bash Variables. (line 568) -* MACHTYPE: Bash Variables. (line 574) +* LC_MESSAGES <1>: Bash Variables. (line 553) +* LC_NUMERIC: Bash Variables. (line 557) +* LC_TIME: Bash Variables. (line 561) +* LINENO: Bash Variables. (line 565) +* LINES: Bash Variables. (line 570) +* MACHTYPE: Bash Variables. (line 576) * MAIL: Bourne Shell Variables. (line 22) -* MAILCHECK: Bash Variables. (line 578) +* MAILCHECK: Bash Variables. (line 580) * MAILPATH: Bourne Shell Variables. (line 27) -* MAPFILE: Bash Variables. (line 586) +* MAPFILE: Bash Variables. (line 588) * mark-modified-lines: Readline Init File Syntax. (line 285) * mark-symlinked-directories: Readline Init File Syntax. @@ -12474,46 +12476,46 @@ D.3 Parameter and Variable Index (line 302) * meta-flag: Readline Init File Syntax. (line 238) -* OLDPWD: Bash Variables. (line 590) +* OLDPWD: Bash Variables. (line 592) * OPTARG: Bourne Shell Variables. (line 34) -* OPTERR: Bash Variables. (line 593) +* OPTERR: Bash Variables. (line 595) * OPTIND: Bourne Shell Variables. (line 38) -* OSTYPE: Bash Variables. (line 597) +* OSTYPE: Bash Variables. (line 599) * output-meta: Readline Init File Syntax. (line 307) * page-completions: Readline Init File Syntax. (line 315) * PATH: Bourne Shell Variables. (line 42) -* PIPESTATUS: Bash Variables. (line 600) -* POSIXLY_CORRECT: Bash Variables. (line 605) -* PPID: Bash Variables. (line 615) -* PROMPT_COMMAND: Bash Variables. (line 619) -* PROMPT_DIRTRIM: Bash Variables. (line 625) -* PS0: Bash Variables. (line 631) +* PIPESTATUS: Bash Variables. (line 602) +* POSIXLY_CORRECT: Bash Variables. (line 607) +* PPID: Bash Variables. (line 617) +* PROMPT_COMMAND: Bash Variables. (line 621) +* PROMPT_DIRTRIM: Bash Variables. (line 627) +* PS0: Bash Variables. (line 633) * PS1: Bourne Shell Variables. (line 48) * PS2: Bourne Shell Variables. (line 53) -* PS3: Bash Variables. (line 636) -* PS4: Bash Variables. (line 641) -* PWD: Bash Variables. (line 649) -* RANDOM: Bash Variables. (line 652) -* READLINE_ARGUMENT: Bash Variables. (line 658) -* READLINE_LINE: Bash Variables. (line 662) -* READLINE_MARK: Bash Variables. (line 666) -* READLINE_POINT: Bash Variables. (line 672) -* REPLY: Bash Variables. (line 676) +* PS3: Bash Variables. (line 638) +* PS4: Bash Variables. (line 643) +* PWD: Bash Variables. (line 651) +* RANDOM: Bash Variables. (line 654) +* READLINE_ARGUMENT: Bash Variables. (line 660) +* READLINE_LINE: Bash Variables. (line 664) +* READLINE_MARK: Bash Variables. (line 668) +* READLINE_POINT: Bash Variables. (line 674) +* REPLY: Bash Variables. (line 678) * revert-all-at-newline: Readline Init File Syntax. (line 325) * search-ignore-case: Readline Init File Syntax. (line 332) -* SECONDS: Bash Variables. (line 679) -* SHELL: Bash Variables. (line 688) -* SHELLOPTS: Bash Variables. (line 693) -* SHLVL: Bash Variables. (line 702) +* SECONDS: Bash Variables. (line 681) +* SHELL: Bash Variables. (line 690) +* SHELLOPTS: Bash Variables. (line 695) +* SHLVL: Bash Variables. (line 704) * show-all-if-ambiguous: Readline Init File Syntax. (line 337) * show-all-if-unmodified: Readline Init File Syntax. @@ -12522,15 +12524,15 @@ D.3 Parameter and Variable Index (line 352) * skip-completed-text: Readline Init File Syntax. (line 358) -* SRANDOM: Bash Variables. (line 707) +* SRANDOM: Bash Variables. (line 709) * TEXTDOMAIN: Creating Internationalized Scripts. (line 51) * TEXTDOMAINDIR: Creating Internationalized Scripts. (line 51) -* TIMEFORMAT: Bash Variables. (line 716) -* TMOUT: Bash Variables. (line 754) -* TMPDIR: Bash Variables. (line 766) -* UID: Bash Variables. (line 770) +* TIMEFORMAT: Bash Variables. (line 718) +* TMOUT: Bash Variables. (line 756) +* TMPDIR: Bash Variables. (line 768) +* UID: Bash Variables. (line 772) * vi-cmd-mode-string: Readline Init File Syntax. (line 371) * vi-ins-mode-string: Readline Init File Syntax. @@ -12922,138 +12924,138 @@ D.5 Concept Index  Tag Table: -Node: Top902 -Node: Introduction2844 -Node: What is Bash?3060 -Node: What is a shell?4204 -Node: Definitions6786 -Node: Basic Shell Features9965 -Node: Shell Syntax11188 -Node: Shell Operation12218 -Node: Quoting13519 -Node: Escape Character14835 -Node: Single Quotes15336 -Node: Double Quotes15688 -Node: ANSI-C Quoting17034 -Node: Locale Translation18422 -Node: Creating Internationalized Scripts19769 -Node: Comments23970 -Node: Shell Commands24608 -Node: Reserved Words25550 -Node: Simple Commands26418 -Node: Pipelines27080 -Node: Lists30146 -Node: Compound Commands32021 -Node: Looping Constructs33033 -Node: Conditional Constructs35580 -Node: Command Grouping50487 -Node: Coprocesses51977 -Node: GNU Parallel54676 -Node: Shell Functions55597 -Node: Shell Parameters63706 -Node: Positional Parameters68242 -Node: Special Parameters69180 -Node: Shell Expansions72490 -Node: Brace Expansion74682 -Node: Tilde Expansion77348 -Node: Shell Parameter Expansion80117 -Node: Command Substitution99144 -Node: Arithmetic Expansion102680 -Node: Process Substitution103648 -Node: Word Splitting104788 -Node: Filename Expansion106932 -Node: Pattern Matching110031 -Node: Quote Removal115267 -Node: Redirections115574 -Node: Executing Commands125386 -Node: Simple Command Expansion126056 -Node: Command Search and Execution128170 -Node: Command Execution Environment130581 -Node: Environment133893 -Node: Exit Status135600 -Node: Signals137388 -Node: Shell Scripts141005 -Node: Shell Builtin Commands144100 -Node: Bourne Shell Builtins146214 -Node: Bash Builtins170621 -Node: Modifying Shell Behavior205229 -Node: The Set Builtin205574 -Node: The Shopt Builtin217092 -Node: Special Builtins233831 -Node: Shell Variables234823 -Node: Bourne Shell Variables235260 -Node: Bash Variables237456 -Node: Bash Features273881 -Node: Invoking Bash274898 -Node: Bash Startup Files281300 -Node: Interactive Shells286615 -Node: What is an Interactive Shell?287026 -Node: Is this Shell Interactive?287695 -Node: Interactive Shell Behavior288522 -Node: Bash Conditional Expressions292279 -Node: Shell Arithmetic297456 -Node: Aliases300541 -Node: Arrays303499 -Node: The Directory Stack310301 -Node: Directory Stack Builtins311101 -Node: Controlling the Prompt315553 -Node: The Restricted Shell318694 -Node: Bash POSIX Mode321484 -Node: Shell Compatibility Mode338968 -Node: Job Control347457 -Node: Job Control Basics347917 -Node: Job Control Builtins353094 -Node: Job Control Variables359057 -Node: Command Line Editing360237 -Node: Introduction and Notation361944 -Node: Readline Interaction363591 -Node: Readline Bare Essentials364782 -Node: Readline Movement Commands366603 -Node: Readline Killing Commands367603 -Node: Readline Arguments369584 -Node: Searching370644 -Node: Readline Init File372876 -Node: Readline Init File Syntax374161 -Node: Conditional Init Constructs399102 -Node: Sample Init File403470 -Node: Bindable Readline Commands406594 -Node: Commands For Moving407822 -Node: Commands For History409925 -Node: Commands For Text415011 -Node: Commands For Killing419089 -Node: Numeric Arguments421893 -Node: Commands For Completion423048 -Node: Keyboard Macros427367 -Node: Miscellaneous Commands428071 -Node: Readline vi Mode434728 -Node: Programmable Completion435683 -Node: Programmable Completion Builtins443643 -Node: A Programmable Completion Example455212 -Node: Using History Interactively460560 -Node: Bash History Facilities461244 -Node: Bash History Builtins464359 -Node: History Interaction469605 -Node: Event Designators473933 -Node: Word Designators475519 -Node: Modifiers477508 -Node: Installing Bash479420 -Node: Basic Installation480557 -Node: Compilers and Options484439 -Node: Compiling For Multiple Architectures485192 -Node: Installation Names486944 -Node: Specifying the System Type489181 -Node: Sharing Defaults489930 -Node: Operation Controls490647 -Node: Optional Features491669 -Node: Reporting Bugs503474 -Node: Major Differences From The Bourne Shell504826 -Node: GNU Free Documentation License522638 -Node: Indexes547818 -Node: Builtin Index548272 -Node: Reserved Word Index555373 -Node: Variable Index557821 -Node: Function Index574955 -Node: Concept Index588814 +Node: Top904 +Node: Introduction2848 +Node: What is Bash?3064 +Node: What is a shell?4208 +Node: Definitions6790 +Node: Basic Shell Features9969 +Node: Shell Syntax11192 +Node: Shell Operation12222 +Node: Quoting13523 +Node: Escape Character14839 +Node: Single Quotes15340 +Node: Double Quotes15692 +Node: ANSI-C Quoting17038 +Node: Locale Translation18426 +Node: Creating Internationalized Scripts19773 +Node: Comments23974 +Node: Shell Commands24612 +Node: Reserved Words25554 +Node: Simple Commands26422 +Node: Pipelines27084 +Node: Lists30150 +Node: Compound Commands32025 +Node: Looping Constructs33037 +Node: Conditional Constructs35584 +Node: Command Grouping50491 +Node: Coprocesses51981 +Node: GNU Parallel54680 +Node: Shell Functions55601 +Node: Shell Parameters63710 +Node: Positional Parameters68246 +Node: Special Parameters69184 +Node: Shell Expansions72494 +Node: Brace Expansion74686 +Node: Tilde Expansion77352 +Node: Shell Parameter Expansion80121 +Node: Command Substitution99148 +Node: Arithmetic Expansion102684 +Node: Process Substitution103652 +Node: Word Splitting104792 +Node: Filename Expansion106936 +Node: Pattern Matching110035 +Node: Quote Removal115271 +Node: Redirections115578 +Node: Executing Commands125390 +Node: Simple Command Expansion126060 +Node: Command Search and Execution128174 +Node: Command Execution Environment130585 +Node: Environment133897 +Node: Exit Status135604 +Node: Signals137392 +Node: Shell Scripts141009 +Node: Shell Builtin Commands144104 +Node: Bourne Shell Builtins146218 +Node: Bash Builtins170625 +Node: Modifying Shell Behavior205233 +Node: The Set Builtin205578 +Node: The Shopt Builtin217096 +Node: Special Builtins233835 +Node: Shell Variables234827 +Node: Bourne Shell Variables235264 +Node: Bash Variables237460 +Node: Bash Features274013 +Node: Invoking Bash275030 +Node: Bash Startup Files281432 +Node: Interactive Shells286747 +Node: What is an Interactive Shell?287158 +Node: Is this Shell Interactive?287827 +Node: Interactive Shell Behavior288654 +Node: Bash Conditional Expressions292411 +Node: Shell Arithmetic297588 +Node: Aliases300673 +Node: Arrays303631 +Node: The Directory Stack310433 +Node: Directory Stack Builtins311233 +Node: Controlling the Prompt315685 +Node: The Restricted Shell318826 +Node: Bash POSIX Mode321616 +Node: Shell Compatibility Mode339100 +Node: Job Control347589 +Node: Job Control Basics348049 +Node: Job Control Builtins353226 +Node: Job Control Variables359189 +Node: Command Line Editing360369 +Node: Introduction and Notation362076 +Node: Readline Interaction363723 +Node: Readline Bare Essentials364914 +Node: Readline Movement Commands366735 +Node: Readline Killing Commands367735 +Node: Readline Arguments369716 +Node: Searching370776 +Node: Readline Init File373008 +Node: Readline Init File Syntax374293 +Node: Conditional Init Constructs399234 +Node: Sample Init File403602 +Node: Bindable Readline Commands406726 +Node: Commands For Moving407954 +Node: Commands For History410057 +Node: Commands For Text415143 +Node: Commands For Killing419221 +Node: Numeric Arguments422025 +Node: Commands For Completion423180 +Node: Keyboard Macros427499 +Node: Miscellaneous Commands428203 +Node: Readline vi Mode434860 +Node: Programmable Completion435815 +Node: Programmable Completion Builtins443775 +Node: A Programmable Completion Example455344 +Node: Using History Interactively460692 +Node: Bash History Facilities461376 +Node: Bash History Builtins464491 +Node: History Interaction469737 +Node: Event Designators474065 +Node: Word Designators475651 +Node: Modifiers477640 +Node: Installing Bash479552 +Node: Basic Installation480689 +Node: Compilers and Options484571 +Node: Compiling For Multiple Architectures485324 +Node: Installation Names487076 +Node: Specifying the System Type489313 +Node: Sharing Defaults490062 +Node: Operation Controls490779 +Node: Optional Features491801 +Node: Reporting Bugs503606 +Node: Major Differences From The Bourne Shell504958 +Node: GNU Free Documentation License522770 +Node: Indexes547950 +Node: Builtin Index548404 +Node: Reserved Word Index555505 +Node: Variable Index557953 +Node: Function Index575087 +Node: Concept Index588946  End Tag Table diff --git a/lib/readline/display.c b/lib/readline/display.c index 258631eb..1c486f16 100644 --- a/lib/readline/display.c +++ b/lib/readline/display.c @@ -2063,7 +2063,11 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l assume it's a combining character and back one up so the two base characters no longer compare equivalently. */ t = MBRTOWC (&wc, ofd, mb_cur_max, &ps); +#if 0 if (t > 0 && UNICODE_COMBINING_CHAR (wc) && WCWIDTH (wc) == 0) +#else + if (t > 0 && IS_COMBINING_CHAR (wc)) +#endif { old_offset = _rl_find_prev_mbchar (old, ofd - old, MB_FIND_ANY); new_offset = _rl_find_prev_mbchar (new, nfd - new, MB_FIND_ANY); diff --git a/lib/readline/mbutil.c b/lib/readline/mbutil.c index 95d232f7..33588cc7 100644 --- a/lib/readline/mbutil.c +++ b/lib/readline/mbutil.c @@ -216,11 +216,13 @@ _rl_find_next_mbchar_internal (const char *string, int seed, int count, int find if (find_non_zero) { - tmp = MBRTOWC (&wc, string + point, strlen (string + point), &ps); + len = strlen (string + point); + tmp = MBRTOWC (&wc, string + point, len, &ps); while (MB_NULLWCH (tmp) == 0 && MB_INVALIDCH (tmp) == 0 && WCWIDTH (wc) == 0) { point += tmp; - tmp = MBRTOWC (&wc, string + point, strlen (string + point), &ps); + len -= tmp; + tmp = MBRTOWC (&wc, string + point, len, &ps); } } @@ -261,11 +263,16 @@ _rl_find_prev_utf8char (const char *string, int seed, int find_non_zero) save = prev; /* Move back until we're not in the middle of a multibyte char */ +#if 0 if (UTF8_MBCHAR (b)) { while (prev > 0 && (b = (unsigned char)string[--prev]) && UTF8_MBCHAR (b)) ; } +#else + while (prev > 0 && (b = (unsigned char)string[--prev]) && UTF8_MBFIRSTCHAR (b) == 0) + ; +#endif if (UTF8_MBFIRSTCHAR (b)) { diff --git a/lib/readline/rlmbutil.h b/lib/readline/rlmbutil.h index 92ce05bd..fe6f4dcb 100644 --- a/lib/readline/rlmbutil.h +++ b/lib/readline/rlmbutil.h @@ -172,11 +172,16 @@ _rl_wcwidth (WCHAR_T wc) } } -/* Unicode combining characters range from U+0300 to U+036F */ -#define UNICODE_COMBINING_CHAR(x) ((x) >= 768 && (x) <= 879) +/* Unicode combining characters as of version 15.1 */ +#define UNICODE_COMBINING_CHAR(x) \ + (((x) >= 0x0300 && (x) <= 0x036F) || \ + ((x) >= 0x1AB0 && (x) <= 0x1AFF) || \ + ((x) >= 0x1DC0 && (x) <= 0x1DFF) || \ + ((x) >= 0x20D0 && (x) <= 0x20FF) || \ + ((x) >= 0xFE20 && (x) <= 0xFE2F)) #if defined (WCWIDTH_BROKEN) -# define WCWIDTH(wc) ((_rl_utf8locale && UNICODE_COMBINING_CHAR(wc)) ? 0 : _rl_wcwidth(wc)) +# define WCWIDTH(wc) ((_rl_utf8locale && UNICODE_COMBINING_CHAR((int)wc)) ? 0 : _rl_wcwidth(wc)) #else # define WCWIDTH(wc) _rl_wcwidth(wc) #endif @@ -187,6 +192,8 @@ _rl_wcwidth (WCHAR_T wc) # define IS_COMBINING_CHAR(x) (WCWIDTH(x) == 0) #endif +#define IS_BASE_CHAR(x) (iswgraph(x) && WCWIDTH(x) > 0) + #define UTF8_SINGLEBYTE(c) (((c) & 0x80) == 0) #define UTF8_MBFIRSTCHAR(c) (((c) & 0xc0) == 0xc0) #define UTF8_MBCHAR(c) (((c) & 0xc0) == 0x80) diff --git a/subst.c b/subst.c index 7a04d71e..e5f7d250 100644 --- a/subst.c +++ b/subst.c @@ -368,7 +368,7 @@ static WORD_LIST *glob_expand_word_list (WORD_LIST *, int); static WORD_LIST *brace_expand_word_list (WORD_LIST *, int); #endif #if defined (ARRAY_VARS) -static int make_internal_declare (char *, char *, char *); +static int make_internal_declare (const char *, const char *, const char *, const char *); static void expand_compound_assignment_word (WORD_LIST *, int); static WORD_LIST *expand_declaration_argument (WORD_LIST *, WORD_LIST *); #endif @@ -12654,7 +12654,7 @@ brace_expand_word_list (WORD_LIST *tlist, int eflags) the list of options to supply to `declare'. CMD is the declaration command we are expanding right now; it's unused currently. */ static int -make_internal_declare (char *word, char *option, char *cmd) +make_internal_declare (const char *word, const char *opts_on, const char *opts_off, const char *cmd) { int t, r; WORD_LIST *wl; @@ -12671,7 +12671,10 @@ make_internal_declare (char *word, char *option, char *cmd) } wl = make_word_list (w, (WORD_LIST *)NULL); - wl = make_word_list (make_word (option), wl); + if (*opts_on) + wl = make_word_list (make_word (opts_on), wl); + if (*opts_off) + wl = make_word_list (make_word (opts_off), wl); r = declare_builtin (wl); @@ -12810,96 +12813,74 @@ expand_compound_assignment_word (WORD_LIST *tlist, int atype) static WORD_LIST * expand_declaration_argument (WORD_LIST *tlist, WORD_LIST *wcmd) { - char opts[16], omap[128]; - int t, opti, oind, skip, inheriting; + char opts_on[16], opts_off[16], omap[128]; + int t, i_on, i_off, oind, skip, inheriting; WORD_LIST *l; - inheriting = localvar_inherit; - opti = 0; - if (tlist->word->flags & (W_ASSIGNASSOC|W_ASSNGLOBAL|W_CHKLOCAL|W_ASSIGNARRAY)) - opts[opti++] = '-'; + memset (omap, '\0', sizeof (omap)); - if ((tlist->word->flags & (W_ASSIGNASSOC|W_ASSNGLOBAL)) == (W_ASSIGNASSOC|W_ASSNGLOBAL)) - { - opts[opti++] = 'g'; - opts[opti++] = 'A'; - } - else if (tlist->word->flags & W_ASSIGNASSOC) - { - opts[opti++] = 'A'; - } - else if ((tlist->word->flags & (W_ASSIGNARRAY|W_ASSNGLOBAL)) == (W_ASSIGNARRAY|W_ASSNGLOBAL)) - { - opts[opti++] = 'g'; - opts[opti++] = 'a'; - } + if (tlist->word->flags & W_ASSIGNASSOC) + omap['A'] = 1; else if (tlist->word->flags & W_ASSIGNARRAY) - { - opts[opti++] = 'a'; - } - else if (tlist->word->flags & W_ASSNGLOBAL) - opts[opti++] = 'g'; + omap['a'] = 1; + if (tlist->word->flags & W_ASSNGLOBAL) + omap['g'] = 1; if (tlist->word->flags & W_CHKLOCAL) - opts[opti++] = 'G'; + omap['G'] = 1; /* If we have special handling note the integer attribute and others that transform the value upon assignment. What we do is take all of the option arguments and scan through them looking for options - that cause such transformations, and add them to the `opts' array. */ + that cause such transformations, and add them to either the `opts_on' + or `opts_off' array as appropriate. */ - memset (omap, '\0', sizeof (omap)); for (l = wcmd->next; l != tlist; l = l->next) { int optchar; if (l->word->word[0] != '-' && l->word->word[0] != '+') break; /* non-option argument */ - if (l->word->word[0] == '-' && l->word->word[1] == '-' && l->word->word[2] == 0) + if (l->word->word[1] == 0) + break; /* handle `local -'; let `declare +' be an error */ + + if (ISOPTION (l->word->word, '-')) break; /* -- signals end of options */ + optchar = l->word->word[0]; for (oind = 1; l->word->word[oind]; oind++) switch (l->word->word[oind]) { case 'I': - inheriting = 1; case 'i': case 'l': case 'u': case 'c': - omap[l->word->word[oind]] = 1; - if (opti == 0) - opts[opti++] = optchar; + omap[l->word->word[oind]] |= (optchar == '-' ? 1 : 2); break; default: break; } } + i_on = i_off = 0; for (oind = 0; oind < sizeof (omap); oind++) - if (omap[oind]) - opts[opti++] = oind; - - /* If there are no -a/-A options, but we have a compound assignment, - we have a choice: we can set opts[0]='-', opts[1]='a', since the - default is to create an indexed array, and call - make_internal_declare with that, or we can just skip the -a and let - declare_builtin deal with it. Once we're here, we're better set - up for the latter, since we don't want to deal with looking up - any existing variable here -- better to let declare_builtin do it. - We need the variable created, though, especially if it's local, so - we get the scoping right before we call do_word_assignment. - To ensure that make_local_declare gets called, we add `--' if there - aren't any options. */ - if ((tlist->word->flags & (W_ASSIGNASSOC|W_ASSIGNARRAY)) == 0) { - if (opti == 0) + if (omap[oind] & 1) /* on options */ { - opts[opti++] = '-'; - opts[opti++] = '-'; + if (i_on == 0) + opts_on[i_on++] = '-'; + opts_on[i_on++] = oind; + } + if (omap[oind] & 2) /* off options */ + { + if (i_off == 0) + opts_off[i_off++] = '+'; + opts_off[i_off++] = oind; } } - opts[opti] = '\0'; + + opts_on[i_on] = opts_off[i_off] = '\0'; /* This isn't perfect, but it's a start. Improvements later. We expand tlist->word->word and single-quote the results to avoid multiple @@ -12910,17 +12891,15 @@ expand_declaration_argument (WORD_LIST *tlist, WORD_LIST *wcmd) expand_compound_assignment_word (tlist, (tlist->word->flags & W_ASSIGNASSOC) ? 1 : 0); skip = 0; - if (opti > 0) + /* We always call make_internal_declare */ + t = make_internal_declare (tlist->word->word, opts_on, opts_off, wcmd ? wcmd->word->word : (char *)0); + if (t != EXECUTION_SUCCESS) { - t = make_internal_declare (tlist->word->word, opts, wcmd ? wcmd->word->word : (char *)0); - if (t != EXECUTION_SUCCESS) - { - last_command_exit_value = t; - if (tlist->word->flags & W_FORCELOCAL) /* non-fatal error */ - skip = 1; - else - exp_jump_to_top_level (DISCARD); - } + last_command_exit_value = t; + if (tlist->word->flags & W_FORCELOCAL) /* non-fatal error */ + skip = 1; + else + exp_jump_to_top_level (DISCARD); } if (skip == 0) diff --git a/tests/array.right b/tests/array.right index 5da194a6..6b7b21c2 100644 --- a/tests/array.right +++ b/tests/array.right @@ -1,6 +1,6 @@ -./array.tests: line 28: syntax error near unexpected token `&' -./array.tests: line 28: `test=(first & second)' +./array.tests: line 34: syntax error near unexpected token `&' +./array.tests: line 34: `test=(first & second)' 1 abcde abcde @@ -26,7 +26,7 @@ hello world 11 3 bdef hello world test expression test 2 -./array.tests: line 92: readonly: `a[5]': not a valid identifier +./array.tests: line 98: readonly: `a[5]': not a valid identifier declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2") declare -ar c declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2") @@ -46,17 +46,17 @@ declare -ar c declare -a d=([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element") declare -a e=([0]="test") declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element") -./array.tests: line 116: a: readonly variable -./array.tests: line 118: b[]: bad array subscript -./array.tests: line 119: b[*]: bad array subscript +./array.tests: line 122: a: readonly variable +./array.tests: line 124: b[]: bad array subscript +./array.tests: line 125: b[*]: bad array subscript this -./array.tests: line 122: c[-2]: bad array subscript -./array.tests: line 123: c: bad array subscript +./array.tests: line 128: c[-2]: bad array subscript +./array.tests: line 129: c: bad array subscript -./array.tests: line 125: d[7]: cannot assign list to array member -./array.tests: line 127: []=abcde: bad array subscript -./array.tests: line 128: [*]=last: cannot assign to non-numeric index -./array.tests: line 129: [-65]=negative: bad array subscript +./array.tests: line 131: d[7]: cannot assign list to array member +./array.tests: line 133: []=abcde: bad array subscript +./array.tests: line 134: [*]=last: cannot assign to non-numeric index +./array.tests: line 135: [-65]=negative: bad array subscript declare -a BASH_ARGC=() declare -a BASH_ARGV=() declare -a BASH_LINENO=([0]="0") @@ -69,8 +69,8 @@ declare -ar c declare -a d=([1]="test test") declare -a e=() declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element") -./array.tests: line 137: unset: ps1: not an array variable -./array.tests: line 141: declare: c: readonly variable +./array.tests: line 143: unset: ps1: not an array variable +./array.tests: line 147: declare: c: readonly variable this of this is a test of read using arrays this test @@ -123,7 +123,7 @@ argv[1] = 55 49 6 -- 6 -./array.tests: line 232: [-10]: bad array subscript +./array.tests: line 238: [-10]: bad array subscript 0 42 14 44 grep [ 123 ] * @@ -131,9 +131,9 @@ grep [ 123 ] * 6 7 9 5 length = 3 value = new1 new2 new3 -./array.tests: line 261: syntax error near unexpected token `&' -./array.tests: line 261: `badarray=( metacharacters like & need to be quoted in compound assignments)' -./array.tests: line 265: narray: unbound variable +./array.tests: line 267: syntax error near unexpected token `&' +./array.tests: line 267: `badarray=( metacharacters like & need to be quoted in compound assignments)' +./array.tests: line 271: narray: unbound variable ./array1.sub: line 1: syntax error near unexpected token `(' ./array1.sub: line 1: `printf "%s\n" -a a=(a 'b c')' ./array2.sub: line 1: declare: `[]=asdf': not a valid identifier @@ -160,10 +160,10 @@ for case if then else 12 14 16 18 20 4414758999202 aaa bbb -./array.tests: line 315: syntax error near unexpected token `<>' -./array.tests: line 315: `metas=( <> < > ! )' -./array.tests: line 316: syntax error near unexpected token `<>' -./array.tests: line 316: `metas=( [1]=<> [2]=< [3]=> [4]=! )' +./array.tests: line 321: syntax error near unexpected token `<>' +./array.tests: line 321: `metas=( <> < > ! )' +./array.tests: line 322: syntax error near unexpected token `<>' +./array.tests: line 322: `metas=( [1]=<> [2]=< [3]=> [4]=! )' abc 3 case 4 abc case if then else 5 diff --git a/tests/array.tests b/tests/array.tests index b6d6c9cc..dfcba2d0 100644 --- a/tests/array.tests +++ b/tests/array.tests @@ -11,13 +11,19 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # + +# Filter stdin to remove builtin array variables that are +# automatically set and possibly contain values that vary. +ignore_builtin_arrays() +{ + grep -v -e BASH_VERSINFO= -e PIPESTATUS= -e GROUPS= +} + # this is needed so that the bad assignments (b[]=bcde, for example) do not # cause fatal shell errors when in posix mode set +o posix set +a -# The calls to egrep -v are to filter out builtin array variables that are -# automatically set and possibly contain values that vary. # first make sure we handle the basics x=() @@ -61,7 +67,7 @@ echo ${a[@]} echo ${a[*]} # this should print out values, too -declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)' +declare -a | ignore_builtin_arrays unset a[7] echo ${a[*]} @@ -92,11 +98,11 @@ echo ${a[@]} readonly a[5] readonly a # these two lines should output `declare' commands -readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)' -declare -ar | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)' +readonly -a | ignore_builtin_arrays +declare -ar | ignore_builtin_arrays # this line should output `readonly' commands, even for arrays set -o posix -readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)' +readonly -a | ignore_builtin_arrays set +o posix declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")' @@ -111,7 +117,7 @@ b=([0]=this [1]=is [2]=a [3]=test [4]="$PS1" [5]=$pass) echo ${b[@]:2:3} -declare -pa | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)' +declare -pa | ignore_builtin_arrays a[3]="this is a test" @@ -131,7 +137,7 @@ d=([1]="test test" [-65]=negative ) unset d[12] unset e[*] -declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)' +declare -a | ignore_builtin_arrays ps1='hello' unset ps1[2] @@ -157,7 +163,7 @@ echo ${vv[0]} ${vv[3]} echo ${vv[@]} unset vv -declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)' +declare -a | ignore_builtin_arrays export rv #set