fix bug parsing a compound assignment inside a (( nested subshell; man page style and formatting updates

This commit is contained in:
Chet Ramey
2024-01-19 12:05:12 -05:00
parent f2fdb5e313
commit a4f44b7a11
13 changed files with 564 additions and 413 deletions
+30
View File
@@ -8304,3 +8304,33 @@ parse.y
- parse_compound_assignment: handle error case (wl == &parse_string_error)
before restoring the parser state from ps
Report from Grisha Levit <grishalevit@gmail.com>
1/13
----
lib/readline/complete.c
- compute_lcd_of_matches: move a strlen out of a call to MBRTOWC by
computing the length of the entire string once and then using an
offset from it while going through the loop
1/15
----
parse.y
- parse_compound_assignment: treat parsing a string following (( (read
by parse_dparen but not an arithmetic command) the same as
expanding an alias when fixing up the pushed string list
Report from Grisha Levit <grishalevit@gmail.com>
1/18
----
doc/bash.1
- typos and style fixes to satisfy groff warnings; remove uses of the
`CW' constant-width font; use .EX/.EE for examples; use consistent
style for double-quoted strings; fix inconsistent inter-paragraph
spacing
Fixes from G. Branden Robinson <g.branden.robinson@gmail.com>
1/19
----
test.c
- binary_test: make sure all calls in posix mode use TEST_LOCALE for
locale-specific string comparisons
-1
View File
@@ -1056,7 +1056,6 @@ expand_and_quote_assoc_word (char *w, int type)
nword[i++] = w[ind++];
nword[i++] = w[ind++];
t = expand_assignment_string_to_string (w+ind, 0);
s = (t && strchr (t, CTLESC)) ? quote_escapes (t) : t;
value = sh_single_quote (s ? s : "");
+397 -323
View File
File diff suppressed because it is too large Load Diff
+36 -25
View File
@@ -1635,9 +1635,9 @@ are a result of the sequence of function calls that caused execution
to reach the current function.
The value of a variable that a function sees depends
on its value within its caller, if any, whether that caller is
the "global" scope or another shell function.
the global scope or another shell function.
This is also the value that a local variable
declaration "shadows", and the value that is restored when the function
declaration shadows, and the value that is restored when the function
returns.
For example, if a variable @env{var} is declared as local in function
@@ -2871,7 +2871,7 @@ In order to match the filenames @samp{.} and @samp{..},
the pattern must begin with @samp{.} (for example, @samp{.?}),
even if @code{dotglob} is set.
If the @code{globskipdots} shell option is enabled, the filenames
@samp{.} and @samp{..} are never matched, even if the pattern begins
@samp{.} and @samp{..} never match, even if the pattern begins
with a @samp{.}.
When not matching filenames, the @samp{.} character is not treated specially.
@@ -2935,8 +2935,8 @@ directories and subdirectories.
@item ?
Matches any single character.
@item [@dots{}]
Matches any one of the enclosed characters. A pair of characters
separated by a hyphen denotes a @var{range expression};
Matches any one of the enclosed characters.
A pair of characters separated by a hyphen denotes a @var{range expression};
any character that falls between those two characters, inclusive,
using the current locale's collating sequence and character set,
is matched. If the first character following the
@@ -3548,9 +3548,14 @@ commands that are invoked as part of a pipeline are also executed
in a subshell environment. Changes made to the subshell environment
cannot affect the shell's execution environment.
Subshells spawned to execute command substitutions inherit the value of
the @option{-e} option from the parent shell. When not in @sc{posix} mode,
Bash clears the @option{-e} option in such subshells.
When the shell is in @sc{posix} mode,
subshells spawned to execute command substitutions inherit the value of
the @option{-e} option from the parent shell.
When not in @sc{posix} mode,
Bash clears the @option{-e} option in such subshells
See the description of the @code{inherit_errexit} shell option
(@pxref{Bash Builtins}) for how to control this behavior when not
in @sc{posix} mode.
If a command is followed by a @samp{&} and job control is not active, the
default standard input for the command is the empty file @file{/dev/null}.
@@ -3894,8 +3899,8 @@ Change the current working directory to @var{directory}.
If @var{directory} is not supplied, the value of the @env{HOME}
shell variable is used.
If the shell variable
@env{CDPATH} exists, it is used as a search path:
each directory name in @env{CDPATH} is searched for
@env{CDPATH} exists, @code{cd} uses it as a search path:
{cd} searches each directory name in @env{CDPATH} for
@var{directory}, with alternative directory names in @env{CDPATH}
separated by a colon (@samp{:}).
If @var{directory} begins with a slash, @env{CDPATH} is not used.
@@ -4067,17 +4072,19 @@ If the variable @env{OPTERR}
is set to 0, no error messages will be displayed, even if the first
character of @code{optstring} is not a colon.
If an invalid option is seen,
@code{getopts} places @samp{?} into @var{name} and, if not silent,
If @code{getopts} detects an invalid option, it
places @samp{?} into @var{name} and, if not silent,
prints an error message and unsets @env{OPTARG}.
If @code{getopts} is silent, the option character found is placed in
@env{OPTARG} and no diagnostic message is printed.
If @code{getopts} is silent, it assigns the option character found
to @env{OPTARG} and does not print a diagnostic message.
If a required argument is not found, and @code{getopts}
is not silent, a question mark (@samp{?}) is placed in @var{name},
@code{OPTARG} is unset, and a diagnostic message is printed.
If @code{getopts} is silent, then a colon (@samp{:}) is placed in
@var{name} and @env{OPTARG} is set to the option character found.
If a required argument is not found,
and @code{getopts} is not silent,
it sets the value of @var{name} to a question mark (@samp{?}),
unsets @code{OPTARG}, and prints a diagnostic message.
If @code{getopts} is silent,
it sets the value of @var{name} to a colon (@samp{:}),
and sets @env{OPTARG} to the option character found.
@item hash
@btindex hash
@@ -5186,6 +5193,9 @@ The exit status is greater than 128 if the timeout is exceeded.
Read input from file descriptor @var{fd}.
@end table
Other than the case where @var{delim} is the empty string, @code{read}
ignores any NUL characters in the input.
If no @var{name}s are supplied, the line read,
without the ending delimiter but otherwise unmodified,
is assigned to the
@@ -6352,7 +6362,7 @@ level is set to the default for the current version.
If @env{BASH_COMPAT} is set to a value that is not one of the valid
compatibility levels, the shell prints an error message and sets the
compatibility level to the default for the current version.
The valid values correspond to the compatibility levels
A subset of the valid values correspond to the compatibility levels
described below (@pxref{Shell Compatibility Mode}).
For example, 4.2 and 42 are valid values that correspond
to the @code{compat42} @code{shopt} option
@@ -6442,7 +6452,7 @@ The patch level.
The build version.
@item BASH_VERSINFO[4]
The release status (e.g., @code{beta1}).
The release status (e.g., @code{beta}).
@item BASH_VERSINFO[5]
The value of @env{MACHTYPE}.
@@ -6785,7 +6795,7 @@ The shell sets the default value to 500 after reading any startup files.
@item HISTTIMEFORMAT
If this variable is set and not null, its value is used as a format string
for @code{strftime} to print the time stamp associated with each history
for @code{strftime}(3) to print the time stamp associated with each history
entry displayed by the @code{history} builtin.
If this variable is set, time stamps are written to the history file so
they may be preserved across shell sessions.
@@ -7038,7 +7048,7 @@ The @samp{%} character introduces an
escape sequence that is expanded to a time value or other
information.
The escape sequences and their meanings are as
follows; the braces denote optional portions.
follows; the brackets denote optional portions.
@table @code
@@ -7862,7 +7872,8 @@ rules above.
@dfn{Aliases} allow a string to be substituted for a word that is in
a position in the input where it can be the first word of a simple
command. Aliases have names and corresponding values that are set
command.
Aliases have names and corresponding values that are set
and unset using the @code{alias} and @code{unalias} builtin commands
(@pxref{Shell Builtin Commands}).
@@ -9111,7 +9122,7 @@ terminal's; such processes are immune to keyboard-generated
signals. Only foreground processes are allowed to read from or, if
the user so specifies with @code{stty tostop}, write to the terminal.
Background processes which attempt to
read from (write to when @code{stty tostop} is in effect) the
read from (write to when @code{tostop} is in effect) the
terminal are sent a @code{SIGTTIN} (@code{SIGTTOU})
signal by the kernel's terminal driver,
which, unless caught, suspends the process.
+4 -4
View File
@@ -1,11 +1,11 @@
@ignore
Copyright (C) 1988-2023 Free Software Foundation, Inc.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Thu Dec 21 12:07:50 EST 2023
@set LASTCHANGE Mon Jan 15 13:13:50 EST 2024
@set EDITION 5.3
@set VERSION 5.3
@set UPDATED 21 December 2023
@set UPDATED-MONTH December 2023
@set UPDATED 15 January 2024
@set UPDATED-MONTH January 2024
+6 -2
View File
@@ -1355,6 +1355,7 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
int low; /* Count of max-matched characters. */
int lx;
char *dtext; /* dequoted TEXT, if needed */
size_t len1, len2;
#if defined (HANDLE_MULTIBYTE)
int v;
size_t v1, v2;
@@ -1381,6 +1382,9 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
memset (&ps2, 0, sizeof (mbstate_t));
}
#endif
len1 = strlen (match_list[i]);
len2 = strlen (match_list[i + 1]);
for (si = 0; (c1 = match_list[i][si]) && (c2 = match_list[i + 1][si]); si++)
{
if (_rl_completion_case_fold)
@@ -1391,8 +1395,8 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
v1 = MBRTOWC (&wc1, match_list[i]+si, strlen (match_list[i]+si), &ps1);
v2 = MBRTOWC (&wc2, match_list[i+1]+si, strlen (match_list[i+1]+si), &ps2);
v1 = MBRTOWC (&wc1, match_list[i]+si, len1 - si, &ps1);
v2 = MBRTOWC (&wc2, match_list[i+1]+si, len2 - si, &ps2);
if (MB_INVALIDCH (v1) || MB_INVALIDCH (v2))
{
if (c1 != c2) /* do byte comparison */
+13 -6
View File
@@ -6,15 +6,22 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Thu Dec 14 15:42:44 EST 2023
.\" Last Change: Thu Jan 18 11:05:09 EST 2024
.\"
.TH HISTORY 3 "2023 December 14" "GNU History 8.3"
.TH HISTORY 3 "2023 January 18" "GNU History 8.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
.\"
.de FN
\fI\|\\$1\|\fP
\%\fI\|\\$1\|\fP
..
.de Q
.ie \n(.g \(lq\\$1\(rq\\$2
.el \{
. if t ``\\$1''\\$2
. if n "\\$1"\\$2
.\}
..
.ds lp \fR\|(\fP
.ds rp \fR\|)\fP
@@ -40,8 +47,8 @@
.SH NAME
history \- GNU History Library
.SH COPYRIGHT
.if t The GNU History Library is Copyright \(co 1989-2023 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2023 by the Free Software Foundation, Inc.
.if t The GNU History Library is Copyright \(co 1989-2024 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2024 by the Free Software Foundation, Inc.
.SH DESCRIPTION
Many programs read input from the user a line at a time. The GNU
History library is able to keep track of those lines, associate arbitrary
@@ -136,7 +143,7 @@ Quick substitution. Repeat the last command, replacing
with
.IR string2 .
Equivalent to
``!!:s\d\s+2\(ha\s-2\u\fIstring1\fP\d\s+2\(ha\s-2\u\fIstring2\fP\d\s+2\(ha\s-2\u''
.Q !!:s\d\s+2\(ha\s-2\u\fIstring1\fP\d\s+2\(ha\s-2\u\fIstring2\fP\d\s+2\(ha\s-2\u
(see \fBModifiers\fP below).
.TP
.B !#
+1 -1
View File
@@ -193,7 +193,7 @@ With no options, display the history list with line numbers.
Lines prefixed with a @samp{*} have been modified.
An argument of @var{n} lists only the last @var{n} lines.
If the shell variable @env{HISTTIMEFORMAT} is set and not null,
it is used as a format string for @var{strftime} to display
it is used as a format string for @code{strftime}(3) to display
the time stamp associated with each displayed history entry.
No intervening blank is printed between the formatted time stamp
and the history line.
+47 -31
View File
@@ -6,15 +6,22 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Fri Jan 5 11:02:00 EST 2024
.\" Last Change: Thu Jan 18 11:05:44 EST 2024
.\"
.TH READLINE 3 "2024 January 5" "GNU Readline 8.3"
.TH READLINE 3 "2024 January 18" "GNU Readline 8.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
.\"
.de FN
\fI\|\\$1\|\fP
\%\fI\|\\$1\|\fP
..
.de Q
.ie \n(.g \(lq\\$1\(rq\\$2
.el \{
. if t ``\\$1''\\$2
. if n "\\$1"\\$2
.\}
..
.SH NAME
readline \- get a line from a user with editing
@@ -141,7 +148,7 @@ or
.RS
C\-Meta\-u: universal\-argument
.RE
.sp
.LP
into the
.I inputrc
would make M\-C\-u execute the readline command
@@ -179,7 +186,7 @@ whitespace between the name and the colon.
When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP,
.I keyname
is the name of a key spelled out in English. For example:
.sp
.PP
.RS
Control\-u: universal\-argument
.br
@@ -199,8 +206,7 @@ and
.I C\-o
is bound to run the macro
expressed on the right hand side (that is, to insert the text
.if t \f(CW> output\fP
.if n ``> output''
.Q "> output"
into the line).
.PP
In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
@@ -212,7 +218,7 @@ an entire key sequence may be specified by placing the sequence
within double quotes. Some GNU Emacs style key escapes can be
used, as in the following example, but the symbolic character names
are not recognized.
.sp
.PP
.RS
"\eC\-u": universal\-argument
.br
@@ -231,8 +237,7 @@ is bound to the function
and
.I "ESC [ 1 1 \(ti"
is bound to insert the text
.if t \f(CWFunction Key 1\fP.
.if n ``Function Key 1''.
.Q "Function Key 1" .
.PP
The full set of GNU Emacs style escape sequences available when specifying
key sequences is
@@ -352,19 +357,24 @@ It is output to the terminal before displaying the text in the active region.
This variable is reset to the default value whenever the terminal type changes.
The default value is the string that puts the terminal in standout mode,
as obtained from the terminal's terminfo description.
A sample value might be \f(CW"\ee[01;33m"\fP.
A sample value might be
.Q "\ee[01;33m" .
.TP
.B active\-region\-end\-color
A string variable that "undoes" the effects of \fBactive\-region\-start\-color\fP
and restores "normal" terminal display appearance after displaying text
in the active region.
A string variable that
.Q undoes
the effects of \fBactive\-region\-start\-color\fP
and restores
.Q normal
terminal display appearance after displaying text in the active region.
This string must not take up any physical character positions on the display,
so it should consist only of terminal escape sequences.
It is output to the terminal after displaying the text in the active region.
This variable is reset to the default value whenever the terminal type changes.
The default value is the string that restores the terminal from standout mode,
as obtained from the terminal's terminfo description.
A sample value might be \f(CW"\ee[0m\fP".
A sample value might be
.Q "\ee[0m" .
.TP
.B bell\-style (audible)
Controls what happens when readline wants to ring the terminal bell.
@@ -378,7 +388,9 @@ characters that are
treated specially by the kernel's terminal driver to their
readline equivalents.
These override the default readline bindings described here.
Type \f(CWstty -a\fP at a bash prompt to see your current terminal settings,
Type
.Q "stty -a"
at a \fBbash\fP prompt to see your current terminal settings,
including the special control characters (usually \fBcchars\fP).
.TP
.B blink\-matching\-paren (Off)
@@ -391,7 +403,8 @@ common prefix of the set of possible completions using a different color.
The color definitions are taken from the value of the \fBLS_COLORS\fP
environment variable.
If there is a color definition in \fB$LS_COLORS\fP for the custom suffix
"readline-colored-completion-prefix", readline uses this color for
.Q readline-colored-completion-prefix ,
readline uses this color for
the common prefix instead of its default.
.TP
.B colored\-stats (Off)
@@ -752,7 +765,7 @@ file can test for a particular value.
This could be used to bind key sequences to functions useful for
a specific program. For instance, the following command adds a
key sequence that quotes the current or previous word in \fBbash\fP:
.sp 1
.PP
.RS
.nf
\fB$if\fP Bash
@@ -781,8 +794,8 @@ the test fails.
This directive takes a single filename as an argument and reads commands
and bindings from that file. For example, the following directive
would read \fI/etc/inputrc\fP:
.sp 1
.RS
.PP
.nf
\fB$include\fP \^ \fI/etc/inputrc\fP
.fi
@@ -977,7 +990,9 @@ insert the \fIn\fPth word from the previous command (the words
in the previous command begin with word 0). A negative argument
inserts the \fIn\fPth word from the end of the previous command.
Once the argument \fIn\fP is computed, the argument is extracted
as if the "!\fIn\fP" history expansion had been specified.
as if the
.Q !\fIn\fP
history expansion had been specified.
.TP
.B
yank\-last\-arg (M\-.\^, M\-_\^)
@@ -991,15 +1006,16 @@ Any numeric argument supplied to these successive calls determines
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.
as if the
.Q !$
history expansion had been specified.
.PD
.SS Commands for Changing Text
.PD 0
.TP
.B \fIend\-of\-file\fP (usually C\-d)
The character indicating end-of-file as set, for example, by
.if t \f(CWstty\fP.
.if n ``stty''.
.IR stty (1).
If this character is read when there are no characters
on the line, and point is at the beginning of the line, readline
interprets it as the end of input and returns
@@ -1280,7 +1296,9 @@ character. A negative argument searches for subsequent occurrences.
Read enough characters to consume a multi-key sequence such as those
defined for keys like Home and End. Such sequences begin with a
Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is
bound to "\e[", keys producing such sequences will have no effect
bound to
.Q \e[ ,
keys producing such sequences will have no effect
unless explicitly bound to a readline command, instead of inserting
stray characters into the editing buffer. This is unbound by default,
but usually bound to ESC\-[.
@@ -1363,7 +1381,7 @@ variable).
.ta 2.5i
.sp
Emacs Standard bindings
.sp
.PP
"C-@" set-mark
"C-A" beginning-of-line
"C-B" backward-char
@@ -1395,7 +1413,7 @@ Emacs Standard bindings
"C-?" backward-delete-char
.PP
Emacs Meta bindings
.sp
.PP
"M-C-G" abort
"M-C-H" backward-kill-word
"M-C-I" tab-insert
@@ -1443,7 +1461,7 @@ Emacs Meta bindings
"M-_" yank-last-arg
.PP
Emacs Control-X bindings
.sp
.PP
"C-XC-G" abort
"C-XC-R" re-read-init-file
"C-XC-U" undo
@@ -1452,16 +1470,14 @@ Emacs Control-X bindings
"C-X)" end-kbd-macro
"C-XE" call-last-kbd-macro
"C-XC-?" backward-kill-line
.sp
.RE
.SS VI Mode bindings
.RS +.6i
.nf
.ta 2.5i
.sp
.PP
VI Insert Mode functions
.sp
.PP
"C-D" vi-eof-maybe
"C-H" backward-delete-char
"C-I" complete
@@ -1482,7 +1498,7 @@ VI Insert Mode functions
"C-?" backward-delete-char
.PP
VI Command Mode functions
.sp
.PP
"C-D" vi-eof-maybe
"C-E" emacs-editing-mode
"C-G" abort
+16 -12
View File
@@ -323,13 +323,14 @@ the line, thereby executing the command from the history list.
A movement command will terminate the search, make the last line found
the current line, and begin editing.
Readline remembers the last incremental search string. If two
@kbd{C-r}s are typed without any intervening characters defining a new
search string, any remembered search string is used.
Readline remembers the last incremental search string.
If two @kbd{C-r}s are typed without any intervening characters defining
a new search string, Readline uses any remembered search string.
Non-incremental searches read the entire search string before starting
to search for matching history lines. The search string may be
typed by the user or be part of the contents of the current line.
to search for matching history lines.
The search string may be typed by the user or be part of the contents of
the current line.
@node Readline Init File
@section Readline Init File
@@ -2502,9 +2503,11 @@ complete -o filenames -o nospace -o bashdefault -F _comp_cd cd
@noindent
Since we'd like Bash and Readline to take care of some
of the other details for us, we use several other options to tell Bash
and Readline what to do. The @option{-o filenames} option tells Readline
and Readline what to do.
The @option{-o filenames} option tells Readline
that the possible completions should be treated as filenames, and quoted
appropriately. That option will also cause Readline to append a slash to
appropriately.
That option will also cause Readline to append a slash to
filenames it can determine are directories (which is why we might want to
extend @code{_comp_cd} to append a slash if we're using directories found
via @var{CDPATH}: Readline can't tell those completions are directories).
@@ -2512,9 +2515,10 @@ The @option{-o nospace} option tells Readline to not append a space
character to the directory name, in case we want to append to it.
The @option{-o bashdefault} option brings in the rest of the "Bash default"
completions -- possible completions that Bash adds to the default Readline
set. These include things like command name completion, variable completion
for words beginning with @samp{$} or @samp{$@{}, completions containing pathname
expansion patterns (@pxref{Filename Expansion}), and so on.
set.
These include things like command name completion, variable completion
for words beginning with @samp{$} or @samp{$@{}, completions containing
pathname expansion patterns (@pxref{Filename Expansion}), and so on.
Once installed using @code{complete}, @code{_comp_cd} will be called every
time we attempt word completion for a @code{cd} command.
@@ -2523,8 +2527,8 @@ Many more examples -- an extensive collection of completions for most of
the common GNU, Unix, and Linux commands -- are available as part of the
bash_completion project. This is installed by default on many GNU/Linux
distributions. Originally written by Ian Macdonald, the project now lives
at @url{https://github.com/scop/bash-completion/}. There are ports for
other systems such as Solaris and Mac OS X.
at @url{https://github.com/scop/bash-completion/}.
There are ports for other systems such as Solaris and Mac OS X.
An older version of the bash_completion package is distributed with bash
in the @file{examples/complete} subdirectory.
+2 -2
View File
@@ -5,7 +5,7 @@ Copyright (C) 1988-2024 Free Software Foundation, Inc.
@set EDITION 8.3
@set VERSION 8.3
@set UPDATED 5 January 2024
@set UPDATED 19 January 2024
@set UPDATED-MONTH January 2024
@set LASTCHANGE Fri Jan 5 11:01:44 EST 2024
@set LASTCHANGE Fri Jan 19 11:01:44 EST 2024
+7 -1
View File
@@ -1470,6 +1470,12 @@ timespec: TIME
# define expanding_alias() 0
#endif
#if defined (DPAREN_ARITHMETIC)
# define parsing_dparen() (pushed_string_list && (pushed_string_list->flags & PSH_DPAREN))
#else
# define parsing_dparen() 0
#endif
/* Global var is non-zero when end of file has been reached. */
int EOF_Reached = 0;
@@ -6965,7 +6971,7 @@ parse_compound_assignment (size_t *retlenp)
/* We're not pushing any new input here, we're reading from the current input
source. If that's an alias, we have to be prepared for the alias to get
popped out from underneath us. */
ss = (ea = expanding_alias ()) ? pushed_string_list : (STRING_SAVER *)NULL;
ss = (ea = (expanding_alias () || parsing_dparen ())) ? pushed_string_list : (STRING_SAVER *)NULL;
restore_pushed_strings = 0;
while ((tok = read_token (READ)) != ')')
+5 -5
View File
@@ -391,7 +391,10 @@ binary_test (char *op, char *arg1, char *arg2, int flags)
else if ((op[0] == '>' || op[0] == '<') && op[1] == '\0')
{
#if defined (HAVE_STRCOLL)
if (shell_compatibility_level > 40 && (flags & TEST_LOCALE))
/* POSIX interp 375 */
if (posixly_correct && (flags & TEST_LOCALE))
return ((op[0] == '>') ? (strcoll (arg1, arg2) > 0) : (strcoll (arg1, arg2) < 0));
else if (shell_compatibility_level > 40 && (flags & TEST_LOCALE))
return ((op[0] == '>') ? (strcoll (arg1, arg2) > 0) : (strcoll (arg1, arg2) < 0));
else
#endif
@@ -443,11 +446,8 @@ binary_operator (void)
((w[0] == '>' || w[0] == '<') && w[1] == '\0') || /* <, > */
(w[0] == '!' && w[1] == '=' && w[2] == '\0')) /* != */
{
#if 1 /* POSIX interp 375 11/9/2022 */
/* POSIX interp 375 11/9/2022 */
value = binary_test (w, argv[pos], argv[pos + 2], (posixly_correct ? TEST_LOCALE : 0));
#else
value = binary_test (w, argv[pos], argv[pos + 2], 0);
#endif
pos += 3;
return (value);
}