From e225d5a981b8102f9a5eda28861a19af7195def2 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Sat, 3 Dec 2011 13:52:14 -0500 Subject: [PATCH] commit bash-20051013 snapshot --- CWRU/CWRU.chlog | 48 +++ CWRU/CWRU.chlog~ | 49 ++- builtins/fc.def | 2 +- doc/bash.0 | 4 +- doc/bash.1 | 6 +- doc/bash.html | 182 +++++----- doc/bash.ps | 12 +- doc/builtins.ps | 2 +- doc/rbash.ps | 2 +- jobs.c | 5 +- lib/glob/sm_loop.c | 13 +- lib/glob/sm_loop.c~ | 754 ++++++++++++++++++++++++++++++++++++++++ lib/readline/bind.c | 22 +- lib/readline/bind.c~ | 34 +- lib/readline/readline.h | 1 + lib/readline/undo.c | 5 + lib/readline/vi_mode.c | 9 + redir.c | 11 + redir.h | 2 + subst.c | 3 +- support/man2html.c | 63 +++- tests/RUN-ONE-TEST | 2 +- tests/redir7.sub | 2 + 23 files changed, 1090 insertions(+), 143 deletions(-) create mode 100644 lib/glob/sm_loop.c~ diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 99213cbf1..55b450171 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -12216,3 +12216,51 @@ bashline.c - in command_word_completion_function, use rl_variable_value to decide whether or not we should ignore case, and use strncasecmp instead of strncmp where appropriate + + 10/11 + ----- +builtins/fc.def + - fixed a typo when using POSIX_FC_EDIT_COMMAND + +redir.h + - new flag values for redirections: RX_INTERNAL and RX_USER (currently + unused) + +redir.c + - add_undo_redirect and add_undo_close_redirect now set RX_INTERNAL + flag when making new redirects + - in do_redirection_internal, only set file descriptors > 2 to CLEXEC + if they're marked as RX_INTERNAL + + 10/12 + ----- +jobs.c + - in wait_for_single_pid, if in posix mode, remove the waited-for pid + from the list of background pids, forgetting it entirely. POSIX + conformance tests test for this. + +lib/readline/{readline.h,vi_mode.c} + - new state flag, RL_STATE_VICMDONCE, set after entering vi command + mode the first time; reset on each call to readline() + + 10/13 + ----- +lib/readline/undo.c + - in rl_revert_line, make sure that revert-line in vi mode leaves + rl_point set to 0 no matter the state of the line buffer + +lib/readline/vi_mode.c + - when entering vi_command mode for the first time, free any existing + undo list so the previous insertions won't be undone by the `U' + command. This is how POSIX.2 says `U' should work (and the test + suite tests for it) + +lib/readline/bind.c + - change rl_parse_and_bind so only `set' commands involving boolean + readline variables have trailing whitespace stripped from the value + string + + 10/16 + ----- +lib/glob/sm_loop.c + - fix patscan() to correctly scan backslash-escaped characters diff --git a/CWRU/CWRU.chlog~ b/CWRU/CWRU.chlog~ index e53aed1d4..1587a9fbf 100644 --- a/CWRU/CWRU.chlog~ +++ b/CWRU/CWRU.chlog~ @@ -12211,4 +12211,51 @@ bashline.c rl_completion_found_quote, but doesn't set rl_completion_quote_character, we have an embedded quoted string or backslash-escaped character in the passed text. We need to dequote that before calling - filename_completion_function + filename_completion_function. So far, this is in place only for + absolute program names (those containing a `/') + - in command_word_completion_function, use rl_variable_value to decide + whether or not we should ignore case, and use strncasecmp instead of + strncmp where appropriate + + 10/11 + ----- +builtins/fc.def + - fixed a typo when using POSIX_FC_EDIT_COMMAND + +redir.h + - new flag values for redirections: RX_INTERNAL and RX_USER (currently + unused) + +redir.c + - add_undo_redirect and add_undo_close_redirect now set RX_INTERNAL + flag when making new redirects + - in do_redirection_internal, only set file descriptors > 2 to CLEXEC + if they're marked as RX_INTERNAL + + 10/12 + ----- +jobs.c + - in wait_for_single_pid, if in posix mode, remove the waited-for pid + from the list of background pids, forgetting it entirely. POSIX + conformance tests test for this. + +lib/readline/{readline.h,vi_mode.c} + - new state flag, RL_STATE_VICMDONCE, set after entering vi command + mode the first time; reset on each call to readline() + + 10/13 + ----- +lib/readline/undo.c + - in rl_revert_line, make sure that revert-line in vi mode leaves + rl_point set to 0 no matter the state of the line buffer + +lib/readline/vi_mode.c + - when entering vi_command mode for the first time, free any existing + undo list so the previous insertions won't be undone by the `U' + command. This is how POSIX.2 says `U' should work (and the test + suite tests for it) + +lib/readline/bind.c + - change rl_parse_and_bind so only `set' commands involving boolean + readline variables have trailing whitespace stripped from the value + string diff --git a/builtins/fc.def b/builtins/fc.def index 7e2da01fd..ebe368326 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -383,7 +383,7 @@ fc_builtin (list) { fcedit = posixly_correct ? POSIX_FC_EDIT_COMMAND : FC_EDIT_COMMAND; command = (char *)xmalloc (3 + strlen (fcedit) + strlen (fn)); - sprintf (command, "%s %s", FC_EDIT_COMMAND, fn); + sprintf (command, "%s %s", fcedit, fn); } retval = parse_and_execute (command, "fc", SEVAL_NOHIST); if (retval != EXECUTION_SUCCESS) diff --git a/doc/bash.0 b/doc/bash.0 index aaf441e69..ecf8ae2e8 100644 --- a/doc/bash.0 +++ b/doc/bash.0 @@ -4818,7 +4818,7 @@ AAUUTTHHOORRSS bfox@gnu.org Chet Ramey, Case Western Reserve University - chet@po.CWRU.Edu + chet@po.cwru.edu BBUUGG RREEPPOORRTTSS If you find a bug in bbaasshh,, you should report it. But first, you should @@ -4844,7 +4844,7 @@ BBUUGG RREEPPOORRTTSS it provides for filing a bug report. Comments and bug reports concerning this manual page should be directed - to _c_h_e_t_@_p_o_._C_W_R_U_._E_d_u. + to _c_h_e_t_@_p_o_._c_w_r_u_._e_d_u. BBUUGGSS It's too big and too slow. diff --git a/doc/bash.1 b/doc/bash.1 index 86a5e676b..40e1fbd3e 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -4,7 +4,7 @@ .\" Chet Ramey .\" Information Network Services .\" Case Western Reserve University -.\" chet@po.CWRU.Edu +.\" chet@po.cwru.edu .\" .\" Last Change: Sat Aug 27 13:28:44 EDT 2005 .\" @@ -8788,7 +8788,7 @@ bfox@gnu.org .PP Chet Ramey, Case Western Reserve University .br -chet@po.CWRU.Edu +chet@po.cwru.edu .SH BUG REPORTS If you find a bug in .B bash, @@ -8829,7 +8829,7 @@ it provides for filing a bug report. .PP Comments and bug reports concerning this manual page should be directed to -.IR chet@po.CWRU.Edu . +.IR chet@po.cwru.edu . .SH BUGS .PP It's too big and too slow. diff --git a/doc/bash.html b/doc/bash.html index 5004b56cd..9c69fcc42 100644 --- a/doc/bash.html +++ b/doc/bash.html @@ -2,7 +2,9 @@ BASH(1) Manual Page - +
BASH(1)2005 Aug 27BASH(1) +
BASH(1)2005 Aug 27BASH(1) +

Index
@@ -26,23 +28,23 @@   -

NAME

+

NAME

bash - GNU Bourne-Again SHell   -

SYNOPSIS

+

SYNOPSIS

bash [options] [file]   -

COPYRIGHT

+

COPYRIGHT

Bash is Copyright © 1989-2005 by the Free Software Foundation, Inc.   -

DESCRIPTION

+

DESCRIPTION

Bash @@ -62,7 +64,7 @@ POSIX Shell and Tools specification (IEEE Working Group 1003.2). can be configured to be POSIX-conformant by default.   -

OPTIONS

+

OPTIONS

In addition to the single-character shell options documented in the description of the set builtin command, bash @@ -297,7 +299,7 @@ on the standard output and exit successfully.   -

ARGUMENTS

+

ARGUMENTS

If arguments remain after option processing, and neither the -c @@ -328,7 +330,7 @@ if no file is found, then the shell searches the directories in for the script.   -

INVOCATION

+

INVOCATION

A login shell is one whose first character of argument zero is a -, @@ -559,7 +561,7 @@ and the effective user id is set to the real user id. If the -p option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset.   -

DEFINITIONS

+

DEFINITIONS

@@ -621,7 +623,7 @@ symbols:   -

RESERVED WORDS

+

RESERVED WORDS

Reserved words are words that have a special meaning to the shell. The following words are recognized as reserved when unquoted and either @@ -648,10 +650,10 @@ command:   -

SHELL GRAMMAR

+

SHELL GRAMMAR

  -

Simple Commands

+

Simple Commands

@@ -667,7 +669,7 @@ The return value of a simple command is its exit status, or n.   -

Pipelines

+

Pipelines

@@ -737,7 +739,7 @@ below. Each command in a pipeline is executed as a separate process (i.e., in a subshell).   -

Lists

+

Lists

@@ -838,7 +840,7 @@ returns a non-zero exit status. The return status of AND and OR lists is the exit status of the last command executed in the list.   -

Compound Commands

+

Compound Commands

@@ -1093,7 +1095,7 @@ of the last do list command executed, or zero if none was executed.   -

Shell Function Definitions

+

Shell Function Definitions

@@ -1129,7 +1131,7 @@ last command executed in the body. (See below.)   -

COMMENTS

+

COMMENTS

In a non-interactive shell, or an interactive shell in which the interactive_comments @@ -1153,7 +1155,7 @@ option enabled does not allow comments. The option is on by default in interactive shells.   -

QUOTING

+

QUOTING

Quoting is used to remove the special meaning of certain characters or words to the shell. Quoting can be used to @@ -1334,7 +1336,7 @@ is ignored. If the string is translated and replaced, the replacement is double-quoted.   -

PARAMETERS

+

PARAMETERS

A parameter @@ -1449,7 +1451,7 @@ appended to the array beginning at one greater than the array's maximum index. When applied to a string-valued variable, value is expanded and appended to the variable's value.   -

Positional Parameters

+

Positional Parameters

@@ -1478,7 +1480,7 @@ digit is expanded, it must be enclosed in braces (see below).   -

Special Parameters

+

Special Parameters

@@ -1601,7 +1603,7 @@ currently being checked.   -

Shell Variables

+

Shell Variables

@@ -2627,7 +2629,7 @@ parser to treat the rest of the line as a comment.   -

Arrays

+

Arrays

Bash @@ -2749,7 +2751,7 @@ and builtins display array values in a way that allows them to be reused as assignments.   -

EXPANSION

+

EXPANSION

Expansion is performed on the command line after it has been split into words. There are seven kinds of expansion performed: @@ -2791,7 +2793,7 @@ as explained above (see   -

Brace Expansion

+

Brace Expansion

@@ -2906,7 +2908,7 @@ command (see below).   -

Tilde Expansion

+

Tilde Expansion

@@ -2977,7 +2979,7 @@ and and the shell assigns the expanded value.   -

Parameter Expansion

+

Parameter Expansion

@@ -3268,7 +3270,7 @@ the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.   -

Command Substitution

+

Command Substitution

@@ -3322,7 +3324,7 @@ escape the inner backquotes with backslashes. If the substitution appears within double quotes, word splitting and pathname expansion are not performed on the results.   -

Arithmetic Expansion

+

Arithmetic Expansion

@@ -3358,7 +3360,7 @@ is invalid, prints a message indicating failure and no substitution occurs.   -

Process Substitution

+

Process Substitution

@@ -3382,7 +3384,7 @@ simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion.   -

Word Splitting

+

Word Splitting

@@ -3471,7 +3473,7 @@ null argument results and is retained. Note that if no expansion occurs, no splitting is performed.   -

Pathname Expansion

+

Pathname Expansion

@@ -3746,7 +3748,7 @@ Matches anything except one of the given patterns   -

Quote Removal

+

Quote Removal

@@ -3759,7 +3761,7 @@ characters and " that did not result from one of the above expansions are removed.   -

REDIRECTION

+

REDIRECTION

Before a command is executed, its input and output may be @@ -3878,7 +3880,7 @@ Redirections using file descriptors greater than 9 should be used with care, as they may conflict with file descriptors the shell uses internally.   -

Redirecting Input

+

Redirecting Input

@@ -3903,7 +3905,7 @@ The general format for redirecting input is:   -

Redirecting Output

+

Redirecting Output

@@ -3957,7 +3959,7 @@ option to the builtin command is not enabled, the redirection is attempted even if the file named by word exists.   -

Appending Redirected Output

+

Appending Redirected Output

@@ -3985,7 +3987,7 @@ The general format for appending output is:

  -

Redirecting Standard Output and Standard Error

+

Redirecting Standard Output and Standard Error

@@ -4025,7 +4027,7 @@ This is semantically equivalent to   -

Here Documents

+

Here Documents

@@ -4097,7 +4099,7 @@ This allows here-documents within shell scripts to be indented in a natural fashion.   -

Here Strings

+

Here Strings

A variant of here documents, the format is:
@@ -4114,7 +4116,7 @@ A variant of here documents, the format is: The word is expanded and supplied to the command on its standard input.   -

Duplicating File Descriptors

+

Duplicating File Descriptors

@@ -4175,7 +4177,7 @@ As a special case, if n is omitted, and word does not expand to one or more digits, the standard output and standard error are redirected as described previously.   -

Moving File Descriptors

+

Moving File Descriptors

@@ -4209,7 +4211,7 @@ moves the file descriptor digit to file descriptor or the standard output (file descriptor 1) if n is not specified.   -

Opening File Descriptors for Reading and Writing

+

Opening File Descriptors for Reading and Writing

@@ -4233,7 +4235,7 @@ or on file descriptor 0 if is not specified. If the file does not exist, it is created.   -

ALIASES

+

ALIASES

Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. @@ -4335,7 +4337,7 @@ in compound commands. For almost every purpose, aliases are superseded by shell functions.   -

FUNCTIONS

+

FUNCTIONS

A shell function, defined as described above under SHELL GRAMMAR, @@ -4449,7 +4451,7 @@ Care should be taken in cases where this may cause a problem. Functions may be recursive. No limit is imposed on the number of recursive calls.   -

ARITHMETIC EVALUATION

+

ARITHMETIC EVALUATION

The shell allows arithmetic expressions to be evaluated, under certain circumstances (see the let and declare builtin @@ -4572,7 +4574,7 @@ Operators are evaluated in order of precedence. Sub-expressions in parentheses are evaluated first and may override the precedence rules above.   -

CONDITIONAL EXPRESSIONS

+

CONDITIONAL EXPRESSIONS

Conditional expressions are used by the [[ compound command and the test and [ builtin commands to test file attributes @@ -4757,7 +4759,7 @@ may be positive or negative integers.
  -

SIMPLE COMMAND EXPANSION

+

SIMPLE COMMAND EXPANSION

When a simple command is executed, the shell performs the following expansions, assignments, and redirections, from left to right. @@ -4801,7 +4803,7 @@ contained a command substitution, the exit status of the command is the exit status of the last command substitution performed. If there were no command substitutions, the command exits with a status of zero.   -

COMMAND EXECUTION

+

COMMAND EXECUTION

After a command has been split into words, if it results in a simple command and an optional list of arguments, the following @@ -4882,7 +4884,7 @@ interpreter name on the first line of the program, followed by the name of the program, followed by the command arguments, if any.   -

COMMAND EXECUTION ENVIRONMENT

+

COMMAND EXECUTION ENVIRONMENT

The shell has an execution environment, which consists of the following: @@ -4960,7 +4962,7 @@ default standard input for the command is the empty file /dev/null. Otherwise, the invoked command inherits the file descriptors of the calling shell as modified by redirections.   -

ENVIRONMENT

+

ENVIRONMENT

When a program is invoked it is given an array of strings called the @@ -5037,7 +5039,7 @@ invokes an external command, the variable is set to the full file name of the command and passed to that command in its environment.   -

EXIT STATUS

+

EXIT STATUS

For the shell's purposes, a command which exits with a zero exit status has succeeded. An exit status of zero @@ -5066,7 +5068,7 @@ executed, unless a syntax error occurs, in which case it exits with a non-zero value. See also the exit builtin command below.   -

SIGNALS

+

SIGNALS

When bash is interactive, in the absence of any traps, it ignores SIGTERM @@ -5183,7 +5185,7 @@ builtin, the reception of a signal for which a trap has been set will cause the wait builtin to return immediately with an exit status greater than 128, immediately after which the trap is executed.   -

JOB CONTROL

+

JOB CONTROL

Job control @@ -5407,7 +5409,7 @@ If a second attempt to exit is made without an intervening command, the shell does not print another warning, and the stopped jobs are terminated.   -

PROMPTING

+

PROMPTING

When executing interactively, bash @@ -5576,7 +5578,7 @@ command under
below).   -

READLINE

+

READLINE

This is the library that handles reading input when using an interactive shell, unless the @@ -5600,7 +5602,7 @@ builtin (see
below).   -

Readline Notation

+

Readline Notation

@@ -5646,7 +5648,7 @@ accumulated into one unit, which can be yanked all at once. Commands which do not kill text separate the chunks of text on the kill ring.   -

Readline Initialization

+

Readline Initialization

@@ -5725,7 +5727,7 @@ and In addition to command names, readline allows keys to be bound to a string that is inserted when the key is pressed (a macro).   -

Readline Key Bindings

+

Readline Key Bindings

@@ -5932,7 +5934,7 @@ builtin command (see below).   -

Readline Variables

+

Readline Variables

@@ -6158,7 +6160,7 @@ completions.   -

Readline Conditional Constructs

+

Readline Conditional Constructs

@@ -6242,7 +6244,7 @@ would read /etc/inputrc:   -

Searching

+

Searching

@@ -6295,7 +6297,7 @@ 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.   -

Readline Command Names

+

Readline Command Names

@@ -6307,7 +6309,7 @@ position, and mark refers to a cursor position saved by the set-mark command. The text between the point and mark is referred to as the region.   -

Commands for Moving

+

Commands for Moving

@@ -6352,7 +6354,7 @@ Refresh the current line.   -

Commands for Manipulating the History

+

Commands for Manipulating the History

@@ -6509,7 +6511,7 @@ and emacs as the editor, in that order.   -

Commands for Changing Text

+

Commands for Changing Text

@@ -6594,7 +6596,7 @@ before point with a space. By default, this command is unbound.   -

Killing and Yanking

+

Killing and Yanking

@@ -6678,7 +6680,7 @@ or   -

Numeric Arguments

+

Numeric Arguments

@@ -6708,7 +6710,7 @@ argument count sixteen, and so on.   -

Completing

+

Completing

@@ -6827,7 +6829,7 @@ above).   -

Keyboard Macros

+

Keyboard Macros

@@ -6850,7 +6852,7 @@ in the macro appear as if typed at the keyboard.   -

Miscellaneous

+

Miscellaneous

@@ -6990,7 +6992,7 @@ Display version information about the current instance of   -

Programmable Completion

+

Programmable Completion

@@ -7164,7 +7166,7 @@ to completed names which are symbolic links to directories, subject to the value of the mark-directories readline variable, regardless of the setting of the mark-symlinked-directories readline variable.   -

HISTORY

+

HISTORY

When the -o history @@ -7300,7 +7302,7 @@ builtin below under for information on setting and unsetting shell options.   -

HISTORY EXPANSION

+

HISTORY EXPANSION

@@ -7413,7 +7415,7 @@ above under Shell Variables).   -

Event Designators

+

Event Designators

@@ -7483,7 +7485,7 @@ The entire command line typed so far.   -

Word Designators

+

Word Designators

@@ -7560,7 +7562,7 @@ Abbreviates x-$ like x*, but omits the last word. If a word designator is supplied without an event specification, the previous command is used as the event.   -

Modifiers

+

Modifiers

@@ -7665,7 +7667,7 @@ Apply the following `s' modifier once to each word in the event line.   -

SHELL BUILTIN COMMANDS

+

SHELL BUILTIN COMMANDS

@@ -11127,7 +11129,7 @@ process or job waited for.   -

RESTRICTED SHELL

+

RESTRICTED SHELL

@@ -11241,7 +11243,7 @@ script.   -

SEE ALSO

+

SEE ALSO

@@ -11255,7 +11257,7 @@ script.
  -

FILES

+

FILES

@@ -11292,7 +11294,7 @@ Individual readline initialization file
  -

AUTHORS

+

AUTHORS

Brian Fox, Free Software Foundation
@@ -11303,9 +11305,9 @@ Brian Fox, Free Software Foundation Chet Ramey, Case Western Reserve University
-chet@po.CWRU.Edu +chet@po.cwru.edu   -

BUG REPORTS

+

BUG REPORTS

If you find a bug in bash, @@ -11353,10 +11355,10 @@ it provides for filing a bug report. Comments and bug reports concerning this manual page should be directed to -chet@po.CWRU.Edu. +chet@po.cwru.edu.   -

BUGS

+

BUGS

@@ -11402,6 +11404,12 @@ Array variables may not (yet) be exported. +


+ + + +
GNU Bash-3.1-beta12005 Aug 27BASH(1) +

 

Index

@@ -11503,6 +11511,6 @@ Array variables may not (yet) be exported.

This document was created by man2html from bash.1.
-Time: 03 October 2005 15:07:47 EDT +Time: 12 October 2005 16:46:47 EDT diff --git a/doc/bash.ps b/doc/bash.ps index 3e4f9fbe9..0615c0da7 100644 --- a/doc/bash.ps +++ b/doc/bash.ps @@ -1,6 +1,6 @@ %!PS-Adobe-3.0 %%Creator: groff version 1.19.1 -%%CreationDate: Mon Oct 3 15:05:27 2005 +%%CreationDate: Wed Oct 12 16:46:45 2005 %%DocumentNeededResources: font Times-Roman %%+ font Times-Bold %%+ font Times-Italic @@ -7377,8 +7377,8 @@ E F0(initialization \214le)2.5 E F3 -.548(AU)72 554.4 S(THORS).548 E F0 (Brian F)108 566.4 Q(ox, Free Softw)-.15 E(are F)-.1 E(oundation)-.15 E (bfox@gnu.or)108 578.4 Q(g)-.18 E(Chet Rame)108 595.2 Q 1.3 -.65(y, C) -.15 H(ase W).65 E(estern Reserv)-.8 E 2.5(eU)-.15 G(ni)-2.5 E -.15(ve) --.25 G(rsity).15 E(chet@po.CWR)108 607.2 Q(U.Edu)-.4 E F3 -.11(BU)72 624 -S 2.738(GR).11 G(EPOR)-2.738 E(TS)-.438 E F0 .567(If you \214nd a b)108 +-.25 G(rsity).15 E(chet@po.cwru.edu)108 607.2 Q F3 -.11(BU)72 624 S +2.738(GR).11 G(EPOR)-2.738 E(TS)-.438 E F0 .567(If you \214nd a b)108 636 R .568(ug in)-.2 F F1(bash,)3.068 E F0 .568(you should report it.) 3.068 F .568(But \214rst, you should mak)5.568 F 3.068(es)-.1 G .568 (ure that it really is a b)-3.068 F .568(ug, and)-.2 F 5.626 @@ -7410,9 +7410,9 @@ E(ug)-.2 E/F2 10/Times-Italic@0 SF(bashb)108.27 148.8 Q(ug)-.2 E F0 (inserts the \214rst three items automatically into the template it pro) 2.72 E(vides for \214ling a b)-.15 E(ug report.)-.2 E(Comments and b)108 165.6 Q(ug reports concerning this manual page should be directed to)-.2 -E F2 -.15(ch)2.5 G(et@po.CWR).15 E -.25(U.)-.4 G(Edu).25 E F0(.).25 E/F3 -10.95/Times-Bold@0 SF -.11(BU)72 182.4 S(GS).11 E F0(It')108 194.4 Q 2.5 -(st)-.55 G(oo big and too slo)-2.5 E -.65(w.)-.25 G 1.868 +E F2 -.15(ch)2.5 G(et@po.cwru.edu).15 E F0(.).25 E/F3 10.95/Times-Bold@0 +SF -.11(BU)72 182.4 S(GS).11 E F0(It')108 194.4 Q 2.5(st)-.55 G +(oo big and too slo)-2.5 E -.65(w.)-.25 G 1.868 (There are some subtle dif)108 211.2 R 1.868(ferences between)-.25 F F1 (bash)4.369 E F0 1.869(and traditional v)4.369 F 1.869(ersions of)-.15 F F1(sh)4.369 E F0 4.369(,m)C 1.869(ostly because of the)-4.369 F/F4 9 diff --git a/doc/builtins.ps b/doc/builtins.ps index 896eaf3ca..f56bcf833 100644 --- a/doc/builtins.ps +++ b/doc/builtins.ps @@ -1,6 +1,6 @@ %!PS-Adobe-3.0 %%Creator: groff version 1.19.1 -%%CreationDate: Mon Oct 3 15:05:28 2005 +%%CreationDate: Wed Oct 12 16:46:45 2005 %%DocumentNeededResources: font Times-Roman %%+ font Times-Bold %%+ font Times-Italic diff --git a/doc/rbash.ps b/doc/rbash.ps index 106c29747..8589fd284 100644 --- a/doc/rbash.ps +++ b/doc/rbash.ps @@ -1,6 +1,6 @@ %!PS-Adobe-3.0 %%Creator: groff version 1.19.1 -%%CreationDate: Mon Oct 3 15:05:28 2005 +%%CreationDate: Wed Oct 12 16:46:46 2005 %%DocumentNeededResources: font Times-Roman %%+ font Times-Bold %%DocumentSuppliedResources: procset grops 1.19 1 diff --git a/jobs.c b/jobs.c index f15a1bdc5..706e250f6 100644 --- a/jobs.c +++ b/jobs.c @@ -1999,7 +1999,10 @@ wait_for_single_pid (pid) /* If running in posix mode, remove the job from the jobs table immediately */ if (posixly_correct) - cleanup_dead_jobs (); + { + cleanup_dead_jobs (); + bgp_delete (pid); + } return r; } diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c index fcae4e131..6e8cf3af8 100644 --- a/lib/glob/sm_loop.c +++ b/lib/glob/sm_loop.c @@ -522,11 +522,11 @@ PATSCAN (string, end, delim) CHAR *string, *end; INT delim; { - int pnest, bnest; + int pnest, bnest, skip; INT cchar; CHAR *s, c, *bfirst; - pnest = bnest = 0; + pnest = bnest = skip = 0; cchar = 0; bfirst = NULL; @@ -534,8 +534,17 @@ PATSCAN (string, end, delim) { if (s >= end) return (s); + if (skip) + { + skip = 0; + continue; + } switch (c) { + case L('\\'): + skip = 1; + break; + case L('\0'): return ((CHAR *)NULL); diff --git a/lib/glob/sm_loop.c~ b/lib/glob/sm_loop.c~ new file mode 100644 index 000000000..5b460f0ff --- /dev/null +++ b/lib/glob/sm_loop.c~ @@ -0,0 +1,754 @@ +/* Copyright (C) 1991-2005 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash 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 2, or (at your option) any later + version. + + Bash 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 Bash; see the file COPYING. If not, write to the Free Software + Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + +int FCT __P((CHAR *, CHAR *, int)); + +static int GMATCH __P((CHAR *, CHAR *, CHAR *, CHAR *, int)); +static CHAR *PARSE_COLLSYM __P((CHAR *, INT *)); +static CHAR *BRACKMATCH __P((CHAR *, U_CHAR, int)); +static int EXTMATCH __P((INT, CHAR *, CHAR *, CHAR *, CHAR *, int)); +static CHAR *PATSCAN __P((CHAR *, CHAR *, INT)); + +int +FCT (pattern, string, flags) + CHAR *pattern; + CHAR *string; + int flags; +{ + CHAR *se, *pe; + + if (string == 0 || pattern == 0) + return FNM_NOMATCH; + + se = string + STRLEN ((XCHAR *)string); + pe = pattern + STRLEN ((XCHAR *)pattern); + + return (GMATCH (string, se, pattern, pe, flags)); +} + +/* Match STRING against the filename pattern PATTERN, returning zero if + it matches, FNM_NOMATCH if not. */ +static int +GMATCH (string, se, pattern, pe, flags) + CHAR *string, *se; + CHAR *pattern, *pe; + int flags; +{ + CHAR *p, *n; /* pattern, string */ + INT c; /* current pattern character - XXX U_CHAR? */ + INT sc; /* current string character - XXX U_CHAR? */ + + p = pattern; + n = string; + + if (string == 0 || pattern == 0) + return FNM_NOMATCH; + +#if DEBUG_MATCHING +fprintf(stderr, "gmatch: string = %s; se = %s\n", string, se); +fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe); +#endif + + while (p < pe) + { + c = *p++; + c = FOLD (c); + + sc = n < se ? *n : '\0'; + +#ifdef EXTENDED_GLOB + /* EXTMATCH () will handle recursively calling GMATCH, so we can + just return what EXTMATCH() returns. */ + if ((flags & FNM_EXTMATCH) && *p == L('(') && + (c == L('+') || c == L('*') || c == L('?') || c == L('@') || c == L('!'))) /* ) */ + { + int lflags; + /* If we're not matching the start of the string, we're not + concerned about the special cases for matching `.' */ + lflags = (n == string) ? flags : (flags & ~FNM_PERIOD); + return (EXTMATCH (c, n, se, p, pe, lflags)); + } +#endif /* EXTENDED_GLOB */ + + switch (c) + { + case L('?'): /* Match single character */ + if (sc == '\0') + return FNM_NOMATCH; + else if ((flags & FNM_PATHNAME) && sc == L('/')) + /* If we are matching a pathname, `?' can never match a `/'. */ + return FNM_NOMATCH; + else if ((flags & FNM_PERIOD) && sc == L('.') && + (n == string || ((flags & FNM_PATHNAME) && n[-1] == L('/')))) + /* `?' cannot match a `.' if it is the first character of the + string or if it is the first character following a slash and + we are matching a pathname. */ + return FNM_NOMATCH; + break; + + case L('\\'): /* backslash escape removes special meaning */ + if (p == pe) + return FNM_NOMATCH; + + if ((flags & FNM_NOESCAPE) == 0) + { + c = *p++; + /* A trailing `\' cannot match. */ + if (p > pe) + return FNM_NOMATCH; + c = FOLD (c); + } + if (FOLD (sc) != (U_CHAR)c) + return FNM_NOMATCH; + break; + + case '*': /* Match zero or more characters */ + if (p == pe) + return 0; + + if ((flags & FNM_PERIOD) && sc == L('.') && + (n == string || ((flags & FNM_PATHNAME) && n[-1] == L('/')))) + /* `*' cannot match a `.' if it is the first character of the + string or if it is the first character following a slash and + we are matching a pathname. */ + return FNM_NOMATCH; + + /* Collapse multiple consecutive `*' and `?', but make sure that + one character of the string is consumed for each `?'. */ + for (c = *p++; (c == L('?') || c == L('*')); c = *p++) + { + if ((flags & FNM_PATHNAME) && sc == L('/')) + /* A slash does not match a wildcard under FNM_PATHNAME. */ + return FNM_NOMATCH; +#ifdef EXTENDED_GLOB + else if ((flags & FNM_EXTMATCH) && c == L('?') && *p == L('(')) /* ) */ + { + CHAR *newn; + for (newn = n; newn < se; ++newn) + { + if (EXTMATCH (c, newn, se, p, pe, flags) == 0) + return (0); + } + /* We didn't match. If we have a `?(...)', that's failure. */ + return FNM_NOMATCH; + } +#endif + else if (c == L('?')) + { + if (sc == L('\0')) + return FNM_NOMATCH; + /* One character of the string is consumed in matching + this ? wildcard, so *??? won't match if there are + fewer than three characters. */ + n++; + sc = n < se ? *n : '\0'; + } + +#ifdef EXTENDED_GLOB + /* Handle ******(patlist) */ + if ((flags & FNM_EXTMATCH) && c == L('*') && *p == L('(')) /*)*/ + { + CHAR *newn; + /* We need to check whether or not the extended glob + pattern matches the remainder of the string. + If it does, we match the entire pattern. */ + for (newn = n; newn < se; ++newn) + { + if (EXTMATCH (c, newn, se, p, pe, flags) == 0) + return (0); + } + /* We didn't match the extended glob pattern, but + that's OK, since we can match 0 or more occurrences. + We need to skip the glob pattern and see if we + match the rest of the string. */ + newn = PATSCAN (p + 1, pe, 0); + /* If NEWN is 0, we have an ill-formed pattern. */ + p = newn ? newn : pe; + } +#endif + if (p == pe) + break; + } + + /* If we've hit the end of the pattern and the last character of + the pattern was handled by the loop above, we've succeeded. + Otherwise, we need to match that last character. */ + if (p == pe && (c == L('?') || c == L('*'))) + return (0); + + /* General case, use recursion. */ + { + U_CHAR c1; + + c1 = ((flags & FNM_NOESCAPE) == 0 && c == L('\\')) ? *p : c; + c1 = FOLD (c1); + for (--p; n < se; ++n) + { + /* Only call strmatch if the first character indicates a + possible match. We can check the first character if + we're not doing an extended glob match. */ + if ((flags & FNM_EXTMATCH) == 0 && c != L('[') && FOLD (*n) != c1) /*]*/ + continue; + + /* If we're doing an extended glob match and the pattern is not + one of the extended glob patterns, we can check the first + character. */ + if ((flags & FNM_EXTMATCH) && p[1] != L('(') && /*)*/ + STRCHR (L("?*+@!"), *p) == 0 && c != L('[') && FOLD (*n) != c1) /*]*/ + continue; + + /* Otherwise, we just recurse. */ + if (GMATCH (n, se, p, pe, flags & ~FNM_PERIOD) == 0) + return (0); + } + return FNM_NOMATCH; + } + + case L('['): + { + if (sc == L('\0') || n == se) + return FNM_NOMATCH; + + /* A character class cannot match a `.' if it is the first + character of the string or if it is the first character + following a slash and we are matching a pathname. */ + if ((flags & FNM_PERIOD) && sc == L('.') && + (n == string || ((flags & FNM_PATHNAME) && n[-1] == L('/')))) + return (FNM_NOMATCH); + + p = BRACKMATCH (p, sc, flags); + if (p == 0) + return FNM_NOMATCH; + } + break; + + default: + if ((U_CHAR)c != FOLD (sc)) + return (FNM_NOMATCH); + } + + ++n; + } + + if (n == se) + return (0); + + if ((flags & FNM_LEADING_DIR) && *n == L('/')) + /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ + return 0; + + return (FNM_NOMATCH); +} + +/* Parse a bracket expression collating symbol ([.sym.]) starting at P, find + the value of the symbol, and move P past the collating symbol expression. + The value is returned in *VP, if VP is not null. */ +static CHAR * +PARSE_COLLSYM (p, vp) + CHAR *p; + INT *vp; +{ + register int pc; + INT val; + + p++; /* move past the `.' */ + + for (pc = 0; p[pc]; pc++) + if (p[pc] == L('.') && p[pc+1] == L(']')) + break; + val = COLLSYM (p, pc); + if (vp) + *vp = val; + return (p + pc + 2); +} + +/* Use prototype definition here because of type promotion. */ +static CHAR * +#if defined (PROTOTYPES) +BRACKMATCH (CHAR *p, U_CHAR test, int flags) +#else +BRACKMATCH (p, test, flags) + CHAR *p; + U_CHAR test; + int flags; +#endif +{ + register CHAR cstart, cend, c; + register int not; /* Nonzero if the sense of the character class is inverted. */ + int brcnt; + INT pc; + CHAR *savep; + + test = FOLD (test); + + savep = p; + + /* POSIX.2 3.13.1 says that an exclamation mark (`!') shall replace the + circumflex (`^') in its role in a `nonmatching list'. A bracket + expression starting with an unquoted circumflex character produces + unspecified results. This implementation treats the two identically. */ + if (not = (*p == L('!') || *p == L('^'))) + ++p; + + c = *p++; + for (;;) + { + /* Initialize cstart and cend in case `-' is the last + character of the pattern. */ + cstart = cend = c; + + /* POSIX.2 equivalence class: [=c=]. See POSIX.2 2.8.3.2. Find + the end of the equivalence class, move the pattern pointer past + it, and check for equivalence. XXX - this handles only + single-character equivalence classes, which is wrong, or at + least incomplete. */ + if (c == L('[') && *p == L('=') && p[2] == L('=') && p[3] == L(']')) + { + pc = FOLD (p[1]); + p += 4; + if (COLLEQUIV (test, pc)) + { +/*[*/ /* Move past the closing `]', since the first thing we do at + the `matched:' label is back p up one. */ + p++; + goto matched; + } + else + { + c = *p++; + if (c == L('\0')) + return ((test == L('[')) ? savep : (CHAR *)0); /*]*/ + c = FOLD (c); + continue; + } + } + + /* POSIX.2 character class expression. See POSIX.2 2.8.3.2. */ + if (c == L('[') && *p == L(':')) + { + CHAR *close, *ccname; + + pc = 0; /* make sure invalid char classes don't match. */ + /* Find end of character class name */ + for (close = p + 1; *close != '\0'; close++) + if (*close == L(':') && *(close+1) == L(']')) + break; + + if (*close != L('\0')) + { + ccname = (CHAR *)malloc ((close - p) * sizeof (CHAR)); + if (ccname == 0) + pc = 0; + else + { + bcopy (p + 1, ccname, (close - p - 1) * sizeof (CHAR)); + *(ccname + (close - p - 1)) = L('\0'); + pc = IS_CCLASS (test, (XCHAR *)ccname); + } + if (pc == -1) + pc = 0; + else + p = close + 2; + + free (ccname); + } + + if (pc) + { +/*[*/ /* Move past the closing `]', since the first thing we do at + the `matched:' label is back p up one. */ + p++; + goto matched; + } + else + { + /* continue the loop here, since this expression can't be + the first part of a range expression. */ + c = *p++; + if (c == L('\0')) + return ((test == L('[')) ? savep : (CHAR *)0); + else if (c == L(']')) + break; + c = FOLD (c); + continue; + } + } + + /* POSIX.2 collating symbols. See POSIX.2 2.8.3.2. Find the end of + the symbol name, make sure it is terminated by `.]', translate + the name to a character using the external table, and do the + comparison. */ + if (c == L('[') && *p == L('.')) + { + p = PARSE_COLLSYM (p, &pc); + /* An invalid collating symbol cannot be the first point of a + range. If it is, we set cstart to one greater than `test', + so any comparisons later will fail. */ + cstart = (pc == INVALID) ? test + 1 : pc; + } + + if (!(flags & FNM_NOESCAPE) && c == L('\\')) + { + if (*p == '\0') + return (CHAR *)0; + cstart = cend = *p++; + } + + cstart = cend = FOLD (cstart); + + /* POSIX.2 2.8.3.1.2 says: `An expression containing a `[' that + is not preceded by a backslash and is not part of a bracket + expression produces undefined results.' This implementation + treats the `[' as just a character to be matched if there is + not a closing `]'. */ + if (c == L('\0')) + return ((test == L('[')) ? savep : (CHAR *)0); + + c = *p++; + c = FOLD (c); + + if ((flags & FNM_PATHNAME) && c == L('/')) + /* [/] can never match when matching a pathname. */ + return (CHAR *)0; + + /* This introduces a range, unless the `-' is the last + character of the class. Find the end of the range + and move past it. */ + if (c == L('-') && *p != L(']')) + { + cend = *p++; + if (!(flags & FNM_NOESCAPE) && cend == L('\\')) + cend = *p++; + if (cend == L('\0')) + return (CHAR *)0; + if (cend == L('[') && *p == L('.')) + { + p = PARSE_COLLSYM (p, &pc); + /* An invalid collating symbol cannot be the second part of a + range expression. If we get one, we set cend to one fewer + than the test character to make sure the range test fails. */ + cend = (pc == INVALID) ? test - 1 : pc; + } + cend = FOLD (cend); + + c = *p++; + + /* POSIX.2 2.8.3.2: ``The ending range point shall collate + equal to or higher than the starting range point; otherwise + the expression shall be treated as invalid.'' Note that this + applies to only the range expression; the rest of the bracket + expression is still checked for matches. */ + if (RANGECMP (cstart, cend) > 0) + { + if (c == L(']')) + break; + c = FOLD (c); + continue; + } + } + + if (RANGECMP (test, cstart) >= 0 && RANGECMP (test, cend) <= 0) + goto matched; + + if (c == L(']')) + break; + } + /* No match. */ + return (!not ? (CHAR *)0 : p); + +matched: + /* Skip the rest of the [...] that already matched. */ + c = *--p; + brcnt = 1; + while (brcnt > 0) + { + /* A `[' without a matching `]' is just another character to match. */ + if (c == L('\0')) + return ((test == L('[')) ? savep : (CHAR *)0); + + c = *p++; + if (c == L('[') && (*p == L('=') || *p == L(':') || *p == L('.'))) + brcnt++; + else if (c == L(']')) + brcnt--; + else if (!(flags & FNM_NOESCAPE) && c == L('\\')) + { + if (*p == '\0') + return (CHAR *)0; + /* XXX 1003.2d11 is unclear if this is right. */ + ++p; + } + } + return (not ? (CHAR *)0 : p); +} + +#if defined (EXTENDED_GLOB) +/* ksh-like extended pattern matching: + + [?*+@!](pat-list) + + where pat-list is a list of one or patterns separated by `|'. Operation + is as follows: + + ?(patlist) match zero or one of the given patterns + *(patlist) match zero or more of the given patterns + +(patlist) match one or more of the given patterns + @(patlist) match exactly one of the given patterns + !(patlist) match anything except one of the given patterns +*/ + +/* Scan a pattern starting at STRING and ending at END, keeping track of + embedded () and []. If DELIM is 0, we scan until a matching `)' + because we're scanning a `patlist'. Otherwise, we scan until we see + DELIM. In all cases, we never scan past END. The return value is the + first character after the matching DELIM. */ +static CHAR * +PATSCAN (string, end, delim) + CHAR *string, *end; + INT delim; +{ + int pnest, bnest; + INT cchar; + CHAR *s, c, *bfirst; + + pnest = bnest = 0; + cchar = 0; + bfirst = NULL; + + for (s = string; c = *s; s++) + { + if (s >= end) + return (s); + switch (c) + { + case L('\\'): + continue; + + case L('\0'): + return ((CHAR *)NULL); + + /* `[' is not special inside a bracket expression, but it may + introduce one of the special POSIX bracket expressions + ([.SYM.], [=c=], [: ... :]) that needs special handling. */ + case L('['): + if (bnest == 0) + { + bfirst = s + 1; + if (*bfirst == L('!') || *bfirst == L('^')) + bfirst++; + bnest++; + } + else if (s[1] == L(':') || s[1] == L('.') || s[1] == L('=')) + cchar = s[1]; + break; + + /* `]' is not special if it's the first char (after a leading `!' + or `^') in a bracket expression or if it's part of one of the + special POSIX bracket expressions ([.SYM.], [=c=], [: ... :]) */ + case L(']'): + if (bnest) + { + if (cchar && s[-1] == cchar) + cchar = 0; + else if (s != bfirst) + { + bnest--; + bfirst = 0; + } + } + break; + + case L('('): + if (bnest == 0) + pnest++; + break; + + case L(')'): + if (bnest == 0 && pnest-- <= 0) + return ++s; + break; + + case L('|'): + if (bnest == 0 && pnest == 0 && delim == L('|')) + return ++s; + break; + } + } + + return (NULL); +} + +/* Return 0 if dequoted pattern matches S in the current locale. */ +static int +STRCOMPARE (p, pe, s, se) + CHAR *p, *pe, *s, *se; +{ + int ret; + CHAR c1, c2; + + c1 = *pe; + c2 = *se; + + *pe = *se = '\0'; +#if HAVE_MULTIBYTE || defined (HAVE_STRCOLL) + ret = STRCOLL ((XCHAR *)p, (XCHAR *)s); +#else + ret = STRCMP ((XCHAR *)p, (XCHAR *)s); +#endif + + *pe = c1; + *se = c2; + + return (ret == 0 ? ret : FNM_NOMATCH); +} + +/* Match a ksh extended pattern specifier. Return FNM_NOMATCH on failure or + 0 on success. This is handed the entire rest of the pattern and string + the first time an extended pattern specifier is encountered, so it calls + gmatch recursively. */ +static int +EXTMATCH (xc, s, se, p, pe, flags) + INT xc; /* select which operation */ + CHAR *s, *se; + CHAR *p, *pe; + int flags; +{ + CHAR *prest; /* pointer to rest of pattern */ + CHAR *psub; /* pointer to sub-pattern */ + CHAR *pnext; /* pointer to next sub-pattern */ + CHAR *srest; /* pointer to rest of string */ + int m1, m2; + +#if DEBUG_MATCHING +fprintf(stderr, "extmatch: xc = %c\n", xc); +fprintf(stderr, "extmatch: s = %s; se = %s\n", s, se); +fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe); +#endif + + prest = PATSCAN (p + (*p == L('(')), pe, 0); /* ) */ + if (prest == 0) + /* If PREST is 0, we failed to scan a valid pattern. In this + case, we just want to compare the two as strings. */ + return (STRCOMPARE (p - 1, pe, s, se)); + + switch (xc) + { + case L('+'): /* match one or more occurrences */ + case L('*'): /* match zero or more occurrences */ + /* If we can get away with no matches, don't even bother. Just + call GMATCH on the rest of the pattern and return success if + it succeeds. */ + if (xc == L('*') && (GMATCH (s, se, prest, pe, flags) == 0)) + return 0; + + /* OK, we have to do this the hard way. First, we make sure one of + the subpatterns matches, then we try to match the rest of the + string. */ + for (psub = p + 1; ; psub = pnext) + { + pnext = PATSCAN (psub, pe, L('|')); + for (srest = s; srest <= se; srest++) + { + /* Match this substring (S -> SREST) against this + subpattern (psub -> pnext - 1) */ + m1 = GMATCH (s, srest, psub, pnext - 1, flags) == 0; + /* OK, we matched a subpattern, so make sure the rest of the + string matches the rest of the pattern. Also handle + multiple matches of the pattern. */ + if (m1) + m2 = (GMATCH (srest, se, prest, pe, flags) == 0) || + (s != srest && GMATCH (srest, se, p - 1, pe, flags) == 0); + if (m1 && m2) + return (0); + } + if (pnext == prest) + break; + } + return (FNM_NOMATCH); + + case L('?'): /* match zero or one of the patterns */ + case L('@'): /* match exactly one of the patterns */ + /* If we can get away with no matches, don't even bother. Just + call gmatch on the rest of the pattern and return success if + it succeeds. */ + if (xc == L('?') && (GMATCH (s, se, prest, pe, flags) == 0)) + return 0; + + /* OK, we have to do this the hard way. First, we see if one of + the subpatterns matches, then, if it does, we try to match the + rest of the string. */ + for (psub = p + 1; ; psub = pnext) + { + pnext = PATSCAN (psub, pe, L('|')); + srest = (prest == pe) ? se : s; + for ( ; srest <= se; srest++) + { + if (GMATCH (s, srest, psub, pnext - 1, flags) == 0 && + GMATCH (srest, se, prest, pe, flags) == 0) + return (0); + } + if (pnext == prest) + break; + } + return (FNM_NOMATCH); + + case '!': /* match anything *except* one of the patterns */ + for (srest = s; srest <= se; srest++) + { + m1 = 0; + for (psub = p + 1; ; psub = pnext) + { + pnext = PATSCAN (psub, pe, L('|')); + /* If one of the patterns matches, just bail immediately. */ + if (m1 = (GMATCH (s, srest, psub, pnext - 1, flags) == 0)) + break; + if (pnext == prest) + break; + } + if (m1 == 0 && GMATCH (srest, se, prest, pe, flags) == 0) + return (0); + } + return (FNM_NOMATCH); + } + + return (FNM_NOMATCH); +} +#endif /* EXTENDED_GLOB */ + +#undef IS_CCLASS +#undef FOLD +#undef CHAR +#undef U_CHAR +#undef XCHAR +#undef INT +#undef INVALID +#undef FCT +#undef GMATCH +#undef COLLSYM +#undef PARSE_COLLSYM +#undef PATSCAN +#undef STRCOMPARE +#undef EXTMATCH +#undef BRACKMATCH +#undef STRCHR +#undef STRCOLL +#undef STRLEN +#undef STRCMP +#undef COLLEQUIV +#undef RANGECMP +#undef L diff --git a/lib/readline/bind.c b/lib/readline/bind.c index 2a6d646de..7559d32f6 100644 --- a/lib/readline/bind.c +++ b/lib/readline/bind.c @@ -77,6 +77,8 @@ static char *_rl_read_file PARAMS((char *, size_t *)); static void _rl_init_file_error PARAMS((const char *)); static int _rl_read_init_file PARAMS((const char *, int)); static int glean_key_from_name PARAMS((char *)); +static int find_boolean_var PARAMS((const char *)); + static char *_rl_get_string_variable_value PARAMS((const char *)); static int substring_member_of_array PARAMS((char *, const char **)); @@ -1206,13 +1208,19 @@ rl_parse_and_bind (string) *value++ = '\0'; while (*value && whitespace (*value)) value++; - /* remove trailing whitespace */ - e = value + strlen (value) - 1; - while (e >= value && whitespace (*e)) - e--; - e++; /* skip back to whitespace or EOS */ - if (*e && e >= value) - *e = '\0'; + /* Strip trailing whitespace from values to boolean variables. Temp + fix until I get a real quoted-string parser here. */ + i = find_boolean_var (var); + if (i >= 0) + { + /* remove trailing whitespace */ + e = value + strlen (value) - 1; + while (e >= value && whitespace (*e)) + e--; + e++; /* skip back to whitespace or EOS */ + if (*e && e >= value) + *e = '\0'; + } rl_variable_bind (var, value); return 0; diff --git a/lib/readline/bind.c~ b/lib/readline/bind.c~ index fd4c9fb2d..ad0d5df7b 100644 --- a/lib/readline/bind.c~ +++ b/lib/readline/bind.c~ @@ -1,6 +1,6 @@ /* bind.c -- key binding and startup file support for the readline library. */ -/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1987-2005 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -77,6 +77,8 @@ static char *_rl_read_file PARAMS((char *, size_t *)); static void _rl_init_file_error PARAMS((const char *)); static int _rl_read_init_file PARAMS((const char *, int)); static int glean_key_from_name PARAMS((char *)); +static int find_boolean_var PARAMS((const char *)); + static char *_rl_get_string_variable_value PARAMS((const char *)); static int substring_member_of_array PARAMS((char *, const char **)); @@ -342,7 +344,7 @@ rl_generic_bind (type, keyseq, data, map) k.function = 0; /* If no keys to bind to, exit right away. */ - if (!keyseq || !*keyseq) + if (keyseq == 0 || *keyseq == 0) { if (type == ISMACR) free (data); @@ -1206,13 +1208,20 @@ rl_parse_and_bind (string) *value++ = '\0'; while (*value && whitespace (*value)) value++; - /* remove trailing whitespace */ - e = value + strlen (value) - 1; - while (e >= value && whitespace (*e)) - e--; - e++; /* skip back to whitespace or EOS */ - if (*e && e >= value) - *e = '\0'; + /* Strip trailing whitespace from values to boolean variables. Temp + fix until I get a real quoted-string parser here. */ + i = find_boolean_var (var); + + if (i >= 0) + { + /* remove trailing whitespace */ + e = value + strlen (value) - 1; + while (e >= value && whitespace (*e)) + e--; + e++; /* skip back to whitespace or EOS */ + if (*e && e >= value) + *e = '\0'; + } rl_variable_bind (var, value); return 0; @@ -1507,12 +1516,11 @@ rl_variable_value (name) return (*boolean_varlist[i].value ? "on" : "off"); i = find_string_var (name); + if (i >= 0) + return (_rl_get_string_variable_value (string_varlist[i].name)); /* Unknown variable names return NULL. */ - if (i < 0) - return 0; - - return (_rl_get_string_variable_value (string_varlist[i].name)); + return 0; } int diff --git a/lib/readline/readline.h b/lib/readline/readline.h index 0ab99c511..3688c4b82 100644 --- a/lib/readline/readline.h +++ b/lib/readline/readline.h @@ -786,6 +786,7 @@ extern int rl_inhibit_completion; #define RL_STATE_CALLBACK 0x080000 /* using the callback interface */ #define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */ #define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */ +#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */ #define RL_STATE_DONE 0x800000 /* done; accepted line */ diff --git a/lib/readline/undo.c b/lib/readline/undo.c index 25c287b5a..fedfa121f 100644 --- a/lib/readline/undo.c +++ b/lib/readline/undo.c @@ -237,7 +237,12 @@ rl_revert_line (count, key) { while (rl_undo_list) rl_do_undo (); +#if defined (VI_MODE) + if (rl_editing_mode == vi_mode) + rl_point = rl_mark = 0; /* rl_end should be set correctly */ +#endif } + return 0; } diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c index efaef3992..2fcc1dc9f 100644 --- a/lib/readline/vi_mode.c +++ b/lib/readline/vi_mode.c @@ -131,6 +131,8 @@ _rl_vi_initialize_line () for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++) vi_mark_chars[i] = -1; + + RL_UNSETSTATE(RL_STATE_VICMDONCE); } void @@ -686,6 +688,13 @@ rl_vi_movement_mode (count, key) _rl_keymap = vi_movement_keymap; _rl_vi_done_inserting (); + + /* This is how POSIX.2 says `U' should behave -- everything up until the + first time you go into command mode should not be undone. */ + if (RL_ISSTATE (RL_STATE_VICMDONCE) == 0) + rl_free_undo_list (); + + RL_SETSTATE (RL_STATE_VICMDONCE); return (0); } diff --git a/redir.c b/redir.c index 08715a0e5..c9e53351e 100644 --- a/redir.c +++ b/redir.c @@ -630,6 +630,9 @@ do_redirection_internal (redirect, flags) redirector = redirect->redirector; ri = redirect->instruction; +if (redirect->flags & RX_INTERNAL) + flags |= RX_INTERNAL; + if (TRANSLATE_REDIRECT (ri)) { /* We have [N]>&WORD[-] or [N]<&WORD[-]. Expand WORD, then translate @@ -903,8 +906,13 @@ do_redirection_internal (redirect, flags) always be open. */ /* if ((already_set || set_unconditionally) && (ok_to_set)) set_it () */ +#if 0 if (((fcntl (redir_fd, F_GETFD, 0) == 1) || redir_fd < 2 || (flags & RX_CLEXEC)) && (redirector > 2)) +#else + if (((fcntl (redir_fd, F_GETFD, 0) == 1) || (redir_fd < 2 && (flags & RX_INTERNAL)) || (flags & RX_CLEXEC)) && + (redirector > 2)) +#endif SET_CLOSE_ON_EXEC (redirector); /* dup-and-close redirection */ @@ -961,6 +969,7 @@ add_undo_redirect (fd) rd.dest = 0; closer = make_redirection (new_fd, r_close_this, rd); + closer->flags |= RX_INTERNAL; dummy_redirect = copy_redirects (closer); rd.dest = new_fd; @@ -968,6 +977,7 @@ add_undo_redirect (fd) new_redirect = make_redirection (fd, r_duplicating_input, rd); else new_redirect = make_redirection (fd, r_duplicating_output, rd); + new_redirect->flags |= RX_INTERNAL; new_redirect->next = closer; closer->next = redirection_undo_list; @@ -1016,6 +1026,7 @@ add_undo_close_redirect (fd) rd.dest = 0; closer = make_redirection (fd, r_close_this, rd); + closer->flags |= RX_INTERNAL; closer->next = redirection_undo_list; redirection_undo_list = closer; } diff --git a/redir.h b/redir.h index acb91e7c1..3eb726147 100644 --- a/redir.h +++ b/redir.h @@ -27,6 +27,8 @@ #define RX_ACTIVE 0x01 /* do it; don't just go through the motions */ #define RX_UNDOABLE 0x02 /* make a list to undo these redirections */ #define RX_CLEXEC 0x04 /* set close-on-exec for opened fds > 2 */ +#define RX_INTERNAL 0x08 +#define RX_USER 0x10 extern void redirection_error __P((REDIRECT *, int)); extern int do_redirections __P((REDIRECT *, int)); diff --git a/subst.c b/subst.c index fabaf155a..cb7638483 100644 --- a/subst.c +++ b/subst.c @@ -1010,6 +1010,7 @@ extract_array_assignment_list (string, sindex) *sindex = slen - 1; return ret; } + return 0; } #endif @@ -2325,7 +2326,7 @@ do_assignment_no_expand (string) td.flags = W_ASSIGNMENT; td.word = string; - do_assignment_internal (&td, 0); + return (do_assignment_internal (&td, 0)); } /*************************************************** diff --git a/support/man2html.c b/support/man2html.c index d1ed8bc54..2432c13f2 100644 --- a/support/man2html.c +++ b/support/man2html.c @@ -102,6 +102,10 @@ static char location_base[NULL_TERMINATED(MED_STR_MAX)] = ""; +static char th_page_and_sec[128] = { '\0' }; +static char th_datestr[128] = { '\0' }; +static char th_version[128] = { '\0' }; + char *signature = "
\nThis document was created by man2html from %s.
\nTime: %s\n"; /* timeformat for signature */ @@ -2148,6 +2152,26 @@ skip_till_newline(char *c) return c; } +static void +outputPageHeader(char *l, char *c, char *r) +{ + out_html("\n\n"); + out_html("\n
"); + out_html(l); + out_html(""); + out_html(c); + out_html(""); + out_html(r); + out_html("\n
\n"); +} + +static void +outputPageFooter(char *l, char *c, char *r) +{ + out_html("
\n"); + outputPageHeader(l, c, r); +} + static int ifelseval = 0; static char * @@ -2836,15 +2860,15 @@ scan_request(char *c) out_html(label); /*   for mosaic users */ if (mode) - out_html("\"> \n

"); + out_html("\"> \n

"); else - out_html("\"> \n

"); + out_html("\"> \n

"); mandoc_synopsis = strncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c, 1, NULL) : scan_troff(c, 1, NULL); if (mode) - out_html("

\n"); + out_html("\n"); else - out_html("\n"); + out_html("\n"); curpos = 0; break; case V('T', 'S'): @@ -2856,25 +2880,31 @@ scan_request(char *c) if (!output_possible) { sl = fill_words(c + j, wordlist, &words); if (words > 1) { - char page_and_sec[128]; - + char *t; for (i = 1; i < words; i++) wordlist[i][-1] = '\0'; *sl = '\0'; output_possible = 1; - sprintf(page_and_sec, "%s(%s)", wordlist[0], wordlist[1]); + sprintf(th_page_and_sec, "%s(%s)", wordlist[0], wordlist[1]); + if (words > 2) { + t = unescape(wordlist[2]); + strncpy(th_datestr, t, sizeof(th_datestr)); + th_datestr[sizeof(th_datestr) - 1] = '\0'; + } else + th_datestr[0] = '\0'; + if (words > 3) { + t = unescape(wordlist[3]); + strncpy(th_version, t, sizeof(th_version)); + th_version[sizeof(th_version) - 1] = '\0'; + } else + th_version[0] = '\0'; out_html("\n"); - out_html(page_and_sec); + out_html(th_page_and_sec); out_html(" Manual Page"); out_html("\n\n"); - out_html("\n"); - out_html("
"); - out_html(page_and_sec); - out_html(""); - out_html(unescape(wordlist[2])); - out_html(""); - out_html(page_and_sec); - out_html("\n
\n"); + + outputPageHeader(th_page_and_sec, th_datestr, th_page_and_sec); + out_html("
Index\n"); *sl = '\n'; out_html("
\n"); @@ -4023,6 +4053,7 @@ main(int argc, char **argv) out_html(NEWLINE); if (output_possible) { + outputPageFooter(th_version, th_datestr, th_page_and_sec); /*   for mosaic users */ fputs("
\n 

Index

\n
\n", stdout); manidx[mip] = 0; diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 72ec06a2c..3efcf32d6 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -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 diff --git a/tests/redir7.sub b/tests/redir7.sub index 5b2a1102a..3fd371c70 100644 --- a/tests/redir7.sub +++ b/tests/redir7.sub @@ -65,3 +65,5 @@ exec 4>&1 >&3 3>&- }` echo c4 is $c +# fixed in bash-3.1 +echo 'exec <&3' | ${THIS_SH} 3<&0 -- 2.47.3