commit bash-20121214 snapshot

This commit is contained in:
Chet Ramey
2013-01-03 10:46:55 -05:00
parent 8b20235af7
commit 77b3aacbdf
29 changed files with 44317 additions and 5803 deletions
+81
View File
@@ -3989,3 +3989,84 @@ lib/sh/zread.c
saying how many bytes to read into the local buffer. Can be used to
implement `read -N' without so many one-byte calls to zreadc. Code
from Mike Frysinger <vapier@gentoo.org>
12/12
-----
lib/glob/sm_loop.c
- PATSCAN (glob_patscan): if passed string already points to end of
pattern, return NULL immediately. Fixes problem with
extglob_skipname reported by Raphaël Droz <raphael.droz@gmail.com>
12/13
-----
execute_cmd.c
- execute_coproc: handle the command's exit status being inverted
(an oversight). Fixes bug reported by DJ Mills
<danielmills1@gmail.com> and Andreas Schwab <schwab@linux-m68k.org>
12/14
-----
lib/readline/readline.c
- bind_arrow_keys_internal: add MINGW key bindings for Home, End,
Delete, and Insert keys. Fix from Pierre Muller
<pierre.muller@ics-cnrs.unistra.fr>
builtins/printf.def
- printf_builtin: '%()T' conversion: if there is no argument supplied,
behave as if -1 had been supplied (current time). ksh93-like feature
suggested by Clark Wang <dearvoid@gmail.com>
doc/{bash.1,bashref.texi}
- document new printf %()T default argument behavior
12/15
-----
lib/readline/display.c
- displaying_prompt_first_line: new variable, indicates whether or
not the first line of output is displaying the prompt. Always true
in normal mode, sometimes false in horizontal scrolling mode
- rl_redisplay: set displaying_prompt_first_line to true unless we
are in horizontal mode; set to false in horizontal mode if the left
margin of the displayed line is greater than the end of the prompt
string
- rl_redisplay: when in horizontal scroll mode, don't adjust
_rl_last_c_pos by the wrap offset unless the line is displaying
a prompt containing invisible chars
- update line: don't adjust _rl_last_c_pos by the wrap offset unless
the line is displaying a prompt containing invisible chars
- update_line: if shrinking the line by reducing the number of
displayed characters, but we have already moved the cursor to the
beginning of the line where the first difference starts, don't
try to delete characters
builtins/read.def
- unbuffered_read: set to 2 if invoked as `read -N'
- if unbuffered_read is set to 2, compute the number of chars we
need to read and read that many with zreadn. Posix mode still
uses zreadintr. Code from Mike Frysinger <vapier@gentoo.org>
doc/{bash.1,bashref.texi}
- read: make it clear that if read times out, it saves any input
read to that point into the variable arguments. Report from
Fiedler Roman <Roman.Fiedler@ait.ac.at>
subst.c
- command_substitute: change direct assignment of exit_immediately_on_error
to use change_flag ('e', FLAG_OFF) instead
flags.c
- use errexit_flag as the variable modified by changes to the -e
option, reflect those changes to exit_immediately_on_error
execute_cmd.c
- execute_builtin: new global variable, builtin_ignoring_errexit, set
to 0 by default and set to 1 if eval/source/command executing in a
context where -e should be ignored
- execute_builtin: set exit_immediately_on_error to errextit_flag
after executing eval/source/command in a context where -e should
be ignored
flags.c
- if builtin_ignoring_errexit is set, changes to errexit_flag are
not reflected in the setting of exit_immediately_on_error. Fixes
bug reported by Robert Schiele <rschiele@gmail.com>
+83
View File
@@ -3983,3 +3983,86 @@ lib/glob/glob.c
o note when the directory name is all ** or ends in ** so we
can treat it specially when the filename is **
All inspired by report from Andrey Borzenkov <arvidjaar@gmail.com>
lib/sh/zread.c
- zreadn: new function, like zread, but takes an additional argument
saying how many bytes to read into the local buffer. Can be used to
implement `read -N' without so many one-byte calls to zreadc. Code
from Mike Frysinger <vapier@gentoo.org>
12/12
-----
lib/glob/sm_loop.c
- PATSCAN (glob_patscan): if passed string already points to end of
pattern, return NULL immediately. Fixes problem with
extglob_skipname reported by Raphaël Droz <raphael.droz@gmail.com>
12/13
-----
execute_cmd.c
- execute_coproc: handle the command's exit status being inverted
(an oversight). Fixes bug reported by DJ Mills
<danielmills1@gmail.com> and Andreas Schwab <schwab@linux-m68k.org>
12/14
-----
lib/readline/readline.c
- bind_arrow_keys_internal: add MINGW key bindings for Home, End,
Delete, and Insert keys. Fix from Pierre Muller
<pierre.muller@ics-cnrs.unistra.fr>
builtins/printf.def
- printf_builtin: '%()T' conversion: if there is no argument supplied,
behave as if -1 had been supplied (current time). ksh93-like feature
suggested by Clark Wang <dearvoid@gmail.com>
doc/{bash.1,bashref.texi}
- document new printf %()T default argument behavior
12/15
-----
lib/readline/display.c
- displaying_prompt_first_line: new variable, indicates whether or
not the first line of output is displaying the prompt. Always true
in normal mode, sometimes false in horizontal scrolling mode
- rl_redisplay: set displaying_prompt_first_line to true unless we
are in horizontal mode; set to false in horizontal mode if the left
margin of the displayed line is greater than the end of the prompt
string
- rl_redisplay: when in horizontal scroll mode, don't adjust
_rl_last_c_pos by the wrap offset unless the line is displaying
a prompt containing invisible chars
- update line: don't adjust _rl_last_c_pos by the wrap offset unless
the line is displaying a prompt containing invisible chars
- update_line: if shrinking the line by reducing the number of
displayed characters, but we have already moved the cursor to the
beginning of the line where the first difference starts, don't
try to delete characters
builtins/read.def
- unbuffered_read: set to 2 if invoked as `read -N'
- if unbuffered_read is set to 2, compute the number of chars we
need to read and read that many with zreadn. Posix mode still
uses zreadintr. Code from Mike Frysinger <vapier@gentoo.org>
doc/{bash.1,bashref.texi}
- read: make it clear that if read times out, it saves any input
read to that point into the variable arguments. Report from
Fiedler Roman <Roman.Fiedler@ait.ac.at>
subst.c
- command_substitute: change direct assignment of exit_immediately_on_error
to use change_flag ('e', FLAG_OFF) instead
flags.c
- use errexit_flag as the variable modified by changes to the -e
option, reflect those changes to exit_immediately_on_error
execute_cmd.c
- execute_builtin: new global variable, builtin_ignoring_errexit, set
to 0 by default and set to 1 if eval/source/command executing in a
context where -e should be ignored
- execute_builtin: set exit_immediately_on_error to errextit_flag
after executing eval/source/command in a context where -e should
be ignored
+4 -3
View File
@@ -56,7 +56,8 @@ When used in a function, `declare' makes NAMEs local, as with the `local'
command. The `-g' option suppresses this behavior.
Exit Status:
Returns success unless an invalid option is supplied or an error occurs.
Returns success unless an invalid option is supplied or a variable
assignment error occurs.
$END
$BUILTIN typeset
@@ -111,8 +112,8 @@ Local variables can only be used within a function; they are visible
only to the function where they are defined and its children.
Exit Status:
Returns success unless an invalid option is supplied, an error occurs,
or the shell is not executing a function.
Returns success unless an invalid option is supplied, a variable
assignment error occurs, or the shell is not executing a function.
$END
int
local_builtin (list)
+2 -1
View File
@@ -466,7 +466,8 @@ printf_builtin (list)
timefmt[2] = '\0';
}
/* argument is seconds since the epoch with special -1 and -2 */
arg = getintmax ();
/* default argument is equivalent to -1; special case */
arg = garglist ? getintmax () : -1;
if (arg == -1)
secs = NOW; /* roughly date +%s */
else if (arg == -2)
+7 -2
View File
@@ -483,7 +483,10 @@ read_builtin (list)
add_unwind_protect (xfree, input_string);
CHECK_ALRM;
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
if ((nchars > 0) && (input_is_tty == 0) && ignore_delim) /* read -N */
unbuffered_read = 2;
else if ((nchars > 0) || (delim != '\n') || input_is_pipe)
unbuffered_read = 1;
if (prompt && edit == 0)
{
@@ -540,7 +543,9 @@ read_builtin (list)
interrupt_immediately++;
#endif
reading = 1;
if (unbuffered_read)
if (unbuffered_read == 2)
retval = posixly_correct ? zreadintr (fd, &c, 1) : zreadn (fd, &c, nchars - nr);
else if (unbuffered_read)
retval = posixly_correct ? zreadintr (fd, &c, 1) : zread (fd, &c, 1);
else
retval = posixly_correct ? zreadcintr (fd, &c) : zreadc (fd, &c);
+1067
View File
File diff suppressed because it is too large Load Diff
+15 -7
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Sat Nov 24 15:07:12 EST 2012
.\" Last Change: Sat Dec 15 17:50:05 EST 2012
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2012 November 24" "GNU Bash 4.2"
.TH BASH 1 "2012 December 15" "GNU Bash 4.2"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -949,6 +949,8 @@ available as the value of the variable \fINAME\fP_PID.
The \fBwait\fP
builtin command may be used to wait for the coprocess to terminate.
.PP
Since the coprocess is created as an asynchronous command,
the \fBcoproc\fP command always returns success.
The return status of a coprocess is the exit status of \fIcommand\fP.
.SS Shell Function Definitions
.PP
@@ -8413,10 +8415,13 @@ causes \fBprintf\fP to output the corresponding
.TP
.B %(\fIdatefmt\fP)T
causes \fBprintf\fP to output the date-time string resulting from using
\fIdatefmt\fP as a format string for \fIstrftime\fP(3). The corresponding
\fIargument\fP is an integer representing the number of seconds since the
epoch. Two special argument values may be used: -1 represents the current
\fIdatefmt\fP as a format string for \fIstrftime\fP(3).
The corresponding \fIargument\fP is an integer representing the number of
seconds since the epoch.
Two special argument values may be used: -1 represents the current
time, and -2 represents the time the shell was invoked.
If no argument is specified, conversion behaves as if -1 had been given.
This is an exception to the usual \fBprintf\fP behavior.
.PD
.PP
Arguments to non-string format specifiers are treated as C constants,
@@ -8584,14 +8589,17 @@ not echoed.
.TP
.B \-t \fItimeout\fP
Cause \fBread\fP to time out and return failure if a complete line of
input is not read within \fItimeout\fP seconds.
input (or a specified number of characters)
is not read within \fItimeout\fP seconds.
\fItimeout\fP may be a decimal number with a fractional portion following
the decimal point.
This option is only effective if \fBread\fP is reading input from a
terminal, pipe, or other special file; it has no effect when reading
from regular files.
If \fBread\fP times out, \fBread\fP saves any partial input read into
the specified variable \fIname\fP.
If \fItimeout\fP is 0, \fBread\fP returns immediately, without trying to
read any data. The exit statis is 0 if input is available on
read any data. The exit status is 0 if input is available on
the specified file descriptor, non-zero otherwise.
The exit status is greater than 128 if the timeout is exceeded.
.TP
+10244
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+5836 -5767
View File
File diff suppressed because it is too large Load Diff
+12 -4
View File
@@ -1197,6 +1197,8 @@ available as the value of the variable @env{NAME}_PID.
The @code{wait}
builtin command may be used to wait for the coprocess to terminate.
Since the coprocess is created as an asynchronous command,
the @code{coproc} command always returns success.
The return status of a coprocess is the exit status of @var{command}.
@node GNU Parallel
@@ -4174,10 +4176,13 @@ Causes @code{printf} to output the
corresponding @var{argument} in a format that can be reused as shell input.
@item %(@var{datefmt})T
Causes @code{printf} to output the date-time string resulting from using
@var{datefmt} as a format string for @code{strftime}(3). The corresponding
@var{argument} is an integer representing the number of seconds since the
epoch. Two special argument values may be used: -1 represents the current
@var{datefmt} as a format string for @code{strftime}(3).
The corresponding @var{argument} is an integer representing the number of
seconds since the epoch.
Two special argument values may be used: -1 represents the current
time, and -2 represents the time the shell was invoked.
If no argument is specified, conversion behaves as if -1 had been given.
This is an exception to the usual @code{printf} behavior.
@end table
@noindent
@@ -4269,12 +4274,15 @@ not echoed.
@item -t @var{timeout}
Cause @code{read} to time out and return failure if a complete line of
input is not read within @var{timeout} seconds.
input (or a specified number of characters)
is not read within @var{timeout} seconds.
@var{timeout} may be a decimal number with a fractional portion following
the decimal point.
This option is only effective if @code{read} is reading input from a
terminal, pipe, or other special file; it has no effect when reading
from regular files.
If @code{read} times out, @code{read} saves any partial input read into
the specified variable @var{name}.
If @var{timeout} is 0, @code{read} returns immediately, without trying to
read and data. The exit status is 0 if input is available on
the specified file descriptor, non-zero otherwise.
+8627
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -2,9 +2,9 @@
Copyright (C) 1988-2012 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Sat Nov 24 15:06:49 EST 2012
@set LASTCHANGE Sat Dec 15 17:49:50 EST 2012
@set EDITION 4.2
@set VERSION 4.2
@set UPDATED 24 November 2012
@set UPDATED-MONTH November 2012
@set UPDATED 15 December 2012
@set UPDATED-MONTH December 2012
+10
View File
@@ -0,0 +1,10 @@
@ignore
Copyright (C) 1988-2012 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Fri Dec 14 10:13:02 EST 2012
@set EDITION 4.2
@set VERSION 4.2
@set UPDATED 14 December 2012
@set UPDATED-MONTH December 2012
+12 -3
View File
@@ -224,6 +224,10 @@ int last_command_exit_value;
was terminated by a signal, and, if so, which one. */
int last_command_exit_signal;
/* Are we currently ignoring the -e option for the duration of a builtin's
execution? */
int builtin_ignoring_errexit = 0;
/* The list of redirections to perform which will undo the redirections
that I made in the shell. */
REDIRECT *redirection_undo_list = (REDIRECT *)NULL;
@@ -2160,7 +2164,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close)
int pipe_in, pipe_out;
struct fd_bitmap *fds_to_close;
{
int rpipe[2], wpipe[2], estat;
int rpipe[2], wpipe[2], estat, invert;
pid_t coproc_pid;
Coproc *cp;
char *tcmd;
@@ -2173,6 +2177,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close)
coproc_init (&sh_coproc);
#endif
invert = (command->flags & CMD_INVERT_RETURN) != 0;
command_string_index = 0;
tcmd = make_command_string (command);
@@ -2224,7 +2229,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close)
DESCRIBE_PID (coproc_pid);
run_pending_traps ();
return (EXECUTION_SUCCESS);
return (invert ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
}
#endif
@@ -4219,6 +4224,7 @@ execute_builtin (builtin, words, flags, subshell)
error_trap = 0;
old_e_flag = exit_immediately_on_error;
/* The eval builtin calls parse_and_execute, which does not know about
the setting of flags, and always calls the execution functions with
flags that will exit the shell on an error if -e is set. If the
@@ -4231,6 +4237,7 @@ execute_builtin (builtin, words, flags, subshell)
{
begin_unwind_frame ("eval_builtin");
unwind_protect_int (exit_immediately_on_error);
unwind_protect_int (builtin_ignoring_errexit);
error_trap = TRAP_STRING (ERROR_TRAP);
if (error_trap)
{
@@ -4240,6 +4247,7 @@ execute_builtin (builtin, words, flags, subshell)
restore_default_signal (ERROR_TRAP);
}
exit_immediately_on_error = 0;
builtin_ignoring_errexit = 1;
eval_unwind = 1;
}
else
@@ -4289,7 +4297,8 @@ execute_builtin (builtin, words, flags, subshell)
if (eval_unwind)
{
exit_immediately_on_error += old_e_flag;
exit_immediately_on_error = errexit_flag;
builtin_ignoring_errexit = 0;
if (error_trap)
{
set_error_trap (error_trap);
+5393
View File
File diff suppressed because it is too large Load Diff
+10 -2
View File
@@ -40,6 +40,7 @@ extern char *shell_name;
#endif
extern int shell_initialized;
extern int builtin_ignoring_errexit;
/* -c, -s invocation options -- not really flags, but they show up in $- */
extern int want_pending_command, read_from_stdin;
@@ -59,7 +60,9 @@ int mark_modified_vars = 0;
int asynchronous_notification = 0;
/* Non-zero means exit immediately if a command exits with a non-zero
exit status. */
exit status. The first is what controls set -e; the second is what
bash uses internally. */
int errexit_flag = 0;
int exit_immediately_on_error = 0;
/* Non-zero means disable filename globbing. */
@@ -179,7 +182,7 @@ const struct flags_alist shell_flags[] = {
#if defined (JOB_CONTROL)
{ 'b', &asynchronous_notification },
#endif /* JOB_CONTROL */
{ 'e', &exit_immediately_on_error },
{ 'e', &errexit_flag },
{ 'f', &disallow_filename_globbing },
{ 'h', &hashing_enabled },
{ 'i', &forced_interactive },
@@ -272,6 +275,11 @@ change_flag (flag, on_or_off)
break;
#endif /* JOB_CONTROL */
case 'e':
if (builtin_ignoring_errexit == 0)
exit_immediately_on_error = errexit_flag;
break;
case 'n':
if (interactive_shell)
read_but_dont_execute = 0;
+364
View File
@@ -0,0 +1,364 @@
/* flags.c -- Everything about flags except the `set' command. That
is in builtins.c */
/* Copyright (C) 1987-2009 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "shell.h"
#include "flags.h"
#if defined (BANG_HISTORY)
# include "bashhist.h"
#endif
#if defined (JOB_CONTROL)
extern int set_job_control __P((int));
#endif
#if defined (RESTRICTED_SHELL)
extern char *shell_name;
#endif
extern int shell_initialized;
extern int builtin_ignoring_errexit;
/* -c, -s invocation options -- not really flags, but they show up in $- */
extern int want_pending_command, read_from_stdin;
/* **************************************************************** */
/* */
/* The Standard sh Flags. */
/* */
/* **************************************************************** */
/* Non-zero means automatically mark variables which are modified or created
as auto export variables. */
int mark_modified_vars = 0;
/* Non-zero causes asynchronous job notification. Otherwise, job state
notification only takes place just before a primary prompt is printed. */
int asynchronous_notification = 0;
/* Non-zero means exit immediately if a command exits with a non-zero
exit status. The first is what controls set -e; the second is what
bash uses internally. */
int errexit_flag = 0;
int exit_immediately_on_error = 0;
/* Non-zero means disable filename globbing. */
int disallow_filename_globbing = 0;
/* Non-zero means that all keyword arguments are placed into the environment
for a command, not just those that appear on the line before the command
name. */
int place_keywords_in_env = 0;
/* Non-zero means read commands, but don't execute them. This is useful
for debugging shell scripts that should do something hairy and possibly
destructive. */
int read_but_dont_execute = 0;
/* Non-zero means end of file is after one command. */
int just_one_command = 0;
/* Non-zero means don't overwrite existing files while doing redirections. */
int noclobber = 0;
/* Non-zero means trying to get the value of $i where $i is undefined
causes an error, instead of a null substitution. */
int unbound_vars_is_error = 0;
/* Non-zero means type out input lines after you read them. */
int echo_input_at_read = 0;
/* Non-zero means type out the command definition after reading, but
before executing. */
int echo_command_at_execute = 0;
/* Non-zero means turn on the job control features. */
int jobs_m_flag = 0;
/* Non-zero means this shell is interactive, even if running under a
pipe. */
int forced_interactive = 0;
/* By default, follow the symbolic links as if they were real directories
while hacking the `cd' command. This means that `cd ..' moves up in
the string of symbolic links that make up the current directory, instead
of the absolute directory. The shell variable `nolinks' also controls
this flag. */
int no_symbolic_links = 0;
/* **************************************************************** */
/* */
/* Non-Standard Flags Follow Here. */
/* */
/* **************************************************************** */
#if 0
/* Non-zero means do lexical scoping in the body of a FOR command. */
int lexical_scoping = 0;
#endif
/* Non-zero means no such thing as invisible variables. */
int no_invisible_vars = 0;
/* Non-zero means look up and remember command names in a hash table, */
int hashing_enabled = 1;
#if defined (BANG_HISTORY)
/* Non-zero means that we are doing history expansion. The default.
This means !22 gets the 22nd line of history. */
# if defined (STRICT_POSIX)
int history_expansion = 0;
# else
int history_expansion = 1;
# endif
#endif /* BANG_HISTORY */
/* Non-zero means that we allow comments to appear in interactive commands. */
int interactive_comments = 1;
#if defined (RESTRICTED_SHELL)
/* Non-zero means that this shell is `restricted'. A restricted shell
disallows: changing directories, command or path names containing `/',
unsetting or resetting the values of $PATH and $SHELL, and any type of
output redirection. */
int restricted = 0; /* currently restricted */
int restricted_shell = 0; /* shell was started in restricted mode. */
#endif /* RESTRICTED_SHELL */
/* Non-zero means that this shell is running in `privileged' mode. This
is required if the shell is to run setuid. If the `-p' option is
not supplied at startup, and the real and effective uids or gids
differ, disable_priv_mode is called to relinquish setuid status. */
int privileged_mode = 0;
#if defined (BRACE_EXPANSION)
/* Zero means to disable brace expansion: foo{a,b} -> fooa foob */
int brace_expansion = 1;
#endif
/* Non-zero means that shell functions inherit the DEBUG trap. */
int function_trace_mode = 0;
/* Non-zero means that shell functions inherit the ERR trap. */
int error_trace_mode = 0;
/* Non-zero means that the rightmost non-zero exit status in a pipeline
is the exit status of the entire pipeline. If each processes exits
with a 0 status, the status of the pipeline is 0. */
int pipefail_opt = 0;
/* **************************************************************** */
/* */
/* The Flags ALIST. */
/* */
/* **************************************************************** */
const struct flags_alist shell_flags[] = {
/* Standard sh flags. */
{ 'a', &mark_modified_vars },
#if defined (JOB_CONTROL)
{ 'b', &asynchronous_notification },
#endif /* JOB_CONTROL */
{ 'e', &errexit_flag },
{ 'f', &disallow_filename_globbing },
{ 'h', &hashing_enabled },
{ 'i', &forced_interactive },
{ 'k', &place_keywords_in_env },
#if defined (JOB_CONTROL)
{ 'm', &jobs_m_flag },
#endif /* JOB_CONTROL */
{ 'n', &read_but_dont_execute },
{ 'p', &privileged_mode },
#if defined (RESTRICTED_SHELL)
{ 'r', &restricted },
#endif /* RESTRICTED_SHELL */
{ 't', &just_one_command },
{ 'u', &unbound_vars_is_error },
{ 'v', &echo_input_at_read },
{ 'x', &echo_command_at_execute },
/* New flags that control non-standard things. */
#if 0
{ 'l', &lexical_scoping },
#endif
#if defined (BRACE_EXPANSION)
{ 'B', &brace_expansion },
#endif
{ 'C', &noclobber },
{ 'E', &error_trace_mode },
#if defined (BANG_HISTORY)
{ 'H', &history_expansion },
#endif /* BANG_HISTORY */
{ 'I', &no_invisible_vars },
{ 'P', &no_symbolic_links },
{ 'T', &function_trace_mode },
{0, (int *)NULL}
};
#define NUM_SHELL_FLAGS (sizeof (shell_flags) / sizeof (struct flags_alist))
char optflags[NUM_SHELL_FLAGS+4] = { '+' };
int *
find_flag (name)
int name;
{
int i;
for (i = 0; shell_flags[i].name; i++)
{
if (shell_flags[i].name == name)
return (shell_flags[i].value);
}
return (FLAG_UNKNOWN);
}
/* Change the state of a flag, and return it's original value, or return
FLAG_ERROR if there is no flag FLAG. ON_OR_OFF must be either
FLAG_ON or FLAG_OFF. */
int
change_flag (flag, on_or_off)
int flag;
int on_or_off;
{
int *value, old_value;
#if defined (RESTRICTED_SHELL)
/* Don't allow "set +r" in a shell which is `restricted'. */
if (restricted && flag == 'r' && on_or_off == FLAG_OFF)
return (FLAG_ERROR);
#endif /* RESTRICTED_SHELL */
value = find_flag (flag);
if ((value == (int *)FLAG_UNKNOWN) || (on_or_off != FLAG_ON && on_or_off != FLAG_OFF))
return (FLAG_ERROR);
old_value = *value;
*value = (on_or_off == FLAG_ON) ? 1 : 0;
/* Special cases for a few flags. */
switch (flag)
{
#if defined (BANG_HISTORY)
case 'H':
if (on_or_off == FLAG_ON)
bash_initialize_history ();
break;
#endif
#if defined (JOB_CONTROL)
case 'm':
set_job_control (on_or_off == FLAG_ON);
break;
#endif /* JOB_CONTROL */
case 'e':
exit_immediately_on_error = errexit_flag;
break;
case 'n':
if (interactive_shell)
read_but_dont_execute = 0;
break;
case 'p':
if (on_or_off == FLAG_OFF)
disable_priv_mode ();
break;
#if defined (RESTRICTED_SHELL)
case 'r':
if (on_or_off == FLAG_ON && shell_initialized)
maybe_make_restricted (shell_name);
break;
#endif
}
return (old_value);
}
/* Return a string which is the names of all the currently
set shell flags. */
char *
which_set_flags ()
{
char *temp;
int i, string_index;
temp = (char *)xmalloc (1 + NUM_SHELL_FLAGS + read_from_stdin + want_pending_command);
for (i = string_index = 0; shell_flags[i].name; i++)
if (*(shell_flags[i].value))
temp[string_index++] = shell_flags[i].name;
if (want_pending_command)
temp[string_index++] = 'c';
if (read_from_stdin)
temp[string_index++] = 's';
temp[string_index] = '\0';
return (temp);
}
void
reset_shell_flags ()
{
mark_modified_vars = exit_immediately_on_error = disallow_filename_globbing = 0;
place_keywords_in_env = read_but_dont_execute = just_one_command = 0;
noclobber = unbound_vars_is_error = echo_input_at_read = 0;
echo_command_at_execute = jobs_m_flag = forced_interactive = 0;
no_symbolic_links = no_invisible_vars = privileged_mode = pipefail_opt = 0;
hashing_enabled = interactive_comments = 1;
#if defined (JOB_CONTROL)
asynchronous_notification = 0;
#endif
#if defined (BANG_HISTORY)
history_expansion = 1;
#endif
#if defined (BRACE_EXPANSION)
brace_expansion = 1;
#endif
#if defined (RESTRICTED_SHELL)
restricted = 0;
#endif
}
void
initialize_flags ()
{
register int i;
for (i = 0; shell_flags[i].name; i++)
optflags[i+1] = shell_flags[i].name;
optflags[++i] = 'o';
optflags[++i] = ';';
optflags[i+1] = '\0';
}
+2 -1
View File
@@ -41,7 +41,8 @@ extern const struct flags_alist shell_flags[];
extern char optflags[];
extern int
mark_modified_vars, exit_immediately_on_error, disallow_filename_globbing,
mark_modified_vars, errexit_flag, exit_immediately_on_error,
disallow_filename_globbing,
place_keywords_in_env, read_but_dont_execute,
just_one_command, unbound_vars_is_error, echo_input_at_read,
echo_command_at_execute, no_invisible_vars, noclobber,
+79
View File
@@ -0,0 +1,79 @@
/* flags.h -- a list of all the flags that the shell knows about. You add
a flag to this program by adding the name here, and in flags.c. */
/* Copyright (C) 1993-2009 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined (_FLAGS_H_)
#define _FLAGS_H_
#include "stdc.h"
/* Welcome to the world of Un*x, where everything is slightly backwards. */
#define FLAG_ON '-'
#define FLAG_OFF '+'
#define FLAG_ERROR -1
#define FLAG_UNKNOWN (int *)0
/* The thing that we build the array of flags out of. */
struct flags_alist {
char name;
int *value;
};
extern const struct flags_alist shell_flags[];
extern char optflags[];
extern int
mark_modified_vars, exit_immediately_on_error, disallow_filename_globbing,
place_keywords_in_env, read_but_dont_execute,
just_one_command, unbound_vars_is_error, echo_input_at_read,
echo_command_at_execute, no_invisible_vars, noclobber,
hashing_enabled, forced_interactive, privileged_mode, jobs_m_flag,
asynchronous_notification, interactive_comments, no_symbolic_links,
function_trace_mode, error_trace_mode, pipefail_opt;
#if 0
extern int lexical_scoping;
#endif
#if defined (BRACE_EXPANSION)
extern int brace_expansion;
#endif
#if defined (BANG_HISTORY)
extern int history_expansion;
#endif /* BANG_HISTORY */
#if defined (RESTRICTED_SHELL)
extern int restricted;
extern int restricted_shell;
#endif /* RESTRICTED_SHELL */
extern int *find_flag __P((int));
extern int change_flag __P((int, int));
extern char *which_set_flags __P((void));
extern void reset_shell_flags __P((void));
extern void initialize_flags __P((void));
/* A macro for efficiency. */
#define change_flag_char(flag, on_or_off) change_flag (flag, on_or_off)
#endif /* _FLAGS_H_ */
+3
View File
@@ -547,6 +547,9 @@ PATSCAN (string, end, delim)
cchar = 0;
bfirst = NULL;
if (string == end)
return (NULL);
for (s = string; c = *s; s++)
{
if (s >= end)
+37 -8
View File
@@ -169,6 +169,7 @@ int _rl_last_v_pos = 0;
static int cpos_adjusted;
static int cpos_buffer_position;
static int displaying_prompt_first_line;
static int prompt_multibyte_chars;
/* Number of lines currently on screen minus 1. */
@@ -964,7 +965,7 @@ rl_redisplay ()
/* If we can move the cursor up and down, then use multiple lines,
otherwise, let long lines display in a single terminal line, and
horizontally scroll it. */
displaying_prompt_first_line = 1;
if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
{
int nleft, pos, changed_screen_line, tx;
@@ -1218,6 +1219,8 @@ rl_redisplay ()
else
lmargin = last_lmargin;
displaying_prompt_first_line = lmargin < nleft;
/* If the first character on the screen isn't the first character
in the display line, indicate this with a special character. */
if (lmargin > 0)
@@ -1243,7 +1246,8 @@ rl_redisplay ()
_rl_screenwidth + (lmargin ? 0 : wrap_offset),
0);
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
displaying_prompt_first_line && OLD_CPOS_IN_PROMPT())
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
/* If the visible new line is shorter than the old, but the number
@@ -1251,7 +1255,7 @@ rl_redisplay ()
the new line, we need to clear to eol. */
t = _rl_last_c_pos - M_OFFSET (lmargin, wrap_offset);
if ((M_OFFSET (lmargin, wrap_offset) > visible_wrap_offset) &&
(_rl_last_c_pos == out) &&
(_rl_last_c_pos == out) && displaying_prompt_first_line &&
t < visible_first_line_len)
{
nleft = _rl_screenwidth - t;
@@ -1672,7 +1676,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* If nfd begins before any invisible characters in the prompt,
adjust _rl_last_c_pos to account for wrap_offset and set
cpos_adjusted to let the caller know. */
if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
if (current_line == 0 && wrap_offset &&
displaying_prompt_first_line &&
((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
@@ -1729,7 +1735,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* If nfd begins before the last invisible character in the
prompt, adjust _rl_last_c_pos to account for wrap_offset
and set cpos_adjusted to let the caller know. */
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && displaying_prompt_first_line && wrap_offset && ((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
@@ -1753,7 +1759,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* If nfd begins before the last invisible character in the
prompt, adjust _rl_last_c_pos to account for wrap_offset
and set cpos_adjusted to let the caller know. */
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && displaying_prompt_first_line && wrap_offset && ((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
@@ -1771,6 +1777,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
a physical character position. */
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
current_line == prompt_last_screen_line && wrap_offset &&
displaying_prompt_first_line &&
wrap_offset != prompt_invis_chars_first_line &&
((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth))))
{
@@ -1788,9 +1795,18 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
prompt string, don't bother. It screws up the assumptions
about what's on the screen. */
if (_rl_horizontal_scroll_mode && _rl_last_c_pos == 0 &&
displaying_prompt_first_line &&
-lendiff == visible_wrap_offset)
col_lendiff = 0;
/* If we have moved lmargin and we're shrinking the line, we've
already moved the cursor to the first character of the new line,
so deleting -col_lendiff characters will mess up the cursor
position calculation */
if (_rl_horizontal_scroll_mode && displaying_prompt_first_line == 0 &&
col_lendiff && _rl_last_c_pos < -col_lendiff)
col_lendiff = 0;
if (col_lendiff)
delete_chars (-col_lendiff); /* delete (diff) characters */
@@ -1806,7 +1822,10 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
_rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
if (current_line == 0 && wrap_offset && _rl_last_c_pos > wrap_offset && ((nfd - new) <= prompt_last_invisible))
if (current_line == 0 && wrap_offset &&
displaying_prompt_first_line &&
_rl_last_c_pos > wrap_offset &&
((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
@@ -1814,6 +1833,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
}
else
_rl_last_c_pos += temp;
if (_rl_horizontal_scroll_mode && ((oe-old) > (ne-new)))
goto clear_rest_of_line;
}
}
/* Otherwise, print over the existing material. */
@@ -1829,13 +1851,17 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
_rl_last_c_pos += col_temp; /* XXX */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
if (current_line == 0 && wrap_offset && _rl_last_c_pos > wrap_offset && ((nfd - new) <= prompt_last_invisible))
if (current_line == 0 && wrap_offset &&
displaying_prompt_first_line &&
_rl_last_c_pos > wrap_offset &&
((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
}
}
}
clear_rest_of_line:
lendiff = (oe - old) - (ne - new);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1);
@@ -2003,6 +2029,9 @@ _rl_move_cursor_relative (new, data)
else
dpos = _rl_col_width (data, 0, new, 1);
if (displaying_prompt_first_line == 0)
adjust = 0;
/* Use NEW when comparing against the last invisible character in the
prompt string, since they're both buffer indices and DPOS is a
desired display position. */
File diff suppressed because it is too large Load Diff
+4
View File
@@ -1239,6 +1239,10 @@ bind_arrow_keys_internal (map)
rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history);
rl_bind_keyseq_if_unbound ("\340M", rl_forward_char);
rl_bind_keyseq_if_unbound ("\340K", rl_backward_char);
rl_bind_keyseq_if_unbound ("\340G", rl_beg_of_line);
rl_bind_keyseq_if_unbound ("\340O", rl_end_of_line);
rl_bind_keyseq_if_unbound ("\340S", rl_delete);
rl_bind_keyseq_if_unbound ("\340R", rl_overwrite_mode);
#endif
_rl_keymap = xkeymap;
+2
View File
@@ -150,6 +150,8 @@ zreadcintr (fd, cp)
return 1;
}
/* Like zreadc, but read a specified number of characters at a time. Used
for `read -N'. */
ssize_t
zreadn (fd, cp, len)
int fd;
+26
View File
@@ -150,6 +150,32 @@ zreadcintr (fd, cp)
return 1;
}
ssize_t
zreadn (fd, cp, len)
int fd;
char *cp;
size_t len;
{
ssize_t nr;
if (lind == lused || lused == 0)
{
if (len > sizeof (lbuf))
len = sizeof (lbuf);
nr = zread (fd, lbuf, len);
lind = 0;
if (nr <= 0)
{
lused = 0;
return nr;
}
lused = nr;
}
if (cp)
*cp = lbuf[lind++];
return 1;
}
void
zreset ()
{
+3 -1
View File
@@ -166,6 +166,7 @@ extern struct fd_bitmap *current_fds_to_close;
extern int wordexp_only;
extern int expanding_redir;
extern int tempenv_assign_error;
extern int builtin_ignoring_errexit;
#if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE)
extern wchar_t *wcsdup __P((const wchar_t *));
@@ -5394,7 +5395,8 @@ command_substitute (string, quoted)
the -e flag. */
if (posixly_correct == 0)
{
exit_immediately_on_error = 0;
builtin_ignoring_errexit = 0;
change_flag ('e', FLAG_OFF);
set_shellopts ();
}
+9556
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR