new readline "fetch-history" bindable command; declare -p output change

This commit is contained in:
Chet Ramey
2021-04-01 17:25:48 -04:00
parent 65822e5011
commit 8f485ff84c
17 changed files with 3065 additions and 2786 deletions
+31
View File
@@ -9925,3 +9925,34 @@ lib/readline/terminal.c
(kN) and bind them to history-search-{backward,forward},
respectively. From a patch from Xose Vazquez Perez
<xose.vazquez@gmail.com>
3/30
----
doc/bashref.texi
- expand the node describing $"..." string translation with additional
details and examples
3/31
----
misc.c
- rl_fetch_history: moved here from vi_mode.c
- rl_fetch_history: negative arguments count back from the end of
the history, instead of taking you to the beginning of the history
list
- rl_fetch_history: in vi mode, an out-of-range argument rings the
bell and doesn't change the line
vi_mode.c
- rl_vi_fetch_history: call rl_fetch_history
readline.h
- rl_fetch_history: new extern declaration
doc/bash.1,lib/readline/doc/{readline.3,rluser.texi}
- rl_fetch_history: add description
builtins/setattr.def
- show_var_attributes: if a variable's value indicates that it should
be ANSI-C quoted, use ansic_quote instead of sh_double_quote to
format the value string. From proposal by Greg Wooledge
<greg@wooledge.org>
+4 -1
View File
@@ -514,7 +514,10 @@ show_var_attributes (var, pattr, nodefs)
printf ("%s\n", var->name);
else
{
x = sh_double_quote (value_cell (var));
if (ansic_shouldquote (value_cell (var)))
x = ansic_quote (value_cell (var), 0, (int *)0);
else
x = sh_double_quote (value_cell (var));
printf ("%s=%s\n", var->name, x);
free (x);
}
+2568 -2563
View File
File diff suppressed because it is too large Load Diff
+17 -11
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Tue Mar 16 14:35:58 EDT 2021
.\" Last Change: Wed Mar 31 11:01:34 EDT 2021
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2021 March 16" "GNU Bash 5.1"
.TH BASH 1 "2021 March 30" "GNU Bash 5.1"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -1212,9 +1212,9 @@ not been present.
.PP
A double-quoted string preceded by a dollar sign (\fB$\fP\(dq\fIstring\fP\(dq)
will cause the string to be translated according to the current locale.
The \fIgettext\fP infrastructure performs the message catalog lookup and
translation, using the \fBLC_MESSAGES\fP and \fBTEXTDOMAIN\fP shell
variables.
The \fIgettext\fP infrastructure performs the lookup and
translation, using the \fBLC_MESSAGES\fP, \fBTEXTDOMAINDIR\fP,
and \fBTEXTDOMAIN\fP shell variables.
If the current locale is \fBC\fP or \fBPOSIX\fP,
or if there are no translations available,
the dollar sign is ignored.
@@ -6283,6 +6283,18 @@ Move to the first line in the history.
Move to the end of the input history, i.e., the line currently being
entered.
.TP
.B operate\-and\-get\-next (C\-o)
Accept the current line for execution and fetch the next line
relative to the current line from the history for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
.TP
.B
fetch\-history
With a numeric argument, fetch that entry from the history list
and make it the current line.
Without an argument, move back to the first entry in the history list.
.TP
.B reverse\-search\-history (C\-r)
Search backward starting at the current line and moving `up' through
the history as necessary. This is an incremental search.
@@ -6382,12 +6394,6 @@ Perform history and alias expansion on the current line.
.B insert\-last\-argument (M\-.\^, M\-_\^)
A synonym for \fByank\-last\-arg\fP.
.TP
.B operate\-and\-get\-next (C\-o)
Accept the current line for execution and fetch the next line
relative to the current line from the history for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
.TP
.B edit\-and\-execute\-command (C\-x C\-e)
Invoke an editor on the current command line, and execute the result as shell
commands.
+248 -157
View File
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 6.7 from
bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.1, 4 March2021).
Bash shell (version 5.1, 31 March 2021).
This is Edition 5.1, last updated 4 March2021, of 'The GNU Bash
This is Edition 5.1, last updated 31 March 2021, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.1.
Copyright (C) 1988-2021 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.1, 4 March2021). The Bash home page is
Bash shell (version 5.1, 31 March 2021). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.1, last updated 4 March2021, of 'The GNU Bash
This is Edition 5.1, last updated 31 March 2021, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.1.
Bash contains features that appear in other popular shells, and some
@@ -419,9 +419,10 @@ File: bashref.info, Node: ANSI-C Quoting, Next: Locale Translation, Prev: Dou
3.1.2.4 ANSI-C Quoting
......................
Words of the form $'STRING' are treated specially. The word expands to
STRING, with backslash-escaped characters replaced as specified by the
ANSI C standard. Backslash escape sequences, if present, are decoded as
Character sequences of the form $'STRING' are treated as a special kind
of single quotes. The sequence expands to STRING, with
backslash-escaped characters in STRING replaced as specified by the ANSI
C standard. Backslash escape sequences, if present, are decoded as
follows:
'\a'
@@ -473,22 +474,104 @@ File: bashref.info, Node: Locale Translation, Prev: ANSI-C Quoting, Up: Quoti
3.1.2.5 Locale-Specific Translation
...................................
A double-quoted string preceded by a dollar sign ('$') will cause the
string to be translated according to the current locale. The 'gettext'
infrastructure performs the message catalog lookup and translation,
using the 'LC_MESSAGES' and 'TEXTDOMAIN' shell variables, as explained
below. See the gettext documentation for additional details. If the
current locale is 'C' or 'POSIX', or if there are no translations
available, the dollar sign is ignored. If the string is translated and
replaced, the replacement is double-quoted.
Prefixing a double-quoted string with a dollar sign ('$'), such as
$"hello, world", will cause the string to be translated according to the
current locale. The 'gettext' infrastructure performs the lookup and
translation, using the 'LC_MESSAGES', 'TEXTDOMAINDIR', and 'TEXTDOMAIN'
shell variables, as explained below. See the gettext documentation for
additional details not covered here. If the current locale is 'C' or
'POSIX', or if there are no translations available, the dollar sign is
ignored, and the shell doesn't attempt to translate the string. If the
string is translated and replaced, the replacement is double-quoted.
Some systems use the message catalog selected by the 'LC_MESSAGES'
shell variable. Others create the name of the message catalog from the
value of the 'TEXTDOMAIN' shell variable, possibly adding a suffix of
'.mo'. If you use the 'TEXTDOMAIN' variable, you may need to set the
'TEXTDOMAINDIR' variable to the location of the message catalog files.
Still others use both variables in this fashion:
'TEXTDOMAINDIR'/'LC_MESSAGES'/LC_MESSAGES/'TEXTDOMAIN'.mo.
The rest of this section is a brief overview of how you use gettext
to create translations for strings in a shell script named SCRIPTNAME.
There are more details in the gettext documentation.
Once you've marked the strings in your script that you want to
translate using $"...", you create a gettext "template" file using the
command
bash --dump-po-strings SCRIPTNAME > DOMAIN.pot
The DOMAIN is your "message domain". It's just an arbitrary string
that's used to identify the files gettext needs, like a package or
script name. It needs to be unique among all the message domains on
systems where you install the translations, so gettext knows which
translations correspond to your script. You'll use the template file to
create translations for each target language. The template file
conventionally has the suffix '.pot'.
You copy this template file to a separate file for each target
language you want to support (called "PO" files, which use the suffix
'.po'). PO files use various naming conventions, but when you are
working to translate a template file into a particular language, you
first copy the template file to a file whose name is the language you
want to target, with the '.po' suffix. For instance, the Spanish
translations of your strings would be in a file named 'es.po', and to
get started using a message domain named "example," you would run
cp example.pot es.po
Ultimately, PO files are often named DOMAIN.po and installed in
directories that contain multiple translation files for a particular
language.
Whichever naming convention you choose, you will need to translate
the strings in the PO files into the appropriate languages. This has to
be done manually.
When you have the translations and PO files complete, you'll use the
gettext tools to produce what are called "MO" files, which are compiled
versions of the PO files the gettext tools use to look up translations
efficiently. MO files are also called "message catalog" files. You use
the 'msgfmt' program to do this. For instance, if you had a file with
Spanish translations, you could run
msgfmt -o es.mo es.po
to produce the corresponding MO file.
Once you have the MO files, you decide where to install them and use
the 'TEXTDOMAINDIR' shell variable to tell the gettext tools where they
are. Make sure to use the same message domain to name the MO files as
you did for the PO files when you install them.
Your users will use the 'LANG' or 'LC_MESSAGES' shell variables to
select the desired language.
You set the 'TEXTDOMAIN' variable to the script's message domain. As
above, you use the message domain to name your translation files.
You, or possibly your users, set the 'TEXTDOMAINDIR' variable to the
name of a directory where the message catalog files are stored. If you
install the message files into the system's standard message catalog
directory, you don't need to worry about this variable.
The directory where the message catalog files are stored varies
between systems. Some use the message catalog selected by the
'LC_MESSAGES' shell variable. Others create the name of the message
catalog from the value of the 'TEXTDOMAIN' shell variable, possibly
adding the '.mo' suffix. If you use the 'TEXTDOMAIN' variable, you may
need to set the 'TEXTDOMAINDIR' variable to the location of the message
catalog files, as above. It's common to use both variables in this
fashion: '$TEXTDOMAINDIR'/'$LC_MESSAGES'/LC_MESSAGES/'$TEXTDOMAIN'.mo.
If you used that last convention, and you wanted to store the message
catalog files with Spanish (es) and Esperanto (eo) translations into a
local directory you use for custom translation files, you could run
TEXTDOMAIN=example
TEXTDOMAINDIR=/usr/local/share/locale
cp es.mo ${TEXTDOMAINDIR}/es/LC_MESSAGES/${TEXTDOMAIN}.mo
cp eo.mo ${TEXTDOMAINDIR}/eo/LC_MESSAGES/${TEXTDOMAIN}.mo
When all of this is done, and the message catalog files containing
the compiled translations are installed in the correct location, your
users will be able to see translated strings in any of the supported
languages by setting the 'LANG' or 'LC_MESSAGES' environment variables
before running your script.

File: bashref.info, Node: Comments, Prev: Quoting, Up: Shell Syntax
@@ -8562,6 +8645,11 @@ File: bashref.info, Node: Commands For History, Next: Commands For Text, Prev
supplied, specifies the history entry to use instead of the current
line.
'fetch-history ()'
With a numeric argument, fetch that entry from the history list and
make it the current line. Without an argument, move back to the
first entry in the history list.

File: bashref.info, Node: Commands For Text, Next: Commands For Killing, Prev: Commands For History, Up: Bindable Readline Commands
@@ -11668,11 +11756,12 @@ D.3 Parameter and Variable Index
(line 197)
* keymap: Readline Init File Syntax.
(line 204)
* LANG: Bash Variables. (line 485)
* LANG: Locale Translation. (line 69)
* LANG <1>: Bash Variables. (line 485)
* LC_ALL: Bash Variables. (line 489)
* LC_COLLATE: Bash Variables. (line 493)
* LC_CTYPE: Bash Variables. (line 500)
* LC_MESSAGES: Locale Translation. (line 15)
* LC_MESSAGES: Locale Translation. (line 69)
* LC_MESSAGES <1>: Bash Variables. (line 505)
* LC_NUMERIC: Bash Variables. (line 509)
* LC_TIME: Bash Variables. (line 513)
@@ -11741,8 +11830,8 @@ D.3 Parameter and Variable Index
* skip-completed-text: Readline Init File Syntax.
(line 299)
* SRANDOM: Bash Variables. (line 657)
* TEXTDOMAIN: Locale Translation. (line 15)
* TEXTDOMAINDIR: Locale Translation. (line 15)
* TEXTDOMAIN: Locale Translation. (line 69)
* TEXTDOMAINDIR: Locale Translation. (line 69)
* TIMEFORMAT: Bash Variables. (line 666)
* TMOUT: Bash Variables. (line 704)
* TMPDIR: Bash Variables. (line 716)
@@ -11838,6 +11927,8 @@ D.4 Function Index
* end-of-line (C-e): Commands For Moving. (line 9)
* exchange-point-and-mark (C-x C-x): Miscellaneous Commands.
(line 37)
* fetch-history (): Commands For History.
(line 103)
* forward-backward-delete-char (): Commands For Text. (line 21)
* forward-char (C-f): Commands For Moving. (line 12)
* forward-search-history (C-s): Commands For History.
@@ -12125,137 +12216,137 @@ D.5 Concept Index

Tag Table:
Node: Top887
Node: Introduction2797
Node: What is Bash?3013
Node: What is a shell?4127
Node: Definitions6665
Node: Basic Shell Features9616
Node: Shell Syntax10835
Node: Shell Operation11861
Node: Quoting13154
Node: Escape Character14458
Node: Single Quotes14943
Node: Double Quotes15291
Node: ANSI-C Quoting16569
Node: Locale Translation17826
Node: Comments18981
Node: Shell Commands19599
Node: Reserved Words20537
Node: Simple Commands21293
Node: Pipelines21947
Node: Lists24904
Node: Compound Commands26699
Node: Looping Constructs27711
Node: Conditional Constructs30206
Node: Command Grouping44368
Node: Coprocesses45843
Node: GNU Parallel48506
Node: Shell Functions52807
Node: Shell Parameters60027
Node: Positional Parameters64460
Node: Special Parameters65362
Node: Shell Expansions68586
Node: Brace Expansion70713
Node: Tilde Expansion73438
Node: Shell Parameter Expansion76059
Node: Command Substitution91188
Node: Arithmetic Expansion92543
Node: Process Substitution93475
Node: Word Splitting94595
Node: Filename Expansion96539
Node: Pattern Matching99088
Node: Quote Removal103078
Node: Redirections103373
Node: Executing Commands112947
Node: Simple Command Expansion113617
Node: Command Search and Execution115571
Node: Command Execution Environment117949
Node: Environment120935
Node: Exit Status122598
Node: Signals124270
Node: Shell Scripts126237
Node: Shell Builtin Commands129249
Node: Bourne Shell Builtins131287
Node: Bash Builtins152492
Node: Modifying Shell Behavior182642
Node: The Set Builtin182987
Node: The Shopt Builtin193400
Node: Special Builtins208312
Node: Shell Variables209291
Node: Bourne Shell Variables209728
Node: Bash Variables211832
Node: Bash Features244490
Node: Invoking Bash245503
Node: Bash Startup Files251516
Node: Interactive Shells256619
Node: What is an Interactive Shell?257029
Node: Is this Shell Interactive?257678
Node: Interactive Shell Behavior258493
Node: Bash Conditional Expressions262006
Node: Shell Arithmetic266583
Node: Aliases269527
Node: Arrays272140
Node: The Directory Stack278149
Node: Directory Stack Builtins278933
Node: Controlling the Prompt283119
Node: The Restricted Shell286084
Node: Bash POSIX Mode288678
Node: Shell Compatibility Mode299951
Node: Job Control306607
Node: Job Control Basics307067
Node: Job Control Builtins312069
Node: Job Control Variables317469
Node: Command Line Editing318625
Node: Introduction and Notation320296
Node: Readline Interaction321919
Node: Readline Bare Essentials323110
Node: Readline Movement Commands324893
Node: Readline Killing Commands325853
Node: Readline Arguments327771
Node: Searching328815
Node: Readline Init File331001
Node: Readline Init File Syntax332260
Node: Conditional Init Constructs352798
Node: Sample Init File356994
Node: Bindable Readline Commands360118
Node: Commands For Moving361322
Node: Commands For History363373
Node: Commands For Text368166
Node: Commands For Killing371815
Node: Numeric Arguments374848
Node: Commands For Completion375987
Node: Keyboard Macros380178
Node: Miscellaneous Commands380865
Node: Readline vi Mode386804
Node: Programmable Completion387711
Node: Programmable Completion Builtins395491
Node: A Programmable Completion Example406186
Node: Using History Interactively411433
Node: Bash History Facilities412117
Node: Bash History Builtins415122
Node: History Interaction420130
Node: Event Designators423750
Node: Word Designators425104
Node: Modifiers426864
Node: Installing Bash428675
Node: Basic Installation429812
Node: Compilers and Options433070
Node: Compiling For Multiple Architectures433811
Node: Installation Names435504
Node: Specifying the System Type436322
Node: Sharing Defaults437038
Node: Operation Controls437711
Node: Optional Features438669
Node: Reporting Bugs449469
Node: Major Differences From The Bourne Shell450663
Node: GNU Free Documentation License467513
Node: Indexes492690
Node: Builtin Index493144
Node: Reserved Word Index499971
Node: Variable Index502419
Node: Function Index518316
Node: Concept Index531964
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: Comments22909
Node: Shell Commands23527
Node: Reserved Words24465
Node: Simple Commands25221
Node: Pipelines25875
Node: Lists28832
Node: Compound Commands30627
Node: Looping Constructs31639
Node: Conditional Constructs34134
Node: Command Grouping48296
Node: Coprocesses49771
Node: GNU Parallel52434
Node: Shell Functions56735
Node: Shell Parameters63955
Node: Positional Parameters68388
Node: Special Parameters69290
Node: Shell Expansions72514
Node: Brace Expansion74641
Node: Tilde Expansion77366
Node: Shell Parameter Expansion79987
Node: Command Substitution95116
Node: Arithmetic Expansion96471
Node: Process Substitution97403
Node: Word Splitting98523
Node: Filename Expansion100467
Node: Pattern Matching103016
Node: Quote Removal107006
Node: Redirections107301
Node: Executing Commands116875
Node: Simple Command Expansion117545
Node: Command Search and Execution119499
Node: Command Execution Environment121877
Node: Environment124863
Node: Exit Status126526
Node: Signals128198
Node: Shell Scripts130165
Node: Shell Builtin Commands133177
Node: Bourne Shell Builtins135215
Node: Bash Builtins156420
Node: Modifying Shell Behavior186570
Node: The Set Builtin186915
Node: The Shopt Builtin197328
Node: Special Builtins212240
Node: Shell Variables213219
Node: Bourne Shell Variables213656
Node: Bash Variables215760
Node: Bash Features248418
Node: Invoking Bash249431
Node: Bash Startup Files255444
Node: Interactive Shells260547
Node: What is an Interactive Shell?260957
Node: Is this Shell Interactive?261606
Node: Interactive Shell Behavior262421
Node: Bash Conditional Expressions265934
Node: Shell Arithmetic270511
Node: Aliases273455
Node: Arrays276068
Node: The Directory Stack282077
Node: Directory Stack Builtins282861
Node: Controlling the Prompt287047
Node: The Restricted Shell290012
Node: Bash POSIX Mode292606
Node: Shell Compatibility Mode303879
Node: Job Control310535
Node: Job Control Basics310995
Node: Job Control Builtins315997
Node: Job Control Variables321397
Node: Command Line Editing322553
Node: Introduction and Notation324224
Node: Readline Interaction325847
Node: Readline Bare Essentials327038
Node: Readline Movement Commands328821
Node: Readline Killing Commands329781
Node: Readline Arguments331699
Node: Searching332743
Node: Readline Init File334929
Node: Readline Init File Syntax336188
Node: Conditional Init Constructs356726
Node: Sample Init File360922
Node: Bindable Readline Commands364046
Node: Commands For Moving365250
Node: Commands For History367301
Node: Commands For Text372295
Node: Commands For Killing375944
Node: Numeric Arguments378977
Node: Commands For Completion380116
Node: Keyboard Macros384307
Node: Miscellaneous Commands384994
Node: Readline vi Mode390933
Node: Programmable Completion391840
Node: Programmable Completion Builtins399620
Node: A Programmable Completion Example410315
Node: Using History Interactively415562
Node: Bash History Facilities416246
Node: Bash History Builtins419251
Node: History Interaction424259
Node: Event Designators427879
Node: Word Designators429233
Node: Modifiers430993
Node: Installing Bash432804
Node: Basic Installation433941
Node: Compilers and Options437199
Node: Compiling For Multiple Architectures437940
Node: Installation Names439633
Node: Specifying the System Type440451
Node: Sharing Defaults441167
Node: Operation Controls441840
Node: Optional Features442798
Node: Reporting Bugs453598
Node: Major Differences From The Bourne Shell454792
Node: GNU Free Documentation License471642
Node: Indexes496819
Node: Builtin Index497273
Node: Reserved Word Index504100
Node: Variable Index506548
Node: Function Index522518
Node: Concept Index536302

End Tag Table
+128 -19
View File
@@ -533,30 +533,136 @@ been present.
@cindex internationalization
@cindex native languages
@cindex translation, native languages
@menu
* Creating Internationalized Scripts:: How to use translations and different
languages in your scripts.
@end menu
A double-quoted string preceded by a dollar sign (@samp{$})
Prefixing a double-quoted string with a dollar sign (@samp{$}), such
as @verb{|$"hello, world"|},
will cause the string to be translated according to the current locale.
The @code{gettext} infrastructure performs the message catalog lookup and
translation, using the @code{LC_MESSAGES} and @code{TEXTDOMAIN} shell
variables, as explained below. See the gettext documentation for additional
details.
The @code{gettext} infrastructure performs the lookup and
translation, using the @code{LC_MESSAGES}, @code{TEXTDOMAINDIR},
and @code{TEXTDOMAIN} shell variables, as explained below.
See the gettext documentation for additional details not covered here.
If the current locale is @code{C} or @code{POSIX},
or if there are no translations available,
the dollar sign is ignored.
If the string is translated and replaced, the replacement is
double-quoted.
the dollar sign is ignored, and the shell doesn't attempt to translate the
string.
If the string is translated and replaced, the replacement
remains double-quoted.
The rest of this section is a brief overview of how you use gettext to
create translations for strings in a shell script named @var{scriptname}.
There are more details in the gettext documentation.
@node Creating Internationalized Scripts
@cindex internationalized scripts
@cindex string translations
Once you've marked the strings in your script
that you want to translate using $"...",
you create a gettext "template" file using the command
@example
bash --dump-po-strings @var{scriptname} > @var{domain}.pot
@end example
@noindent
The @var{domain} is your @dfn{message domain}.
It's just an arbitrary string that's used to identify the files gettext
needs, like a package or script name.
It needs to be unique among all
the message domains on systems where you install the translations, so
gettext knows which translations correspond to your script.
You'll use the template file to create translations for each target language.
The template file conventionally has the suffix @samp{.pot}.
You copy this template file to a separate file for each target language
you want to support (called "PO" files, which use the suffix @samp{.po}).
PO files use various naming conventions, but
when you are working to translate a template file into a particular
language, you first copy the template file to a file whose name is the
language you want to target, with the @samp{.po} suffix.
For instance, the Spanish translations of your strings would be
in a file named @samp{es.po}, and to get started using a message
domain named "example," you would run
@example
cp example.pot es.po
@end example
@noindent
Ultimately, PO files are often named @var{domain}.po and installed in
directories that contain multiple translation files for a particular language.
Whichever naming convention you choose, you will need to translate the
strings in the PO files into the appropriate languages.
This has to be done manually.
When you have the translations and PO files complete, you'll use the
gettext tools to produce what are called "MO" files, which are compiled
versions of the PO files the gettext tools use to look up translations
efficiently.
MO files are also called "message catalog" files.
You use the @command{msgfmt} program to do this.
For instance, if you had a file with Spanish translations, you could run
@example
msgfmt -o es.mo es.po
@end example
@noindent
to produce the corresponding MO file.
Once you have the MO files, you decide where to install them and use the
@code{TEXTDOMAINDIR} shell variable to tell the gettext tools where they are.
Make sure to use the same message domain to name the MO files
as you did for the PO files when you install them.
@vindex LANG
@vindex LC_MESSAGES
@vindex TEXTDOMAIN
@vindex TEXTDOMAINDIR
Some systems use the message catalog selected by the @env{LC_MESSAGES}
shell variable. Others create the name of the message catalog from the
value of the @env{TEXTDOMAIN} shell variable, possibly adding a
suffix of @samp{.mo}. If you use the @env{TEXTDOMAIN} variable, you
may need to set the @env{TEXTDOMAINDIR} variable to the location of
the message catalog files. Still others use both variables in this
fashion:
@env{TEXTDOMAINDIR}/@env{LC_MESSAGES}/LC_MESSAGES/@env{TEXTDOMAIN}.mo.
Your users will use the @env{LANG} or @env{LC_MESSAGES} shell variables to
select the desired language.
You set the @env{TEXTDOMAIN} variable to the script's message domain.
As above, you use the message domain to name your translation files.
You, or possibly your users, set the @env{TEXTDOMAINDIR} variable to the
name of a directory where the message catalog files are stored.
If you install the message files into the system's standard message catalog
directory, you don't need to worry about this variable.
The directory where the message catalog files are stored varies between
systems.
Some use the message catalog selected by the @env{LC_MESSAGES}
shell variable.
Others create the name of the message catalog from the value of the
@env{TEXTDOMAIN} shell variable, possibly adding the @samp{.mo} suffix.
If you use the @env{TEXTDOMAIN} variable, you may need to set the
@env{TEXTDOMAINDIR} variable to the location of the message catalog files,
as above.
It's common to use both variables in this fashion:
@env{$TEXTDOMAINDIR}/@env{$LC_MESSAGES}/LC_MESSAGES/@env{$TEXTDOMAIN}.mo.
If you used that last convention, and you wanted to store the message
catalog files with Spanish (es) and Esperanto (eo) translations into a
local directory you use for custom translation files, you could run
@example
TEXTDOMAIN=example
TEXTDOMAINDIR=/usr/local/share/locale
cp es.mo $@{TEXTDOMAINDIR@}/es/LC_MESSAGES/$@{TEXTDOMAIN@}.mo
cp eo.mo $@{TEXTDOMAINDIR@}/eo/LC_MESSAGES/$@{TEXTDOMAIN@}.mo
@end example
When all of this is done, and the message catalog files containing the
compiled translations are installed in the correct location,
your users will be able to see translated strings
in any of the supported languages by setting the @env{LANG} or
@env{LC_MESSAGES} environment variables before running your script.
@node Comments
@subsection Comments
@@ -5596,7 +5702,7 @@ performing filename expansion.
@item nocasematch
If set, Bash matches patterns in a case-insensitive fashion when
performing matching while executing @code{case} or @code{[[}
conditional commands,
conditional commands (@pxref{Conditional Constructs},
when performing pattern substitution word expansions,
or when filtering possible completions as part of programmable completion.
@@ -7037,7 +7143,10 @@ printing @env{$PS1} (@pxref{Bash Variables}).
@cindex expressions, conditional
Conditional expressions are used by the @code{[[} compound command
and the @code{test} and @code{[} builtin commands. The @code{test}
(@pxref{Conditional Constructs})
and the @code{test} and @code{[} builtin commands
(@pxref{Bourne Shell Builtins}).
The @code{test}
and @code{[} commands determine their behavior based on the number
of arguments; see the descriptions of those commands for any other
command-specific actions.
@@ -9539,7 +9648,7 @@ which specifies the behavior based on the number of arguments.
@item
Bash includes the @code{caller} builtin, which displays the context of
any active subroutine call (a shell function or a script executed with
the @code{.} or @code{source} builtins). This supports the bash
the @code{.} or @code{source} builtins). This supports the Bash
debugger.
@item
+2 -2
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2021 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Thu Mar 4 15:49:19 EST 2021
@set LASTCHANGE Wed Mar 31 11:53:05 EDT 2021
@set EDITION 5.1
@set VERSION 5.1
@set UPDATED 4 March2021
@set UPDATED 31 March 2021
@set UPDATED-MONTH March 2021
+15 -9
View File
@@ -853,6 +853,21 @@ Move to the first line in the history.
Move to the end of the input history, i.e., the line currently being
entered.
.TP
.B
operate\-and\-get\-next (C\-o)
Accept the current line for return to the calling application as if a
newline had been entered,
and fetch the next line relative to the current line from the history
for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
.TP
.B
fetch\-history
With a numeric argument, fetch that entry from the history list
and make it the current line.
Without an argument, move back to the first entry in the history list.
.TP
.B reverse\-search\-history (C\-r)
Search backward starting at the current line and moving `up' through
the history as necessary. This is an incremental search.
@@ -919,15 +934,6 @@ the direction to move through the history. A negative argument switches
the direction through the history (back or forward).
The history expansion facilities are used to extract the last argument,
as if the "!$" history expansion had been specified.
.TP
.B
operate\-and\-get\-next (C\-o)
Accept the current line for return to the calling application as if a
newline had been entered,
and fetch the next line relative to the current line from the history
for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
.PD
.SS Commands for Changing Text
.PD 0
+5
View File
@@ -1332,6 +1332,11 @@ for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
@item fetch-history ()
With a numeric argument, fetch that entry from the history list
and make it the current line.
Without an argument, move back to the first entry in the history list.
@end ftable
@node Commands For Text
+2 -2
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2021 Free Software Foundation, Inc.
@set EDITION 8.1
@set VERSION 8.1
@set UPDATED 16 March 2021
@set UPDATED 31 March 2021
@set UPDATED-MONTH March 2021
@set LASTCHANGE Tue Mar 16 14:41:07 EDT 2021
@set LASTCHANGE Wed Mar 31 11:45:32 EDT 2021
+1
View File
@@ -93,6 +93,7 @@ static const FUNMAP default_funmap[] = {
{ "end-of-history", rl_end_of_history },
{ "end-of-line", rl_end_of_line },
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
{ "fetch-history", rl_fetch_history },
{ "forward-backward-delete-char", rl_rubout_or_delete },
{ "forward-byte", rl_forward_byte },
{ "forward-char", rl_forward_char },
+36
View File
@@ -634,6 +634,42 @@ rl_get_previous_history (int count, int key)
return 0;
}
/* With an argument, move back that many history lines, else move to the
beginning of history. */
int
rl_fetch_history (int count, int c)
{
int wanted, nhist;
/* Giving an argument of n means we want the nth command in the history
file. The command number is interpreted the same way that the bash
`history' command does it -- that is, giving an argument count of 450
to this command would get the command listed as number 450 in the
output of `history'. */
if (rl_explicit_arg)
{
nhist = history_base + where_history ();
/* Negative arguments count back from the end of the history list. */
wanted = (count >= 0) ? nhist - count : -count;
if (wanted <= 0 || wanted >= nhist)
{
/* In vi mode, we don't change the line with an out-of-range
argument, as for the `G' command. */
if (rl_editing_mode == vi_mode)
rl_ding ();
else
rl_beginning_of_history (0, 0);
}
else
rl_get_previous_history (wanted, c);
}
else
rl_beginning_of_history (count, 0);
return (0);
}
/* The equivalent of the Korn shell C-o operate-and-get-next-history-line
editing command. */
+1
View File
@@ -134,6 +134,7 @@ extern int rl_end_of_history (int, int);
extern int rl_get_next_history (int, int);
extern int rl_get_previous_history (int, int);
extern int rl_operate_and_get_next (int, int);
extern int rl_fetch_history (int, int);
/* Bindable commands for managing the mark and region. */
extern int rl_set_mark (int, int);
+1 -18
View File
@@ -337,24 +337,7 @@ rl_vi_yank_arg (int count, int key)
int
rl_vi_fetch_history (int count, int c)
{
int wanted;
/* Giving an argument of n means we want the nth command in the history
file. The command number is interpreted the same way that the bash
`history' command does it -- that is, giving an argument count of 450
to this command would get the command listed as number 450 in the
output of `history'. */
if (rl_explicit_arg)
{
wanted = history_base + where_history () - count;
if (wanted <= 0)
rl_beginning_of_history (0, 0);
else
rl_get_previous_history (wanted, c);
}
else
rl_beginning_of_history (count, 0);
return (0);
return (rl_fetch_history (count, c));
}
/* Search again for the last thing searched for. */
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
BUILD_DIR=/usr/local/build/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+4 -3
View File
@@ -227,15 +227,16 @@ argv[2] = <Y>
argv[1] = <XY^AY>
argv[1] = <x^Ay^?z>
argv[1] = <x^Ay^?z>
declare -- var="xyz"
declare -- var=$'x\001y\177z'
argv[1] = <declare>
argv[2] = <-->
argv[3] = <var="x^Ay^?z">
argv[3] = <var=$'x\001y\177z'>
declare -- var=$'x\001y\177z'$
declare -- var="x\001y\177z"$
argv[1] = <$'x\001y\177z'>
argv[1] = <x^Ay^?z>
var=$'x\001y\177z'
./exp8.sub: line 29: xyz: syntax error: invalid arithmetic operator (error token is "z")
./exp8.sub: line 30: xyz: syntax error: invalid arithmetic operator (error token is "z")
declare -a array=()
declare -a array=([0]=$'x\001y\177z')
argv[1] = <x^Ay^?z>
+1
View File
@@ -20,6 +20,7 @@ declare -p var
recho $(declare -p var)
declare -p var | sed -n l
echo "declare -- var=\"$var\"" | sed -n l
recho ${var@Q}
recho ${var@P}