bindable readline command to perform spelling correction on a word

This commit is contained in:
Chet Ramey
2021-03-18 11:48:48 -04:00
parent 83c4ad27c7
commit 6be3a741cb
16 changed files with 1607 additions and 1370 deletions
+3
View File
@@ -26,6 +26,9 @@ bash
bashbug
bashversion
TAGS
tags
Makefile
builtins/Makefile
builtins/builtext.h
+45
View File
@@ -9850,3 +9850,48 @@ bashline.c
$"..." in the line by calling expand_string_dollar_quote, since
that happens after history expansion and before alias expansion in
normal processing
3/15
----
subst.c
- expand_string_dollar_quote: fix out-of-order initialization
Makefile.in
- {TAGS,tags}: add ETAGS/ETAGSFLAGS/CTAGS/CTAGS flags; make sure to
cd to the source directory before running them to get source files
that don't have absolute paths. Fix from Mike Jonkmans
<bashbug@jonkmans.nl>
parse.y
- xparse_dolparen: don't longjmp if FLAGS includes SX_NOLONGJMP. From
a report by Xu Lu <oliver_lew@outlook.com>
3/16
----
subst.c
- process_substitute: set startup_state and parse_and_execute_level
to see if we can avoid a fork()
bashline.c
- bash_spell_correct_word: bindable command (spell-correct-word) to
perform spelling correction on the current `shellword', using the
same code as the `cdspell' option and directory spelling correction
during completion. Feature suggested by in 10/2020 by
Karl Kleinpaste <karl@kleinpaste.org>
- bash_spell_correct_word: bound to "C-x s" by default in emacs mode
lib/readline/display.c
- rl_redisplay: fix redisplay problem that occurs when switching from
the rl-digit-argument prompt "(arg: N)" back to the regular prompt,
and the regular prompt contains invisible characters
doc/bash.1,lib/readline/doc/rluser.texi
- spell-correct-word: document new function and its default binding
3/17
----
doc/{bash.1,bashref.texi}
- cd: slight changes to specify that it sets PWD and OLDPWD
- {pushd,popd}: make it clear that these builtins use cd to change
the current working directory; change wording to simplify the
description and clarify the exit status
+8 -3
View File
@@ -1,4 +1,4 @@
# Makefile for bash-5.0, version 4.30
# Makefile for bash-5.0, version 4.31
#
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
@@ -87,6 +87,11 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALLMODE= -m 0755
INSTALLMODE2 = -m 0555
CTAGS = ctags
CTAGSFLAGS = -x
ETAGS = etags
ETAGSFLAGS =
TESTSCRIPT = @TESTSCRIPT@
DEBUGGER_START_FILE = @DEBUGGER_START_FILE@
@@ -809,10 +814,10 @@ force:
# unused
TAGS: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
etags $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
( cd $(topdir) && $(ETAGS) $(ETAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) )
tags: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
ctags -x $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) > $@
( cd $(topdir) && $(CTAGS) $(CTAGSFLAGS) $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) > $@ )
# Targets that actually do things not part of the build
+54
View File
@@ -142,6 +142,8 @@ static int bash_kill_shellword PARAMS((int, int));
static int bash_backward_kill_shellword PARAMS((int, int));
static int bash_transpose_shellwords PARAMS((int, int));
static int bash_spell_correct_shellword PARAMS((int, int));
/* Helper functions for Readline. */
static char *restore_tilde PARAMS((char *, char *));
static char *maybe_restore_tilde PARAMS((char *, char *));
@@ -470,6 +472,9 @@ initialize_readline ()
rl_add_defun ("shell-backward-kill-word", bash_backward_kill_shellword, -1);
rl_add_defun ("shell-transpose-words", bash_transpose_shellwords, -1);
rl_add_defun ("spell-correct-word", bash_spell_correct_shellword, -1);
rl_bind_key_if_unbound_in_map ('s', bash_spell_correct_shellword, emacs_ctlx_keymap);
#ifdef ALIAS
rl_add_defun ("alias-expand-line", alias_expand_line, -1);
# ifdef BANG_HISTORY
@@ -1324,6 +1329,55 @@ bash_transpose_shellwords (count, key)
return 0;
}
/* Directory name spelling correction on the current word (not shellword).
COUNT > 1 is not exactly correct yet. */
static int
bash_spell_correct_shellword (count, key)
int count, key;
{
int opoint, wbeg, wend;
char *text, *newdir;
opoint = rl_point;
while (count)
{
bash_backward_shellword (1, key);
wbeg = rl_point;
bash_forward_shellword (1, key);
wend = rl_point;
if (wbeg > wend)
break;
text = rl_copy_text (wbeg, wend);
newdir = dirspell (text);
if (newdir)
{
rl_begin_undo_group ();
rl_delete_text (wbeg, wend);
rl_point = wbeg;
if (*newdir)
rl_insert_text (newdir);
rl_mark = wbeg;
rl_end_undo_group ();
}
free (text);
free (newdir);
if (rl_point >= rl_end)
break;
count--;
if (count)
bash_forward_shellword (1, key); /* XXX */
}
return 0;
}
/* **************************************************************** */
/* */
/* How To Do Shell Completion */
+1159 -1146
View File
File diff suppressed because it is too large Load Diff
+50 -28
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Thu Mar 4 15:52:34 EST 2021
.\" Last Change: Tue Mar 16 14:35:58 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 4" "GNU Bash 5.1"
.TH BASH 1 "2021 March 16" "GNU Bash 5.1"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -5397,7 +5397,8 @@ the version of \fBbash\fP (e.g., 2.00)
the release of \fBbash\fP, version + patch level (e.g., 2.00.0)
.TP
.B \ew
the current working directory, with
the value of the \fBPWD\fP shell variable (\fB$PWD\fP),
with
.SM
.B $HOME
abbreviated with a tilde
@@ -5407,7 +5408,8 @@ abbreviated with a tilde
variable)
.TP
.B \eW
the basename of the current working directory, with
the basename of \fB$PWD\fP,
with
.SM
.B $HOME
abbreviated with a tilde
@@ -6757,6 +6759,11 @@ a shell comment.
If a numeric argument causes the comment character to be removed, the line
will be executed by the shell.
.TP
.B spell\-correct\-word (C\-x s)
Perform spelling correction on the current word, treating it as a directory
or filename, in the same way as the \fBcdspell\fP shell option.
Word boundaries are the same as those used by \fBshell\-forward\-word\fP.
.TP
.B glob\-complete\-word (M\-g)
The word before point is treated as a pattern for pathname expansion,
with an asterisk implicitly appended. This pattern is used to
@@ -7728,6 +7735,10 @@ is used, or if
\fB\-\fP is the first argument, and the directory change is
successful, the absolute pathname of the new working directory is
written to the standard output.
If the directory change is successful, \fBcd\fP sets the value of the
\fBPWD\fP environment variable to the new directory name, and sets the
\fBOLDPWD\fP environment variable to the value of the current working
directory before the change.
The return value is true if the directory was successfully changed;
false otherwise.
.TP
@@ -9084,10 +9095,12 @@ argument is supplied, \fIarray\fP is invalid or unassignable, or if
.RE
.TP
\fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
Removes entries from the directory stack. With no arguments,
removes the top directory from the stack, and performs a
.B cd
to the new top directory.
Removes entries from the directory stack.
The elements are numbered from 0 starting at the first directory
listed by \fBdirs\fP.
With no arguments, \fBpopd\fP
removes the top directory from the stack, and
changes to the new top directory.
Arguments, if supplied, have the following meanings:
.RS
.PD 0
@@ -9100,7 +9113,8 @@ from the stack, so that only the stack is manipulated.
Removes the \fIn\fPth entry counting from the left of the list
shown by
.BR dirs ,
starting with zero. For example:
starting with zero, from the stack.
For example:
.if n ``popd +0''
.if t \f(CWpopd +0\fP
removes the first directory,
@@ -9121,15 +9135,21 @@ removes the last directory,
the next to last.
.PD
.PP
If the top element of the directory stack is modified, and
the \fI-n\fP option was not supplied, \fBpopd\fP uses the \fBcd\fP
builtin to change to the directory at the top of the stack.
If the \fBcd\fP fails, \fBpopd\fP returns a non-zero value.
.PP
Otherwise,
.B popd
returns false if an invalid option is encountered, the directory stack
is empty, or a non-existent directory stack entry is specified.
.PP
If the
.B popd
command is successful, a
.B dirs
is performed as well, and the return status is 0.
.B popd
returns false if an invalid option is encountered, the directory stack
is empty, a non-existent directory stack entry is specified, or the
directory change fails.
.RE
.TP
\fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP]
@@ -9193,8 +9213,9 @@ The return value is zero on success, non-zero on failure.
.PD
Adds a directory to the top of the directory stack, or rotates
the stack, making the new top of the stack the current working
directory. With no arguments, \fBpushd\fP exchanges the top two directories
and returns 0, unless the directory stack is empty.
directory.
With no arguments, \fBpushd\fP exchanges the top two elements of
the directory stack.
Arguments, if supplied, have the following meanings:
.RS
.PD 0
@@ -9219,26 +9240,27 @@ starting with zero) is at the top.
.I dir
Adds
.I dir
to the directory stack at the top, making it the
new current working directory as if it had been supplied as the argument
to the \fBcd\fP builtin.
to the directory stack at the top
.PD
.PP
After the stack has been modified, if the \fB\-n\fP option was not
supplied, \fBpushd\fP uses the \fBcd\fP builtin to change to the
directory at the top of the stack.
If the \fBcd\fP fails, \fBpushd\fP returns a non-zero value.
.PP
Otherwise, if no arguments are supplied,
.B pushd
returns 0 unless the directory stack is empty.
When rotating the directory stack,
.B pushd
returns 0 unless the directory stack is empty or
a non-existent directory stack element is specified.
.PP
If the
.B pushd
command is successful, a
.B dirs
is performed as well.
If the first form is used,
.B pushd
returns 0 unless the cd to
.I dir
fails. With the second form,
.B pushd
returns 0 unless the directory stack is empty,
a non-existent directory stack element is specified,
or the directory change to the specified new current directory
fails.
.RE
.TP
\fBpwd\fP [\fB\-LP\fP]
+178 -154
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, 28 February 2021).
Bash shell (version 5.1, 4 March2021).
This is Edition 5.1, last updated 28 February 2021, of 'The GNU Bash
This is Edition 5.1, last updated 4 March2021, 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, 28 February 2021). The Bash home page is
Bash shell (version 5.1, 4 March2021). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.1, last updated 28 February 2021, of 'The GNU Bash
This is Edition 5.1, last updated 4 March2021, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.1.
Bash contains features that appear in other popular shells, and some
@@ -971,7 +971,7 @@ File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Pre
any character in the string (its usual regular expression meaning),
but in the pattern '"xxx.txt"' it can only match a literal '.'.
Shell programmers should take special care with backslashes, since
backslashes are used both by the shell and regular expressions to
backslashes are used by both the shell and regular expressions to
remove the special meaning from the following character. The
following two sets of commands are _not_ equivalent:
pattern='\.'
@@ -1059,6 +1059,7 @@ had been terminated with the '&' control operator, with a two-way pipe
established between the executing shell and the coprocess.
The syntax for a coprocess is:
coproc [NAME] COMMAND [REDIRECTIONS]
This creates a coprocess named NAME. COMMAND may be either a simple
@@ -1066,12 +1067,26 @@ command (*note Simple Commands::) or a compound command (*note Compound
Commands::). NAME is a shell variable name. If NAME is not supplied,
the default name is 'COPROC'.
If COMMAND is a compound command, NAME is optional. The word
following 'coproc' determines whether that word is interpreted as a
variable name: it is interpreted as NAME if it is not a reserved word
that introduces a compound command. If COMMAND is a simple command,
NAME is not allowed; this is to avoid confusion between NAME and the
first word of the simple command.
The recommended form to use for a coprocess is
coproc NAME { COMMAND; }
This form is recommended because simple commands result in the coprocess
always being named 'COPROC', and it is simpler to use and more complete
than the other compound commands.
There are other forms of coprocesses:
coproc NAME COMPOUND-COMMAND
coproc COMPOUND-COMMAND
coproc SIMPLE-COMMAND
If COMMAND is a compound command, NAME is optional. The word following
'coproc' determines whether that word is interpreted as a variable name:
it is interpreted as NAME if it is not a reserved word that introduces a
compound command. If COMMAND is a simple command, NAME is not allowed;
this is to avoid confusion between NAME and the first word of the simple
command.
When the coprocess is executed, the shell creates an array variable
(*note Arrays::) named NAME in the context of the executing shell. The
@@ -3386,7 +3401,8 @@ standard.
unset. Readonly variables and functions may not be unset. Some
shell variables lose their special behavior if they are unset; such
behavior is noted in the description of the individual variables.
The return status is zero unless a NAME is readonly.
The return status is zero unless a NAME is readonly or may not be
unset.

File: bashref.info, Node: Bash Builtins, Next: Modifying Shell Behavior, Prev: Bourne Shell Builtins, Up: Shell Builtin Commands
@@ -8863,6 +8879,12 @@ File: bashref.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up:
is formatted in such a way that it can be made part of an INPUTRC
file. This command is unbound by default.
'spell-correct-word (C-x s)'
Perform spelling correction on the current word, treating it as a
directory or filename, in the same way as the 'cdspell' shell
option. Word boundaries are the same as those used by
'shell-forward-word'.
'glob-complete-word (M-g)'
The word before point is treated as a pattern for pathname
expansion, with an asterisk implicitly appended. This pattern is
@@ -11652,7 +11674,7 @@ D.4 Function Index
* accept-line (Newline or Return): Commands For History.
(line 6)
* alias-expand-line (): Miscellaneous Commands.
(line 125)
(line 131)
* backward-char (C-b): Commands For Moving. (line 15)
* backward-delete-char (Rubout): Commands For Text. (line 17)
* backward-kill-line (C-x Rubout): Commands For Killing.
@@ -11701,7 +11723,7 @@ D.4 Function Index
(line 57)
* digit-argument (M-0, M-1, ... M--): Numeric Arguments. (line 6)
* display-shell-version (C-x C-v): Miscellaneous Commands.
(line 110)
(line 116)
* do-lowercase-version (M-A, M-B, M-X, ...): Miscellaneous Commands.
(line 14)
* downcase-word (M-l): Commands For Text. (line 62)
@@ -11714,7 +11736,7 @@ D.4 Function Index
* dynamic-complete-history (M-<TAB>): Commands For Completion.
(line 90)
* edit-and-execute-command (C-x C-e): Miscellaneous Commands.
(line 134)
(line 140)
* end-kbd-macro (C-x )): Keyboard Macros. (line 9)
* end-of-file (usually C-d): Commands For Text. (line 6)
* end-of-history (M->): Commands For History.
@@ -11728,15 +11750,15 @@ D.4 Function Index
(line 33)
* forward-word (M-f): Commands For Moving. (line 18)
* glob-complete-word (M-g): Miscellaneous Commands.
(line 92)
* glob-expand-word (C-x *): Miscellaneous Commands.
(line 98)
* glob-list-expansions (C-x g): Miscellaneous Commands.
* glob-expand-word (C-x *): Miscellaneous Commands.
(line 104)
* glob-list-expansions (C-x g): Miscellaneous Commands.
(line 110)
* history-and-alias-expand-line (): Miscellaneous Commands.
(line 128)
(line 134)
* history-expand-line (M-^): Miscellaneous Commands.
(line 118)
(line 124)
* history-search-backward (): Commands For History.
(line 57)
* history-search-forward (): Commands For History.
@@ -11750,7 +11772,7 @@ D.4 Function Index
* insert-completions (M-*): Commands For Completion.
(line 22)
* insert-last-argument (M-. or M-_): Miscellaneous Commands.
(line 131)
(line 137)
* kill-line (C-k): Commands For Killing.
(line 6)
* kill-region (): Commands For Killing.
@@ -11760,7 +11782,7 @@ D.4 Function Index
* kill-word (M-d): Commands For Killing.
(line 23)
* magic-space (): Miscellaneous Commands.
(line 121)
(line 127)
* menu-complete (): Commands For Completion.
(line 26)
* menu-complete-backward (): Commands For Completion.
@@ -11808,7 +11830,7 @@ D.4 Function Index
(line 37)
* shell-backward-word (M-C-b): Commands For Moving. (line 30)
* shell-expand-line (M-C-e): Miscellaneous Commands.
(line 113)
(line 119)
* shell-forward-word (M-C-f): Commands For Moving. (line 26)
* shell-kill-word (M-C-d): Commands For Killing.
(line 32)
@@ -11816,6 +11838,8 @@ D.4 Function Index
(line 41)
* skip-csi-sequence (): Miscellaneous Commands.
(line 52)
* spell-correct-word (C-x s): Miscellaneous Commands.
(line 92)
* start-kbd-macro (C-x (): Keyboard Macros. (line 6)
* tilde-expand (M-&): Miscellaneous Commands.
(line 30)
@@ -12007,137 +12031,137 @@ D.5 Concept Index

Tag Table:
Node: Top897
Node: Introduction2817
Node: What is Bash?3033
Node: What is a shell?4147
Node: Definitions6685
Node: Basic Shell Features9636
Node: Shell Syntax10855
Node: Shell Operation11881
Node: Quoting13174
Node: Escape Character14478
Node: Single Quotes14963
Node: Double Quotes15311
Node: ANSI-C Quoting16589
Node: Locale Translation17846
Node: Comments19001
Node: Shell Commands19619
Node: Reserved Words20557
Node: Simple Commands21313
Node: Pipelines21967
Node: Lists24924
Node: Compound Commands26719
Node: Looping Constructs27731
Node: Conditional Constructs30226
Node: Command Grouping41797
Node: Coprocesses43272
Node: GNU Parallel45542
Node: Shell Functions49843
Node: Shell Parameters57063
Node: Positional Parameters61496
Node: Special Parameters62398
Node: Shell Expansions65622
Node: Brace Expansion67749
Node: Tilde Expansion70474
Node: Shell Parameter Expansion73095
Node: Command Substitution88224
Node: Arithmetic Expansion89579
Node: Process Substitution90511
Node: Word Splitting91631
Node: Filename Expansion93575
Node: Pattern Matching96124
Node: Quote Removal100114
Node: Redirections100409
Node: Executing Commands109983
Node: Simple Command Expansion110653
Node: Command Search and Execution112607
Node: Command Execution Environment114985
Node: Environment117971
Node: Exit Status119634
Node: Signals121306
Node: Shell Scripts123273
Node: Shell Builtin Commands126285
Node: Bourne Shell Builtins128323
Node: Bash Builtins149254
Node: Modifying Shell Behavior179404
Node: The Set Builtin179749
Node: The Shopt Builtin190162
Node: Special Builtins205074
Node: Shell Variables206053
Node: Bourne Shell Variables206490
Node: Bash Variables208594
Node: Bash Features241252
Node: Invoking Bash242265
Node: Bash Startup Files248278
Node: Interactive Shells253381
Node: What is an Interactive Shell?253791
Node: Is this Shell Interactive?254440
Node: Interactive Shell Behavior255255
Node: Bash Conditional Expressions258768
Node: Shell Arithmetic263345
Node: Aliases266289
Node: Arrays268902
Node: The Directory Stack274911
Node: Directory Stack Builtins275695
Node: Controlling the Prompt278663
Node: The Restricted Shell281611
Node: Bash POSIX Mode284205
Node: Shell Compatibility Mode295478
Node: Job Control302134
Node: Job Control Basics302594
Node: Job Control Builtins307596
Node: Job Control Variables312996
Node: Command Line Editing314152
Node: Introduction and Notation315823
Node: Readline Interaction317446
Node: Readline Bare Essentials318637
Node: Readline Movement Commands320420
Node: Readline Killing Commands321380
Node: Readline Arguments323298
Node: Searching324342
Node: Readline Init File326528
Node: Readline Init File Syntax327787
Node: Conditional Init Constructs348325
Node: Sample Init File352521
Node: Bindable Readline Commands355645
Node: Commands For Moving356849
Node: Commands For History358900
Node: Commands For Text363693
Node: Commands For Killing367342
Node: Numeric Arguments370375
Node: Commands For Completion371514
Node: Keyboard Macros375705
Node: Miscellaneous Commands376392
Node: Readline vi Mode382076
Node: Programmable Completion382983
Node: Programmable Completion Builtins390763
Node: A Programmable Completion Example401458
Node: Using History Interactively406705
Node: Bash History Facilities407389
Node: Bash History Builtins410394
Node: History Interaction415402
Node: Event Designators419022
Node: Word Designators420376
Node: Modifiers422136
Node: Installing Bash423947
Node: Basic Installation425084
Node: Compilers and Options428342
Node: Compiling For Multiple Architectures429083
Node: Installation Names430776
Node: Specifying the System Type431594
Node: Sharing Defaults432310
Node: Operation Controls432983
Node: Optional Features433941
Node: Reporting Bugs444741
Node: Major Differences From The Bourne Shell445935
Node: GNU Free Documentation License462785
Node: Indexes487962
Node: Builtin Index488416
Node: Reserved Word Index495243
Node: Variable Index497691
Node: Function Index513588
Node: Concept Index527098
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 Grouping41777
Node: Coprocesses43252
Node: GNU Parallel45915
Node: Shell Functions50216
Node: Shell Parameters57436
Node: Positional Parameters61869
Node: Special Parameters62771
Node: Shell Expansions65995
Node: Brace Expansion68122
Node: Tilde Expansion70847
Node: Shell Parameter Expansion73468
Node: Command Substitution88597
Node: Arithmetic Expansion89952
Node: Process Substitution90884
Node: Word Splitting92004
Node: Filename Expansion93948
Node: Pattern Matching96497
Node: Quote Removal100487
Node: Redirections100782
Node: Executing Commands110356
Node: Simple Command Expansion111026
Node: Command Search and Execution112980
Node: Command Execution Environment115358
Node: Environment118344
Node: Exit Status120007
Node: Signals121679
Node: Shell Scripts123646
Node: Shell Builtin Commands126658
Node: Bourne Shell Builtins128696
Node: Bash Builtins149652
Node: Modifying Shell Behavior179802
Node: The Set Builtin180147
Node: The Shopt Builtin190560
Node: Special Builtins205472
Node: Shell Variables206451
Node: Bourne Shell Variables206888
Node: Bash Variables208992
Node: Bash Features241650
Node: Invoking Bash242663
Node: Bash Startup Files248676
Node: Interactive Shells253779
Node: What is an Interactive Shell?254189
Node: Is this Shell Interactive?254838
Node: Interactive Shell Behavior255653
Node: Bash Conditional Expressions259166
Node: Shell Arithmetic263743
Node: Aliases266687
Node: Arrays269300
Node: The Directory Stack275309
Node: Directory Stack Builtins276093
Node: Controlling the Prompt279061
Node: The Restricted Shell282009
Node: Bash POSIX Mode284603
Node: Shell Compatibility Mode295876
Node: Job Control302532
Node: Job Control Basics302992
Node: Job Control Builtins307994
Node: Job Control Variables313394
Node: Command Line Editing314550
Node: Introduction and Notation316221
Node: Readline Interaction317844
Node: Readline Bare Essentials319035
Node: Readline Movement Commands320818
Node: Readline Killing Commands321778
Node: Readline Arguments323696
Node: Searching324740
Node: Readline Init File326926
Node: Readline Init File Syntax328185
Node: Conditional Init Constructs348723
Node: Sample Init File352919
Node: Bindable Readline Commands356043
Node: Commands For Moving357247
Node: Commands For History359298
Node: Commands For Text364091
Node: Commands For Killing367740
Node: Numeric Arguments370773
Node: Commands For Completion371912
Node: Keyboard Macros376103
Node: Miscellaneous Commands376790
Node: Readline vi Mode382729
Node: Programmable Completion383636
Node: Programmable Completion Builtins391416
Node: A Programmable Completion Example402111
Node: Using History Interactively407358
Node: Bash History Facilities408042
Node: Bash History Builtins411047
Node: History Interaction416055
Node: Event Designators419675
Node: Word Designators421029
Node: Modifiers422789
Node: Installing Bash424600
Node: Basic Installation425737
Node: Compilers and Options428995
Node: Compiling For Multiple Architectures429736
Node: Installation Names431429
Node: Specifying the System Type432247
Node: Sharing Defaults432963
Node: Operation Controls433636
Node: Optional Features434594
Node: Reporting Bugs445394
Node: Major Differences From The Bourne Shell446588
Node: GNU Free Documentation License463438
Node: Indexes488615
Node: Builtin Index489069
Node: Reserved Word Index495896
Node: Variable Index498344
Node: Function Index514241
Node: Concept Index527889

End Tag Table
+53 -15
View File
@@ -1129,7 +1129,7 @@ This means that in the pattern @samp{xxx.txt}, the @samp{.} matches any
character in the string (its usual regular expression meaning), but in the
pattern @samp{"xxx.txt"} it can only match a literal @samp{.}.
Shell programmers should take special care with backslashes, since backslashes
are used both by the shell and regular expressions to remove the special
are used by both the shell and regular expressions to remove the special
meaning from the following character.
The following two sets of commands are @emph{not} equivalent:
@example
@@ -3573,6 +3573,11 @@ If a non-empty directory name from @env{CDPATH} is used, or if
successful, the absolute pathname of the new working directory is
written to the standard output.
If the directory change is successful, @code{cd} sets the value of the
@env{PWD} environment variable to the new directory name, and sets the
@env{OLDPWD} environment variable to the value of the current working
directory before the change.
The return status is zero if the directory is successfully changed,
non-zero otherwise.
@@ -7501,11 +7506,16 @@ with zero.
popd [-n] [+@var{N} | -@var{N}]
@end example
When no arguments are given, @code{popd}
removes the top directory from the stack and
performs a @code{cd} to the new top directory.
Removes elements from the directory stack.
The elements are numbered from 0 starting at the first directory
listed with @code{dirs}; that is, @code{popd} is equivalent to @code{popd +0}.
listed by @code{dirs};
that is, @code{popd} is equivalent to @code{popd +0}.
When no arguments are given, @code{popd}
removes the top directory from the stack and changes to
the new top directory.
Arguments, if supplied, have the following meanings:
@table @code
@item -n
@@ -7513,22 +7523,37 @@ Suppresses the normal change of directory when removing directories
from the stack, so that only the stack is manipulated.
@item +@var{N}
Removes the @var{N}th directory (counting from the left of the
list printed by @code{dirs}), starting with zero.
list printed by @code{dirs}), starting with zero, from the stack.
@item -@var{N}
Removes the @var{N}th directory (counting from the right of the
list printed by @code{dirs}), starting with zero.
list printed by @code{dirs}), starting with zero, from the stack.
@end table
If the top element of the directory stack is modified, and
the @option{-n} option was not supplied, @code{popd} uses the @code{cd}
builtin to change to the directory at the top of the stack.
If the @code{cd} fails, @code{popd} returns a non-zero value.
Otherwise, @code{popd} returns an unsuccessful status if
an invalid option is encountered, the directory stack
is empty, or a non-existent directory stack entry is specified.
If the @code{popd} command is successful, a @code{dirs}
is performed as well, and the return status is 0.
@btindex pushd
@item pushd
@example
pushd [-n] [@var{+N} | @var{-N} | @var{dir}]
@end example
Save the current directory on the top of the directory stack
and then @code{cd} to @var{dir}.
With no arguments, @code{pushd} exchanges the top two directories
and makes the new top the current directory.
Adds a directory to the top of the directory stack, or rotates
the stack, making the new top of the stack the current working
directory.
With no arguments, @code{pushd} exchanges the top two elements
of the directory stack.
Arguments, if supplied, have the following meanings:
@table @code
@item -n
@@ -7543,10 +7568,22 @@ Brings the @var{N}th directory (counting from the right of the
list printed by @code{dirs}, starting with zero) to the top of
the list by rotating the stack.
@item @var{dir}
Makes @var{dir} be the top of the stack, making
it the new current directory as if it had been supplied as an argument
to the @code{cd} builtin.
Makes @var{dir} be the top of the stack.
@end table
After the stack has been modified, if the @option{-n} option was not
supplied, @code{pushd} uses the @code{cd} builtin to change to the
directory at the top of the stack.
If the @code{cd} fails, @code{pushd} returns a non-zero value.
Otherwise, if no arguments are supplied, @code{pushd} returns 0 unless the
directory stack is empty.
When rotating the directory stack, @code{pushd} returns 0 unless
the directory stack is empty or a non-existent directory stack element
is specified.
If the @code{pushd} command is successful, a @code{dirs} is performed as well.
@end table
@node Controlling the Prompt
@@ -7604,7 +7641,8 @@ The version of Bash (e.g., 2.00)
@item \V
The release of Bash, version + patchlevel (e.g., 2.00.0)
@item \w
The current working directory, with @env{$HOME} abbreviated with a tilde
The value of the @code{PWD} shell variable (@env{$PWD}),
with @env{$HOME} abbreviated with a tilde
(uses the @env{$PROMPT_DIRTRIM} variable).
@item \W
The basename of @env{$PWD}, with @env{$HOME} abbreviated with a tilde.
+18 -3
View File
@@ -2421,9 +2421,24 @@ dumb_update:
((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth+prompt_invis_chars_first_line))))
ADJUST_CPOS (wrap_offset - prompt_invis_chars_first_line);
/* XXX - what happens if wrap_offset == prompt_invis_chars_first_line
and we are drawing the first line (current_line == 0)? We should
adjust by _rl_last_c_pos -= prompt_invis_chars_first_line */
/* What happens if wrap_offset == prompt_invis_chars_first_line
and we are drawing the first line (current_line == 0), or if we
are drawing the first line and changing the number of invisible
characters in the line? If we're starting to draw before the last
invisible character in the prompt, we need to adjust by
_rl_last_c_pos -= prompt_invis_chars_first_line. This can happen
when we finish reading a digit argument (with the "(arg: N)"
prompt) and are switching back to displaying a line with a prompt
containing invisible characters, since we have to redraw the
entire prompt string. */
if ((mb_cur_max > 1 && rl_byte_oriented == 0) &&
current_line == 0 && wrap_offset &&
displaying_prompt_first_line &&
wrap_offset == prompt_invis_chars_first_line &&
visible_wrap_offset != current_invis_chars &&
visible_wrap_offset != prompt_invis_chars_first_line &&
((nfd-new) < prompt_last_invisible))
ADJUST_CPOS (prompt_invis_chars_first_line);
}
}
else /* Delete characters from line. */
+20 -6
View File
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
topdir = .
srcdir = .
VPATH = .
@@ -49,6 +48,8 @@ TEXI2HTML = $(srcdir)/texi2html
QUIETPS = #set this to -q to shut up dvips
PSDPI = 300 # I don't have any 600-dpi printers
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -o $@ # tricky
DVIPDF = dvipdfm -o $@ -p ${PAPERSIZE}
PSPDF = gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@
RLSRC = $(srcdir)/rlman.texi $(srcdir)/rluser.texi \
$(srcdir)/rltech.texi $(srcdir)/version.texi \
@@ -66,15 +67,25 @@ DVIOBJ = readline.dvi history.dvi rluserman.dvi
INFOOBJ = readline.info history.info rluserman.info
PSOBJ = readline.ps history.ps rluserman.ps
HTMLOBJ = readline.html history.html rluserman.html
PDFOBJ = readline.pdf history.pdf rluserman.pdf
INTERMEDIATE_OBJ = rlman.dvi
CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ)
CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(PDFOBJ)
.SUFFIXES: .ps .txt .dvi
.SUFFIXES: .ps .txt .dvi .html .pdf
all: info dvi html ps
.ps.pdf:
$(RM) $@
-${PSPDF} $<
.dvi.pdf:
$(RM) $@
-${DVIPDF} $<
all: info dvi html ps
nodvi: info html
pdf: $(PDFOBJ)
readline.dvi: $(RLSRC)
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rlman.texi
@@ -123,14 +134,17 @@ dvi: $(DVIOBJ)
ps: $(PSOBJ)
html: $(HTMLOBJ)
readline.pdf: readline.dvi
history.pdf: history.dvi
rluserman.pdf: rluserman.dvi
clean:
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
*.fns *.kys *.tps *.vrs *.o core
*.fns *.kys *.tps *.vrs *.bt *.bts *.o core *.core
distclean: clean
$(RM) $(CREATED_DOCS)
$(RM) $(INTERMEDIATE_OBJ)
$(RM) Makefile
mostlyclean: clean
+6 -5
View File
@@ -2,20 +2,21 @@
# This makefile for Readline library documentation is in -*- text -*- mode.
# Emacs likes it that way.
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
topdir = .
srcdir = .
@@ -45,7 +46,7 @@ MAKEINFO = LANGUAGE= makeinfo
TEXI2DVI = $(srcdir)/texi2dvi
TEXI2HTML = $(srcdir)/texi2html
QUIETPS = #set this to -q to shut up dvips
PSDPI = 600
PSDPI = 300 # I don't have any 600-dpi printers
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -o $@ # tricky
DVIPDF = dvipdfm -o $@ -p ${PAPERSIZE}
PSPDF = gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@
+5
View File
@@ -1772,6 +1772,11 @@ the output is formatted in such a way that it can be made part
of an @var{inputrc} file. This command is unbound by default.
@ifset BashFeatures
@item spell-correct-word (C-x s)
Perform spelling correction on the current word, treating it as a directory
or filename, in the same way as the @code{cdspell} shell option.
Word boundaries are the same as those used by @code{shell-forward-word}.
@item glob-complete-word (M-g)
The word before point is treated as a pattern for pathname expansion,
with an asterisk implicitly appended. This pattern is used to
+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 10 March 2021
@set UPDATED 16 March 2021
@set UPDATED-MONTH March 2021
@set LASTCHANGE Wed Mar 10 15:43:49 EST 2021
@set LASTCHANGE Tue Mar 16 14:41:07 EDT 2021
+1 -1
View File
@@ -4655,7 +4655,7 @@ xparse_dolparen (base, string, indp, flags)
itrace("xparse_dolparen:%d: *indp (%d) < orig_ind (%d), orig_string = `%s'", line_number, *indp, orig_ind, ostring);
#endif
if (base[*indp] != ')')
if (base[*indp] != ')' && (flags & SX_NOLONGJMP) == 0)
{
/*(*/
parser_error (start_lineno, _("unexpected EOF while looking for matching `%c'"), ')');
+4 -6
View File
@@ -3734,14 +3734,14 @@ expand_string_dollar_quote (string, flags)
char *ret, *trans, *send, *t;
DECLARE_MBSTATE;
retsize = slen + 1;
ret = xmalloc (retsize);
retind = 0;
slen = strlen (string);
send = string + slen;
sindex = 0;
retsize = slen + 1;
ret = xmalloc (retsize);
retind = 0;
while (c = string[sindex])
{
switch (c)
@@ -6205,10 +6205,8 @@ process_substitute (string, open_for_read_in_child)
remove_quoted_escapes (string);
#if 0 /* TAG: bash-5.2 */
startup_state = 2; /* see if we can avoid a fork */
parse_and_execute_level = 0;
#endif
/* Give process substitution a place to jump back to on failure,
so we don't go back up to main (). */
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR