documentation updates; fix read builtin not to set tty EOL character to NUL if the delimiter is NULL

This commit is contained in:
Chet Ramey
2026-02-09 14:09:42 -05:00
parent 468e98e574
commit 979ae78392
24 changed files with 22295 additions and 51749 deletions
+7 -1
View File
@@ -12667,4 +12667,10 @@ array.c,array2.c
Not used yet, but could be used for another array parameter
expansion, like ksh93's array[s..e]
2/5
---
builtins/read.def
- read_builtin: if the delimiter happens to be _POSIX_VDISABLE, use
the old character-at-a-time cbreak mode code path if we're reading
from a tty
Report from Martin D Kealey <martin@kurahaupo.gen.nz>
+4 -7
View File
@@ -5,23 +5,20 @@ doc d
MANIFEST.doc f
doc/article.ps f
doc/rose94.ps f
doc/bash.ps f
doc/bashbug.ps f
doc/builtins.ps f
doc/rbash.ps f
doc/bashref.dvi f
doc/bash.0 f
doc/bashbug.0 f
doc/builtins.0 f
doc/rbash.0 f
doc/article.txt f
doc/bash.html f
doc/bashref.html f
doc/bash.info f
doc/bashref.info f
doc/bash.html f
doc/bashref.html f
doc/article.pdf f
doc/bash.pdf f
doc/bashref.pdf f
doc/builtins.pdf f
doc/rbash.pdf f
doc/rose94.pdf f
doc/aosa-bash.pdf f
doc/aosa-bash-full.pdf f
+68 -60
View File
@@ -47,10 +47,10 @@ there are areas where the Bash default behavior differs from the
specification. The Bash “posix mode” changes the Bash behavior in these
areas so that it conforms more strictly to the standard.
Starting Bash with the --posix command-line option or executing set
-o posix while Bash is running will cause Bash to conform more closely
to the POSIX standard by changing the behavior to match that specified
by POSIX in areas where the Bash default differs.
Starting Bash with the --posix or -o posix command-line option or
executing set -o posix while Bash is running will cause Bash to
conform more closely to the POSIX standard by changing the behavior to
match that specified by POSIX in areas where the Bash default differs.
When invoked as sh, Bash enters POSIX mode after reading the startup
files.
@@ -60,7 +60,7 @@ The following list is what's changed when POSIX mode is in effect:
1. Bash ensures that the POSIXLY_CORRECT variable is set.
2. Bash reads and executes the POSIX startup files ($ENV) rather
than the normal Bash files (*note Bash Startup Files::.
than the normal Bash files (*note Bash Startup Files::).
3. Alias expansion is always enabled, even in non-interactive shells.
@@ -140,65 +140,73 @@ The following list is what's changed when POSIX mode is in effect:
the command hash table, even if it returns it as a (last-ditch)
result from a $PATH search.
22. The message printed by the job control code and builtins when a
job exits with a non-zero status is 'Done(status)'.
22. Normally, when job control is not enabled, the shell implicitly
redirects the standard input of asynchronous commands from
/dev/null. A redirection to the standard input in this command
inhibits this implicit redirection. In POSIX mode, a redirection
that redirects file descriptor 0 to itself (e.g., <&0) does not
count as a redirection that overrides the implicit redirection from
/dev/null.
23. The message printed by the job control code and builtins when a
job is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for
job exits with a non-zero status is "Done(status)".
24. The message printed by the job control code and builtins when a
job is stopped is "Stopped(SIGNAME)", where SIGNAME is, for
example, SIGTSTP.
24. If the shell is interactive, Bash does not perform job
25. If the shell is interactive, Bash does not perform job
notifications between executing commands in lists separated by ;
or newline. Non-interactive shells print status messages after a
foreground job in a list completes.
25. If the shell is interactive, Bash waits until the next prompt
26. If the shell is interactive, Bash waits until the next prompt
before printing the status of a background job that changes status
or a foreground job that terminates due to a signal.
Non-interactive shells print status messages after a foreground job
completes.
26. Bash permanently removes jobs from the jobs table after notifying
27. Bash permanently removes jobs from the jobs table after notifying
the user of their termination via the wait or jobs builtins.
It removes the job from the jobs list after notifying the user of
its termination, but the status is still available via wait, as
long as wait is supplied a PID argument.
27. The vi editing mode will invoke the vi editor directly when
28. The vi editing mode will invoke the vi editor directly when
the v command is run, instead of checking $VISUAL and
$EDITOR.
28. Prompt expansion enables the POSIX PS1 and PS2 expansions of
29. Prompt expansion enables the POSIX PS1 and PS2 expansions of
! to the history number and !! to !, and Bash performs
parameter expansion on the values of PS1 and PS2 regardless of
the setting of the promptvars option.
29. The default history file is ~/.sh_history (this is the default
30. The default history file is ~/.sh_history (this is the default
value the shell assigns to $HISTFILE).
30. The ! character does not introduce history expansion within a
31. The ! character does not introduce history expansion within a
double-quoted string, even if the histexpand option is enabled.
31. When printing shell function definitions (e.g., by type), Bash
32. When printing shell function definitions (e.g., by type), Bash
does not print the function reserved word unless necessary.
32. Non-interactive shells exit if a syntax error in an arithmetic
33. Non-interactive shells exit if a syntax error in an arithmetic
expansion results in an invalid expression.
33. Non-interactive shells exit if a parameter expansion error occurs.
34. Non-interactive shells exit if a parameter expansion error occurs.
34. If a POSIX special builtin returns an error status, a
35. If a POSIX special builtin returns an error status, a
non-interactive shell exits. The fatal errors are those listed in
the POSIX standard, and include things like passing incorrect
options, redirection errors, variable assignment errors for
assignments preceding the command name, and so on.
35. A non-interactive shell exits with an error status if a variable
36. A non-interactive shell exits with an error status if a variable
assignment error occurs when no command name follows the assignment
statements. A variable assignment error occurs, for example, when
trying to assign a value to a readonly variable.
36. A non-interactive shell exits with an error status if a variable
37. A non-interactive shell exits with an error status if a variable
assignment error occurs in an assignment statement preceding a
special builtin, but not with any other simple command. For any
other simple command, the shell aborts execution of that command,
@@ -206,160 +214,160 @@ The following list is what's changed when POSIX mode is in effect:
perform any further processing of the command in which the error
occurred").
37. A non-interactive shell exits with an error status if the
38. A non-interactive shell exits with an error status if the
iteration variable in a for statement or the selection variable
in a select statement is a readonly variable or has an invalid
name.
38. Non-interactive shells exit if FILENAME in . FILENAME is not
39. Non-interactive shells exit if FILENAME in . FILENAME is not
found.
39. Non-interactive shells exit if there is a syntax error in a script
40. Non-interactive shells exit if there is a syntax error in a script
read with the . or source builtins, or in a string processed by
the eval builtin.
40. Non-interactive shells exit if the export, readonly or unset
41. Non-interactive shells exit if the export, readonly or unset
builtin commands get an argument that is not a valid identifier,
and they are not operating on shell functions. These errors force
an exit because these are special builtins.
41. Assignment statements preceding POSIX special builtins persist in
42. Assignment statements preceding POSIX special builtins persist in
the shell environment after the builtin completes.
42. The command builtin does not prevent builtins that take
43. The command builtin does not prevent builtins that take
assignment statements as arguments from expanding them as
assignment statements; when not in POSIX mode, declaration commands
lose their assignment statement expansion properties when preceded
by command.
43. Enabling POSIX mode has the effect of setting the
44. Enabling POSIX mode has the effect of setting the
inherit_errexit option, so subshells spawned to execute command
substitutions inherit the value of the -e option from the parent
shell. When the inherit_errexit option is not enabled, Bash
clears the -e option in such subshells.
44. Enabling POSIX mode has the effect of setting the shift_verbose
45. Enabling POSIX mode has the effect of setting the shift_verbose
option, so numeric arguments to shift that exceed the number of
positional parameters will result in an error message.
45. Enabling POSIX mode has the effect of setting the
46. Enabling POSIX mode has the effect of setting the
interactive_comments option (*note Comments::).
46. The . and source builtins do not search the current directory
47. The . and source builtins do not search the current directory
for the filename argument if it is not found by searching PATH.
47. When the alias builtin displays alias definitions, it does not
48. When the alias builtin displays alias definitions, it does not
display them with a leading alias unless the -p option is
supplied.
48. The bg builtin uses the required format to describe each job
49. The bg builtin uses the required format to describe each job
placed in the background, which does not include an indication of
whether the job is the current or previous job.
49. When the cd builtin is invoked in logical mode, and the pathname
50. When the cd builtin is invoked in logical mode, and the pathname
constructed from $PWD and the directory name supplied as an
argument does not refer to an existing directory, cd will fail
instead of falling back to physical mode.
50. When the cd builtin cannot change a directory because the length
51. When the cd builtin cannot change a directory because the length
of the pathname constructed from $PWD and the directory name
supplied as an argument exceeds PATH_MAX when canonicalized, cd
will attempt to use the supplied directory name.
51. When the xpg_echo option is enabled, Bash does not attempt to
52. When the xpg_echo option is enabled, Bash does not attempt to
interpret any arguments to echo as options. echo displays each
argument after converting escape sequences.
52. The export and readonly builtin commands display their output
53. The export and readonly builtin commands display their output
in the format required by POSIX.
53. When listing the history, the fc builtin does not include an
54. When listing the history, the fc builtin does not include an
indication of whether or not a history entry has been modified.
54. The default editor used by fc is ed.
55. The default editor used by fc is ed.
55. fc treats extra arguments as an error instead of ignoring them.
56. fc treats extra arguments as an error instead of ignoring them.
56. If there are too many arguments supplied to fc -s, fc prints
57. If there are too many arguments supplied to fc -s, fc prints
an error message and returns failure.
57. The output of kill -l prints all the signal names on a single
58. The output of kill -l prints all the signal names on a single
line, separated by spaces, without the SIG prefix.
58. The kill builtin does not accept signal names with a SIG
59. The kill builtin does not accept signal names with a SIG
prefix.
59. The kill builtin returns a failure status if any of the pid or
60. The kill builtin returns a failure status if any of the pid or
job arguments are invalid or if sending the specified signal to any
of them fails. In default mode, kill returns success if the
signal was successfully sent to any of the specified processes.
60. The printf builtin uses double (via strtod) to convert
61. The printf builtin uses double (via strtod) to convert
arguments corresponding to floating point conversion specifiers,
instead of long double if it's available. The L length
modifier forces printf to use long double if it's available.
61. The pwd builtin verifies that the value it prints is the same as
62. The pwd builtin verifies that the value it prints is the same as
the current directory, even if it is not asked to check the file
system with the -P option.
62. The read builtin may be interrupted by a signal for which a trap
63. The read builtin may be interrupted by a signal for which a trap
has been set. If Bash receives a trapped signal while executing
read, the trap handler executes and read returns an exit status
greater than 128.
63. When the set builtin is invoked without options, it does not
64. When the set builtin is invoked without options, it does not
display shell function names and definitions.
64. When the set builtin is invoked without options, it displays
65. When the set builtin is invoked without options, it displays
variable values without quotes, unless they contain shell
metacharacters, even if the result contains nonprinting characters.
65. The test builtin compares strings using the current locale when
66. The test builtin compares strings using the current locale when
evaluating the < and > binary operators.
66. The test builtin's -t unary primary requires an argument.
67. The test builtin's -t unary primary requires an argument.
Historical versions of test made the argument optional in certain
cases, and Bash attempts to accommodate those for backwards
compatibility.
67. The trap builtin displays signal names without the leading
68. The trap builtin displays signal names without the leading
SIG.
68. The trap builtin doesn't check the first argument for a possible
69. The trap builtin doesn't check the first argument for a possible
signal specification and revert the signal handling to the original
disposition if it is, unless that argument consists solely of
digits and is a valid signal number. If users want to reset the
handler for a given signal to the original disposition, they should
use - as the first argument.
69. trap -p without arguments displays signals whose dispositions
70. trap -p without arguments displays signals whose dispositions
are set to SIG_DFL and those that were ignored when the shell
started, not just trapped signals.
70. The type and command builtins will not report a non-executable
71. The type and command builtins will not report a non-executable
file as having been found, though the shell will attempt to execute
such a file if it is the only so-named file found in $PATH.
71. The ulimit builtin uses a block size of 512 bytes for the -c
72. The ulimit builtin uses a block size of 512 bytes for the -c
and -f options.
72. The unset builtin with the -v option specified returns a fatal
73. The unset builtin with the -v option specified returns a fatal
error if it attempts to unset a readonly or non-unsettable
variable, which causes a non-interactive shell to exit.
73. When asked to unset a variable that appears in an assignment
74. When asked to unset a variable that appears in an assignment
statement preceding the command, the unset builtin attempts to
unset a variable of the same name in the current or previous scope
as well. This implements the required "if an assigned variable is
further modified by the utility, the modifications made by the
utility shall persist" behavior.
74. The arrival of SIGCHLD when a trap is set on SIGCHLD does not
75. The arrival of SIGCHLD when a trap is set on SIGCHLD does not
interrupt the wait builtin and cause it to return immediately.
The trap command is run once for each child that exits.
75. Bash removes an exited background process's status from the list
76. Bash removes an exited background process's status from the list
of such statuses after the wait builtin returns it.
There is additional POSIX behavior that Bash does not implement by
+4 -1
View File
@@ -47,7 +47,10 @@ shell escapes are particularly vulnerable), changing the current
directory to a non-writable directory other than $HOME after login,
not allowing the restricted shell to execute shell scripts, and cleaning
the environment of variables that cause some commands to modify their
behavior (e.g., VISUAL or PAGER).
behavior (e.g., VISUAL or PAGER). When setting up a restricted
environment like this, it's important not to install or allow symbolic
links in the new current directory, since those could be used to
circumvent restrictions on writing to files.
Modern systems provide more secure ways to implement a restricted
environment, such as jails, zones, or containers.
-7519
View File
File diff suppressed because it is too large Load Diff
-13778
View File
File diff suppressed because it is too large Load Diff
-13779
View File
File diff suppressed because it is too large Load Diff
View File
+19 -4
View File
@@ -142,7 +142,7 @@ static void uw_reset_timeout (void *);
/* Try this to see what the rest of the shell can do with the information. */
sh_timer *read_timeout;
static int reading, tty_modified;
static int reading, tty_modified, vdisable = -10;
static struct ttsave termsave;
@@ -595,6 +595,21 @@ read_builtin (WORD_LIST *list)
shtimer_set (read_timeout, tmsec, tmusec);
}
/* Initialize this once, as needed, it's not going to change. */
if (vdisable == -10 && input_is_tty && delim != '\n')
{
#if defined (_POSIX_VDISABLE)
vdisable = _POSIX_VDISABLE;
#elif defined (_PC_VDISABLE) && defined (HAVE_PATHCONF)
errno = 0;
vdisable = pathconf("/dev/tty", _PC_VDISABLE);
if (vdisable == -1 && errno != 0)
vdisable = 0; /* conservative assumption */
#else
vdisable = 0;
#endif
}
/* If we've been asked to read only NCHARS chars, or we're using some
character other than newline to terminate the line, do the right
thing to readline or the tty. */
@@ -627,9 +642,9 @@ read_builtin (WORD_LIST *list)
ttset = ttattrs;
if (nchars > 0)
if (nchars > 0 || delim == vdisable)
rc = silent ? ttfd_cbreak (fd, &ttset) : ttfd_onechar (fd, &ttset);
else /* delim != '\n' */
else /* delim != '\n',_POSIX_VDISABLE */
{
rc = silent ? tt_setnoecho (&ttset) : 0;
if (rc >= 0)
@@ -706,7 +721,7 @@ read_builtin (WORD_LIST *list)
else if ((nchars > 0 && input_is_tty) || input_is_pipe) /* read -n */
unbuffered_read = 1;
else if (delim != '\n' && input_is_tty) /* read -d */
unbuffered_read = 3;
unbuffered_read = (delim != vdisable) ? 3 : 1;
if (prompt && edit == 0)
{
+9306 -9086
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+27 -52
View File
@@ -1,12 +1,12 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.27 (TeX Live 2025/MacPorts 2025.74524_1) (preloaded format=pdfetex 2025.9.16) 29 JAN 2026 13:25
This is pdfTeX, Version 3.141592653-2.6-1.40.27 (TeX Live 2025/MacPorts 2025.74524_1) (preloaded format=etex 2025.9.16) 2 FEB 2026 15:27
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
%&-line parsing enabled.
**\input /usr/local/src/bash/bash-20260123/doc/bashref.texi \input /usr/local/s
rc/bash/bash-20260123/doc/bashref.texi
(/usr/local/src/bash/bash-20260123/doc/bashref.texi
(/usr/local/src/bash/bash-20260123/doc/texinfo.tex
**\nonstopmode \input /usr/local/src/bash/bash-20260130/doc/bashref.texi \input
/usr/local/src/bash/bash-20260130/doc/bashref.texi
(/usr/local/src/bash/bash-20260130/doc/bashref.texi
(/usr/local/src/bash/bash-20260130/doc/texinfo.tex
Loading texinfo [version 2015-11-22.14]:
\outerhsize=\dimen16
\outervsize=\dimen17
@@ -162,23 +162,20 @@ This is `epsf.tex' v2.7.4 <14 February 2011>
texinfo.tex: doing @include of version.texi
(/usr/local/src/bash/bash-20260123/doc/version.texi) [1{/opt/local/var/db/texmf
/fonts/map/pdftex/updmap/pdftex.map}] [2]
(/usr/local/build/bash/bash-20260123/doc/bashref.toc [-1] [-2] [-3]) [-4]
(/usr/local/build/bash/bash-20260123/doc/bashref.toc)
(/usr/local/build/bash/bash-20260123/doc/bashref.toc) Chapter 1
(/usr/local/src/bash/bash-20260130/doc/version.texi) [1] [2]
(/usr/local/build/bash/bash-20260130/doc/bashref.toc [-1] [-2] [-3]) [-4]
Chapter 1
\openout0 = `bashref.toc'.
(/usr/local/build/bash/bash-20260123/doc/bashref.aux)
(/usr/local/build/bash/bash-20260130/doc/bashref.aux)
\openout1 = `bashref.aux'.
[1] Chapter 2 [2]
[1] Chapter 2
[2]
@cpindfile=@write2
\openout2 = `bashref.cp'.
[3] Chapter 3 [4] [5] [6] [7]
[3] Chapter 3 [4] [5] [6] [7]
@vrindfile=@write3
\openout3 = `bashref.vr'.
@@ -222,16 +219,15 @@ Overfull \hbox (5.95723pt too wide) in paragraph at lines 765--766
@rwindfile=@write4
\openout4 = `bashref.rw'.
[10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20{/opt/local/share/texmf-t
exlive/fonts/enc/dvips/cm-super/cm-super-t1.enc}] [21] [22] [23] [24]
[25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35] [36] [37] [38] [39]
[40] [41] [42] [43] [44] [45] [46] [47] [48] [49] [50] Chapter 4 [51]
[10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23]
[24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35] [36] [37] [38]
[39] [40] [41] [42] [43] [44] [45] [46] [47] [48] [49] [50] Chapter 4 [51]
@btindfile=@write5
\openout5 = `bashref.bt'.
[52]
[53] [54] [55] [56] [57] [58] [59] [60] [61] [62] [63] [64] [65] [66] [67]
[68] [69] [70] [71] [72] [73]
[52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62] [63] [64] [65] [66]
[67] [68] [69] [70] [71] [72] [73]
Overfull \hbox (38.26585pt too wide) in paragraph at lines 5964--5964
[]@texttt set [-abefhkmnptuvxBCEHPT] [-o @textttsl option-name@texttt ] [--] [
-] [@textttsl ar-gu-ment []@texttt ][]
@@ -265,7 +261,7 @@ Chapter 7 [124] [125] [126] [127] [128]
texinfo.tex: doing @include of rluser.texi
(/usr/local/src/bash/bash-20260123/lib/readline/doc/rluser.texi Chapter 8
(/usr/local/src/bash/bash-20260130/lib/readline/doc/rluser.texi Chapter 8
[129] [130] [131] [132] [133] [134] [135] [136] [137] [138] [139] [140]
Underfull \hbox (badness 7540) in paragraph at lines 969--975
[]@textrm In the ex-am-ple above, @textttsl C-u[] @textrm is bound to the func
@@ -314,7 +310,7 @@ gnored[]
texinfo.tex: doing @include of hsuser.texi
(/usr/local/src/bash/bash-20260123/lib/readline/doc/hsuser.texi Chapter 9
(/usr/local/src/bash/bash-20260130/lib/readline/doc/hsuser.texi Chapter 9
[167] [168] [169] [170] [171] [172] [173]) Chapter 10 [174] [175] [176]
[177] [178]
Underfull \hbox (badness 10000) in paragraph at lines 10793--10802
@@ -347,37 +343,16 @@ extrm '[], `@texttt strict-posix-default[]@textrm '[], and
texinfo.tex: doing @include of fdl.texi
(/usr/local/src/bash/bash-20260123/doc/fdl.texi [192] [193] [194] [195]
(/usr/local/src/bash/bash-20260130/doc/fdl.texi [192] [193] [194] [195]
[196] [197] [198]) Appendix D [199] [200] [201] [202] [203] [204] [205]
[206] [207] [208] )
Here is how much of TeX's memory you used:
4116 strings out of 495820
47662 string characters out of 6170887
145125 words of memory out of 5000000
5053 multiletter control sequences out of 15000+600000
3531 strings out of 495830
40273 string characters out of 6171293
88550 words of memory out of 5000000
4884 multiletter control sequences out of 15000+600000
34315 words of font info for 116 fonts, out of 8000000 for 9000
701 hyphenation exceptions out of 8191
16i,6n,16p,389b,983s stack positions out of 10000i,1000n,20000p,200000b,200000s
</opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/
cm/cmbx12.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cm
csc10.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmmi10
.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmmi12.pfb>
</opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmmi9.pfb></opt/
local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr10.pfb></opt/local/
share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr9.pfb></opt/local/share/t
exmf-texlive/fonts/type1/public/amsfonts/cm/cmsl10.pfb></opt/local/share/texmf-
texlive/fonts/type1/public/amsfonts/cm/cmsltt10.pfb></opt/local/share/texmf-tex
live/fonts/type1/public/amsfonts/cm/cmsy10.pfb></opt/local/share/texmf-texlive/
fonts/type1/public/amsfonts/cm/cmti10.pfb></opt/local/share/texmf-texlive/fonts
/type1/public/amsfonts/cm/cmtt10.pfb></opt/local/share/texmf-texlive/fonts/type
1/public/amsfonts/cm/cmtt12.pfb></opt/local/share/texmf-texlive/fonts/type1/pub
lic/amsfonts/cm/cmtt9.pfb></opt/local/share/texmf-texlive/fonts/type1/public/cm
-super/sfrm1095.pfb></opt/local/share/texmf-texlive/fonts/type1/public/cm-super
/sfrm1440.pfb>
Output written on bashref.pdf (214 pages, 813195 bytes).
PDF statistics:
2948 PDF objects out of 2984 (max. 8388607)
2686 compressed objects within 27 object streams
342 named destinations out of 1000 (max. 500000)
1157 words of extra memory for PDF output out of 10000 (max. 10000000)
16i,6n,16p,402b,942s stack positions out of 10000i,1000n,20000p,200000b,200000s
Output written on bashref.dvi (214 pages, 903700 bytes).
+6497 -6326
View File
File diff suppressed because it is too large Load Diff
+18 -7
View File
@@ -63,7 +63,7 @@ extern int errno;
#endif
static char *bash_special_tilde_expansions (char *);
static int unquoted_tilde_word (const char *);
static int unquoted_tilde_word (const char *, int);
static void initialize_group_array (void);
/* A standard error message to use when getcwd() returns NULL. */
@@ -1184,7 +1184,7 @@ tilde_initialize (void)
#define TILDE_END(c) ((c) == '\0' || (c) == '/' || (c) == ':')
static int
unquoted_tilde_word (const char *s)
unquoted_tilde_word (const char *s, int flags)
{
const char *r;
@@ -1238,10 +1238,11 @@ bash_tilde_find_word (const char *s, int flags, size_t *lenp)
}
/* Tilde-expand S by running it through the tilde expansion library.
ASSIGN_P is 1 if this is a variable assignment, so the alternate
tilde prefixes should be enabled (`=~' and `:~', see above). If
ASSIGN_P is 2, we are expanding the rhs of an assignment statement,
so `=~' is not valid. */
ASSIGN_P is 1 if this is a variable assignment, or a word for which
tilde expansion is being forced, so the alternate tilde prefixes should
be enabled (`=~' and `:~', see above). If ASSIGN_P is 2, we are expanding
the rhs of an assignment statement, so `=~' is not valid.
ASSIGN_P is 0 for all other words. */
char *
bash_tilde_expand (const char *s, int assign_p)
{
@@ -1253,7 +1254,17 @@ bash_tilde_expand (const char *s, int assign_p)
if (assign_p == 2)
tilde_additional_suffixes = bash_tilde_suffixes2;
r = (*s == '~') ? unquoted_tilde_word (s) : 1;
/*TAG:bash-5.4 posix mode possibly */
/* XXX - in posix mode, if assign_p is 0 (an ordinary word, not an
assignment), we shouldn't tilde expand a tilde followed by a colon.
To do this, we need to assign tilde_additional_suffixes = (char **)NULL,
and change unquoted_tilde_word to pay attention to assign_p (if it's
0 && posixly_correct, don't accept `:' as the end of a tilde prefix).
Behavior varies widely, but many posix shells don't perform tilde
expansion in `echo ~:'. */
/* If we don't do this, remove the sentence from the Tilde Expansion section
of the man page and texinfo manual saying we do. */
r = (*s == '~') ? unquoted_tilde_word (s, assign_p) : 1;
ret = r ? tilde_expand (s) : savestring (s);
QUIT;
+5 -2
View File
@@ -386,8 +386,11 @@ PARSE_SUBBRACKET (CHAR *p, int flags)
type = *p;
/* POSIX allows a right bracket to appear in a collating symbol. */
while (*++p != L('\0') && SLASH_PATHNAME (*p) == 0 && (type != L('.') && *p == L(']')) == 0)
/* POSIX allows a right bracket to appear in a collating symbol. If we
want to allow it to appear in an equivalence class, uncomment the test
of TYPE against '=' below. */
while (*++p != L('\0') && SLASH_PATHNAME (*p) == 0 &&
(type != L('.') /*&& type != L('=')*/ && *p == L(']')) == 0)
if (*p == type && p[1] == L(']'))
return p;
return NULL;
BIN
View File
Binary file not shown.
+5704
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+632 -620
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -11605,7 +11605,11 @@ add_string:
goto add_character;
}
#if 0 /* TAG:bash-5.4 posix mode possibly */
if (word->flags & (W_ASSIGNRHS|W_ASSIGNARG))
#else
if (word->flags & W_ASSIGNRHS)
#endif
tflag = 2;
else if (word->flags & (W_ASSIGNMENT|W_TILDEEXP))
tflag = 1;
-127
View File
@@ -1,127 +0,0 @@
#! /bin/bash
#
# mail-shell -- mail out the shell
#
# usage: mail-shell -t tarball recipient
#
# Chet Ramey
# chet@ins.CWRU.Edu
#
# Copyright (C) 1995-2009 by Chester Ramey
#
# 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/>.
#
PATH=/usr/ucb:/bin:/usr/bin:/usr/local/bin/gnu:/usr/local/bin:.
trap 'rm -f x?? ${UUFILE}' 0 1 2 3 6 15
prog=`basename $0`
TARFILE=bash.tar
VERS=2.05b
while getopts t: opt
do
case $opt in
t) TARFILE=$OPTARG ;;
*) echo usage: $prog [ -t tarfile ] recipient 1>&2
exit 1
esac
done
shift $(( $OPTIND - 1 ))
case "$TARFILE" in
bash-*.tar) VERS=${TARFILE%%.tar} ; VERS=${VERS#bash-} ;;
esac
GZFILE=${TARFILE}.gz
UUFILE=${GZFILE}.uu
if [ $# -ne 1 ] ; then
echo usage: $0 recipient
exit 1
fi
recip=$1
i=1
if [ ! -f ${TARFILE} ] && [ ! -f ${GZFILE} ]; then
echo "$prog: no file ${TARFILE}, aborting"
exit 1
fi
if [ ! -f ${GZFILE} ] ; then
echo "$prog: no gzipped tar file ${GZFILE}"
echo "$prog: gzipping ${TARFILE}"
gzip ${TARFILE}
fi
if [ ! -f ${UUFILE} ] ; then
echo "$prog: no uuencoded tar file ${UUFILE}"
echo "$prog: uuencoding ${GZFILE}"
uuencode ${GZFILE} < ${GZFILE} > ${UUFILE}
fi
files=$(echo x??)
if [ "$files" = 'x??' ] ; then
echo "$prog: no split of ${UUFILE} exists"
echo "$prog: splitting ${UUFILE}"
split ${UUFILE}
fi
count()
{
echo $#
}
parts=$(count x??)
if [ -x /usr/ucb/mail ]; then
MAIL=/usr/ucb/mail
elif [ -x /usr/ucb/Mail ]; then
MAIL=/usr/ucb/Mail
elif [ -x /usr/bin/mailx ]; then
MAIL=/usr/bin/mailx
elif [ -x /usr/bin/mail ]; then
MAIL=/usr/bin/mail
else
MAIL=/bin/mail
fi
$MAIL -s "bash-${VERS} shipment coming" $recip <<EOF
Hi. Here is version ${VERS} of bash. Expect $parts messages.
Each is part of a uuencoded tar file of the bash sources. When
you get all $parts messages, cat them all together into the file
${UUFILE}, and run uudecode on this file. You will have a
gzipped tar file named ${GZFILE}. gunzip it, cd into a source
directory (the tar archive extracts into its own directory), and
untar.
Chet
EOF
for file in x??
do
echo mailing part $i to $recip
/usr/ucb/mail -s "${UUFILE} part $i of $parts" $recip < $file
i=$(( $i + 1 ))
done
exit 0
-380
View File
@@ -1,380 +0,0 @@
#
# A suite of tests for bash word expansions
#
# This tests parameter and variable expansion, with an empahsis on
# proper quoting behavior.
#
# Chet Ramey
#
# If you comment out the body of this function, you can do a diff against
# `expansion-tests.right' to see if the shell is behaving correctly
#
expect()
{
echo expect "$@"
}
# Test the substitution quoting characters (CTLESC and CTLNUL) in different
# combinations
expect "<^A>"
recho `echo ''`
expect "<^A>"
recho `echo ""`
expect "<^B>"
recho `echo ''`
expect "<^B>"
recho `echo ""`
expect "<^A>"
recho `echo `
expect "<^B>"
recho `echo `
# Test null strings without variable expansion
expect "<abcdefgh>"
recho abcd""efgh
expect "<abcdefgh>"
recho abcd''efgh
expect "<abcdefgh>"
recho ""abcdefgh
expect "<abcdefgh>"
recho ''abcdefgh
expect "<abcd>"
recho abcd""
expect "<abcd>"
recho abcd''
# Test the quirky behavior of $@ in ""
expect nothing
recho "$@"
expect "< >"
recho " $@"
expect "<-->"
recho "-${@}-"
# Test null strings with variable expansion that fails
expect '<>'
recho $xxx""
expect '<>'
recho ""$xxx
expect '<>'
recho $xxx''
expect '<>'
recho ''$xxx
expect '<>'
recho $xxx""$yyy
expect '<>'
recho $xxx''$yyy
# Test null strings with variable expansion that succeeds
xxx=abc
yyy=def
expect '<abc>'
recho $xxx""
expect '<abc>'
recho ""$xxx
expect '<abc>'
recho $xxx''
expect '<abc>'
recho ''$xxx
expect '<abcdef>'
recho $xxx""$yyy
expect '<abcdef>'
recho $xxx''$yyy
unset xxx yyy
# Test the unquoted special quoting characters
expect "<^A>"
recho 
expect "<^B>"
recho 
expect "<^A>"
recho ""
expect "<^B>"
recho ""
expect "<^A>"
recho ''
expect "<^B>"
recho ''
# Test expansion of a variable that is unset
expect nothing
recho $xxx
expect '<>'
recho "$xxx"
expect nothing
recho "$xxx${@}"
# Test empty string expansion
expect '<>'
recho ""
expect '<>'
recho ''
# Test command substitution with (disabled) history substitution
expect '<Hello World!>'
# set +H
recho "`echo \"Hello world!\"`"
# Test some shell special characters
expect '<`>'
recho "\`"
expect '<">'
recho "\""
expect '<\^A>'
recho "\"
expect '<\$>'
recho "\\$"
expect '<\\>'
recho "\\\\"
# This should give argv[1] = a argv[2] = b
expect '<a> <b>'
FOO=`echo 'a b' | tr ' ' '\012'`
recho $FOO
# This should give argv[1] = ^A argv[2] = ^B
expect '<^A> <^B>'
FOO=`echo ' ' | tr ' ' '\012'`
recho $FOO
# Test quoted and unquoted globbing characters
expect '<**>'
recho "*"*
expect '<\.\./*/>'
recho "\.\./*/"
# Test patterns that come up when the shell quotes funny character
# combinations
expect '<^A^B^A^B>'
recho ''
expect '<^A^A>'
recho ''
expect '<^A^B>'
recho ''
expect '<^A^A^B>'
recho ''
# More tests of "$@"
set abc def ghi jkl
expect '< abc> <def> <ghi> <jkl >'
recho " $@ "
expect '< abc> <def> <ghi> <jkl >'
recho "${1+ $@ }"
set abc def ghi jkl
expect '<--abc> <def> <ghi> <jkl-->'
recho "--$@--"
set "a b" cd ef gh
expect '<a b> <cd> <ef> <gh>'
recho ${1+"$@"}
expect '<a b> <cd> <ef> <gh>'
recho ${foo:-"$@"}
expect '<a b> <cd> <ef> <gh>'
recho "${@}"
expect '< >'
recho " "
expect '< - >'
recho " - "
# Test combinations of different types of quoting in a fully-quoted string
# (so the WHOLLY_QUOTED tests fail and it doesn't get set)
expect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'
recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"
# Test the various Posix parameter expansions
expect '<foo bar>'
recho "${x:-$(echo "foo bar")}"
expect '<foo> <bar>'
recho ${x:-$(echo "foo bar")}
unset X
expect '<abc>'
recho ${X:=abc}
expect '<abc>'
recho $X
set a b c
expect '<posix>'
recho ${3:+posix}
POSIX=/usr/posix
expect '<10>'
recho ${#POSIX}
# remove shortest trailing match
x=file.c
expect '<file.o>'
recho ${x%.c}.o
# remove longest trailing match
x=posix/src/std
expect '<posix>'
recho ${x%%/*}
# remove shortest leading pattern
x=$HOME/src/cmd
expect '</src/cmd>'
recho ${x#$HOME}
# remove longest leading pattern
x=/one/two/three
expect '<three>'
recho ${x##*/}
# pattern removal of patterns that don't match
z=abcdef
expect '<abcdef>'
recho ${z#xyz}
expect '<abcdef>'
recho ${z##xyz}
expect '<abcdef>'
recho ${z%xyz}
expect '<abcdef>'
recho ${z%%xyz}
# Command substitution and the quirky differences between `` and $()
expect '<\$x>'
recho '\$x'
expect '<$x>'
recho `echo '\$x'`
expect '<\$x>'
recho $(echo '\$x')
# The difference between $* "$*" and "$@"
set "abc" "def ghi" "jkl"
expect '<abc> <def> <ghi> <jkl>'
recho $*
expect '<abc def ghi jkl>'
recho "$*"
OIFS="$IFS"
IFS=":$IFS"
# The special behavior of "$*", using the first character of $IFS as separator
expect '<abc:def ghi:jkl>'
recho "$*"
IFS="$OIFS"
expect '<abc> <def ghi> <jkl>'
recho "$@"
expect '<xxabc> <def ghi> <jklyy>'
recho "xx$@yy"
expect '<abc> <def ghi> <jklabc> <def ghi> <jkl>'
recho "$@$@"
foo=abc
bar=def
expect '<abcdef>'
recho "$foo""$bar"
unset foo
set $foo bar '' xyz "$foo" abc
expect '<bar> <> <xyz> <> <abc>'
recho "$@"
# More tests of quoting and deferred evaluation
foo=10 x=foo
y='$'$x
expect '<$foo>'
recho $y
eval y='$'$x
expect '<10>'
recho $y
# case statements
NL='
'
x='ab
cd'
expect '<newline expected>'
case "$x" in
*$NL*) recho "newline expected" ;;
esac
expect '<got it>'
case \? in
*"?"*) recho "got it" ;;
esac
expect '<got it>'
case \? in
*\?*) recho "got it" ;;
esac
set one two three four five
expect '<one> <three> <five>'
recho $1 $3 ${5} $8 ${9}
# length tests on positional parameters and some special parameters
expect '<5> <5>'
recho $# ${#}
expect '<3>'
recho ${#1}
expect '<1>'
recho ${##}
expect '<1>'
recho ${#?}
expect '<5>'
recho ${#@}
expect '<5>'
recho ${#*}
expect '<5>'
recho "${#@}"
expect '<5>'
recho "${#*}"
expect '<42>'
recho $((28 + 14))
expect '<26>'
recho $[ 13 * 2 ]
expect '<\>'
recho `echo \\\\`
expect '<~>'
recho '~'
expect nothing
recho $!
expect nothing
recho ${!}
# test word splitting of assignment statements not preceding a command
a="a b c d e"
declare b=$a
expect '<a> <b> <c> <d> <e>'
recho $b
a="a?b?c"
echo ${a//\\?/ }
echo ${a//\?/ }
Binary file not shown.