implementation of printf '%N$' numbered argument conversion specifier, compatible with coreutils

This commit is contained in:
Chet Ramey
2025-12-05 15:50:38 -05:00
parent 5a104e96d8
commit f27bf94a79
29 changed files with 2012 additions and 1428 deletions
+165 -149
View File
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 7.2 from
bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 24 September 2025).
Bash shell (version 5.3, 2 December 2025).
This is Edition 5.3, last updated 24 September 2025, of The GNU Bash
This is Edition 5.3, last updated 2 December 2025, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Copyright © 1988-2025 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, 24 September 2025). The Bash home page is
Bash shell (version 5.3, 2 December 2025). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 24 September 2025, of The GNU Bash
This is Edition 5.3, last updated 2 December 2025, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -4370,7 +4370,7 @@ standard.
The -f option means to load the new builtin command NAME from
shared object FILENAME, on systems that support dynamic loading.
If FILENAME does not contain a slash. Bash will use the value of
If FILENAME does not contain a slash, Bash will use the value of
the BASH_LOADABLES_PATH variable as a colon-separated list of
directories in which to search for FILENAME. The default for
BASH_LOADABLES_PATH is system-dependent, and may include "." to
@@ -4562,12 +4562,25 @@ standard.
the numeric value of the following character, using the current
locale.
Format specifiers may apply to the Nth argument rather than the
next sequential argument. In this case, the % in the format
specifier is replaced by the sequence %N$, where N is a decimal
integer greater than 0, giving the argument number to use as the
operand. The format string should not mix numbered and unnumbered
argument specifiers, though this is allowed. Unnumbered argument
specifiers always refer to the next argument following the last
argument consumed by an unnumbered specifier; numbered argument
specifiers refer to absolute positions in the argument list.
The FORMAT is reused as necessary to consume all of the ARGUMENTS.
If the FORMAT requires more ARGUMENTS than are supplied, the extra
format specifications behave as if a zero value or null string, as
appropriate, had been supplied. The return value is zero on
success, non-zero if an invalid option is supplied or a write or
assignment error occurs.
appropriate, had been supplied. If FORMAT is reused, a numbered
argument specifier %N$ refers to the Nth argument following the
highest numbered argument consumed by the previous use of FORMAT.
The return value is zero on success, non-zero if an invalid option
is supplied or a write or assignment error occurs.
read
read [-Eers] [-a ANAME] [-d DELIM] [-i TEXT] [-n NCHARS]
@@ -7311,6 +7324,9 @@ end of the array, and an index of -1 references the last element.
The += operator appends to an array variable when assigning using
the compound assignment syntax; see *note Shell Parameters:: above.
If one of the word expansions in a compound array assignment unsets
the variable, the results are unspecified.
An array element is 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
@@ -7570,8 +7586,8 @@ can appear in the prompt variables PS0, PS1, PS2, and PS4
\\
A backslash.
\[
Begin a sequence of non-printing characters. Thiss could be used
to embed a terminal control sequence into the prompt.
Begin a sequence of non-printing characters. This could be used to
embed a terminal control sequence into the prompt.
\]
End a sequence of non-printing characters.
@@ -12951,8 +12967,8 @@ D.1 Index of Shell Builtin Commands
(line 71)
* pwd: Bourne Shell Builtins.
(line 265)
* read: Bash Builtins. (line 558)
* readarray: Bash Builtins. (line 669)
* read: Bash Builtins. (line 571)
* readarray: Bash Builtins. (line 682)
* readonly: Bourne Shell Builtins.
(line 277)
* return: Bourne Shell Builtins.
@@ -12961,7 +12977,7 @@ D.1 Index of Shell Builtin Commands
* shift: Bourne Shell Builtins.
(line 327)
* shopt: The Shopt Builtin. (line 9)
* source: Bash Builtins. (line 678)
* source: Bash Builtins. (line 691)
* suspend: Job Control Builtins.
(line 141)
* test: Bourne Shell Builtins.
@@ -12972,12 +12988,12 @@ D.1 Index of Shell Builtin Commands
(line 446)
* true: Bourne Shell Builtins.
(line 512)
* type: Bash Builtins. (line 683)
* typeset: Bash Builtins. (line 720)
* ulimit: Bash Builtins. (line 726)
* type: Bash Builtins. (line 696)
* typeset: Bash Builtins. (line 733)
* ulimit: Bash Builtins. (line 739)
* umask: Bourne Shell Builtins.
(line 517)
* unalias: Bash Builtins. (line 834)
* unalias: Bash Builtins. (line 847)
* unset: Bourne Shell Builtins.
(line 535)
* wait: Job Control Builtins.
@@ -13661,138 +13677,138 @@ D.5 Concept Index

Tag Table:
Node: Top906
Node: Introduction2852
Node: What is Bash?3068
Node: What is a shell?4204
Node: Definitions6817
Node: Basic Shell Features10147
Node: Shell Syntax11374
Node: Shell Operation12404
Node: Quoting13698
Node: Escape Character15039
Node: Single Quotes15577
Node: Double Quotes15929
Node: ANSI-C Quoting17277
Node: Locale Translation18674
Node: Creating Internationalized Scripts20080
Node: Comments24281
Node: Shell Commands25051
Node: Reserved Words25993
Node: Simple Commands27139
Node: Pipelines27804
Node: Lists31063
Node: Compound Commands32986
Node: Looping Constructs33998
Node: Conditional Constructs36550
Node: Command Grouping51690
Node: Coprocesses53185
Node: GNU Parallel55874
Node: Shell Functions56795
Node: Shell Parameters65246
Node: Positional Parameters70150
Node: Special Parameters71243
Node: Shell Expansions74707
Node: Brace Expansion76899
Node: Tilde Expansion80238
Node: Shell Parameter Expansion83196
Node: Command Substitution103846
Node: Arithmetic Expansion107378
Node: Process Substitution108557
Node: Word Splitting109668
Node: Filename Expansion112115
Node: Pattern Matching115342
Node: Quote Removal121111
Node: Redirections121418
Node: Executing Commands131677
Node: Simple Command Expansion132347
Node: Command Search and Execution134458
Node: Command Execution Environment136905
Node: Environment140356
Node: Exit Status142262
Node: Signals144324
Node: Shell Scripts149275
Node: Shell Builtin Commands152576
Node: Bourne Shell Builtins154920
Node: Bash Builtins181642
Node: Modifying Shell Behavior218569
Node: The Set Builtin218914
Node: The Shopt Builtin230911
Node: Special Builtins247967
Node: Shell Variables248959
Node: Bourne Shell Variables249396
Node: Bash Variables251907
Node: Bash Features291194
Node: Invoking Bash292211
Node: Bash Startup Files298798
Node: Interactive Shells304043
Node: What is an Interactive Shell?304454
Node: Is this Shell Interactive?305119
Node: Interactive Shell Behavior305946
Node: Bash Conditional Expressions309710
Node: Shell Arithmetic315130
Node: Aliases318460
Node: Arrays321597
Node: The Directory Stack329188
Node: Directory Stack Builtins329988
Node: Controlling the Prompt334436
Node: The Restricted Shell337324
Node: Bash POSIX Mode340209
Node: Shell Compatibility Mode359159
Node: Job Control368169
Node: Job Control Basics368629
Node: Job Control Builtins375000
Node: Job Control Variables381791
Node: Command Line Editing383025
Node: Introduction and Notation384731
Node: Readline Interaction387086
Node: Readline Bare Essentials388277
Node: Readline Movement Commands390088
Node: Readline Killing Commands391087
Node: Readline Arguments393113
Node: Searching394206
Node: Readline Init File396452
Node: Readline Init File Syntax397758
Node: Conditional Init Constructs424712
Node: Sample Init File429100
Node: Bindable Readline Commands432223
Node: Commands For Moving433764
Node: Commands For History436231
Node: Commands For Text441625
Node: Commands For Killing445753
Node: Numeric Arguments448544
Node: Commands For Completion449699
Node: Keyboard Macros455398
Node: Miscellaneous Commands456102
Node: Readline vi Mode462672
Node: Programmable Completion463652
Node: Programmable Completion Builtins473391
Node: A Programmable Completion Example485131
Node: Using History Interactively490479
Node: Bash History Facilities491163
Node: Bash History Builtins494901
Node: History Interaction501375
Node: Event Designators506328
Node: Word Designators507909
Node: Modifiers510304
Node: Installing Bash512244
Node: Basic Installation513363
Node: Compilers and Options517242
Node: Compiling For Multiple Architectures517995
Node: Installation Names519751
Node: Specifying the System Type521988
Node: Sharing Defaults522737
Node: Operation Controls523454
Node: Optional Features524476
Node: Reporting Bugs537202
Node: Major Differences From The Bourne Shell538562
Node: GNU Free Documentation License559992
Node: Indexes585172
Node: Builtin Index585626
Node: Reserved Word Index592727
Node: Variable Index595175
Node: Function Index612591
Node: Concept Index626589
Node: Top902
Node: Introduction2844
Node: What is Bash?3060
Node: What is a shell?4196
Node: Definitions6809
Node: Basic Shell Features10139
Node: Shell Syntax11366
Node: Shell Operation12396
Node: Quoting13690
Node: Escape Character15031
Node: Single Quotes15569
Node: Double Quotes15921
Node: ANSI-C Quoting17269
Node: Locale Translation18666
Node: Creating Internationalized Scripts20072
Node: Comments24273
Node: Shell Commands25043
Node: Reserved Words25985
Node: Simple Commands27131
Node: Pipelines27796
Node: Lists31055
Node: Compound Commands32978
Node: Looping Constructs33990
Node: Conditional Constructs36542
Node: Command Grouping51682
Node: Coprocesses53177
Node: GNU Parallel55866
Node: Shell Functions56787
Node: Shell Parameters65238
Node: Positional Parameters70142
Node: Special Parameters71235
Node: Shell Expansions74699
Node: Brace Expansion76891
Node: Tilde Expansion80230
Node: Shell Parameter Expansion83188
Node: Command Substitution103838
Node: Arithmetic Expansion107370
Node: Process Substitution108549
Node: Word Splitting109660
Node: Filename Expansion112107
Node: Pattern Matching115334
Node: Quote Removal121103
Node: Redirections121410
Node: Executing Commands131669
Node: Simple Command Expansion132339
Node: Command Search and Execution134450
Node: Command Execution Environment136897
Node: Environment140348
Node: Exit Status142254
Node: Signals144316
Node: Shell Scripts149267
Node: Shell Builtin Commands152568
Node: Bourne Shell Builtins154912
Node: Bash Builtins181634
Node: Modifying Shell Behavior219373
Node: The Set Builtin219718
Node: The Shopt Builtin231715
Node: Special Builtins248771
Node: Shell Variables249763
Node: Bourne Shell Variables250200
Node: Bash Variables252711
Node: Bash Features291998
Node: Invoking Bash293015
Node: Bash Startup Files299602
Node: Interactive Shells304847
Node: What is an Interactive Shell?305258
Node: Is this Shell Interactive?305923
Node: Interactive Shell Behavior306750
Node: Bash Conditional Expressions310514
Node: Shell Arithmetic315934
Node: Aliases319264
Node: Arrays322401
Node: The Directory Stack330107
Node: Directory Stack Builtins330907
Node: Controlling the Prompt335355
Node: The Restricted Shell338242
Node: Bash POSIX Mode341127
Node: Shell Compatibility Mode360077
Node: Job Control369087
Node: Job Control Basics369547
Node: Job Control Builtins375918
Node: Job Control Variables382709
Node: Command Line Editing383943
Node: Introduction and Notation385649
Node: Readline Interaction388004
Node: Readline Bare Essentials389195
Node: Readline Movement Commands391006
Node: Readline Killing Commands392005
Node: Readline Arguments394031
Node: Searching395124
Node: Readline Init File397370
Node: Readline Init File Syntax398676
Node: Conditional Init Constructs425630
Node: Sample Init File430018
Node: Bindable Readline Commands433141
Node: Commands For Moving434682
Node: Commands For History437149
Node: Commands For Text442543
Node: Commands For Killing446671
Node: Numeric Arguments449462
Node: Commands For Completion450617
Node: Keyboard Macros456316
Node: Miscellaneous Commands457020
Node: Readline vi Mode463590
Node: Programmable Completion464570
Node: Programmable Completion Builtins474309
Node: A Programmable Completion Example486049
Node: Using History Interactively491397
Node: Bash History Facilities492081
Node: Bash History Builtins495819
Node: History Interaction502293
Node: Event Designators507246
Node: Word Designators508827
Node: Modifiers511222
Node: Installing Bash513162
Node: Basic Installation514281
Node: Compilers and Options518160
Node: Compiling For Multiple Architectures518913
Node: Installation Names520669
Node: Specifying the System Type522906
Node: Sharing Defaults523655
Node: Operation Controls524372
Node: Optional Features525394
Node: Reporting Bugs538120
Node: Major Differences From The Bourne Shell539480
Node: GNU Free Documentation License560910
Node: Indexes586090
Node: Builtin Index586544
Node: Reserved Word Index593645
Node: Variable Index596093
Node: Function Index613509
Node: Concept Index627507

End Tag Table