- experimental: print a warning, but go on, if line editing not active
when bind is invoked. Suggested by Rocky Bernstein
<rocky.bernstein@gmail.com>
+
+ 10/3
+ ----
+test.c
+ - use same_file instead of directly comparing st_dev and st_ino when
+ comparing files in filecomp(). From mingw32 patches submitted
+ by Hector Chu <hkcc2@cantab.net>
+
+ 10/4
+ ----
+
+redir.c
+ - in redirection_error(), use `error' instead of errno when comparing
+ against EBADF. From mingw32 patches submitted by Hector Chu
+ <hkcc2@cantab.net>
+
+shell.c
+ - in unset_bash_input(), reset bash_input.type to st_none after
+ closing the default buffered fd. From mingw32 patches submitted
+ by Hector Chu <hkcc2@cantab.net>
+
+builtins/cd.def
+ - ignore CDPATH when in privileged mode. Suggested by Paul Jarc
+ <prj@po.cwru.edu>
+
+variables.c
+ - change sv_globignore to only act if privileged mode is not enabled.
+ Suggested by Paul Jarc <prj@po.cwru.edu>
+
+doc/bash.1,bashref.texi
+ - document new treatment of CDPATH and GLOBIGNORE when privileged
+ mode is enabled
+
+builtins/read.def
+ - change prompt printing to occur after terminal is set to no-echo
+ mode. Based on suggestion from Stephane Chazelas
+ <stephane_chazelas@yahoo.fr>
+
+lib/readline/signals.c
+ - new variables to keep track of special characters corresponding to
+ SIGINT, SIGQUIT, and SIGTSTP
+ - new variable to keep track of whether tty is echoing control
+ characters corresponding to SIGINT, SIGQUIT, and SIGTSTP
+ - new function, _rl_echo_signal_char(int sig) to display the tty
+ special char generating SIGINT, SIGQUIT, or SIGTSTP. Based on
+ idea and code from Joe Peterson <joe@skyrush.com>
+ - call rl_echo_signal_char in rl_signal_handler: if the terminal
+ settings indicate it, readline will echo characters that generate
+ keyboard signals
+
+lib/readline/rltty.c
+ - set _rl_intr_char, _rl_quit_char, and _rl_susp_char to special
+ characters that generate signals from keyboard
+ - set _rl_echoctl if ECHOCTL tty flag is set
+
+lib/readline/rlprivate.h
+ - extern declarations for _rl_intr_char, _rl_quit_char, and
+ _rl_susp_char
+ - extern declaration for _rl_echoctl
+
+lib/readline/readline.h
+ - extern declaration for rl_echo_signal_char()
+
+lib/readline/doc/rltech.texi
+ - document rl_echo_signal_handler(): available for applications
+ that install their own signal handlers
+
+ 10/5
+ ----
+execute_cmd.c
+ - fix errexit logic to not cause the shell to exit when a command in
+ a pipeline fails. Fixes bug reported by Marcin Owsiany
+ <marcin@owsiany.pl>
interrupt occurred. The behavior is dependent on the shell
compatibility level being > 32 (bash-4.0 and above)
- 9/24
+ 9/23
----
+redir.c
+ - don't bother reporting an error with a file descriptor, even if
+ the errno is EBADF, if the redirection error (e.g., NOCLOBBER)
+ can't have anything to do with the fd. Fixes bug reported by
+ "David A. Harding" <dave@dtrt.org>, debian bug #499633.
+
+ 9/24
+ ----
builtins/declare.def
- make `declare [option] var' (and the `typeset' equivalent) create
invisible variables, instead of assigning the null string to a
- visible variable
+ visible variable. Fixes bug reported by Bernd Eggink <monoped@sudrala.de>
+
+ 9/25
+ ----
+builtins/common.[ch]
+ - new function, builtin_warning(), like builtin_error but for warning
+ messages
+
+builtins/bind.def
+ - experimental: print a warning, but go on, if line editing not active
+ when bind is invoked. Suggested by Rocky Bernstein
+ <rocky.bernstein@gmail.com>
+
+ 10/3
+ ----
+test.c
+ - use same_file instead of directly comparing st_dev and st_ino when
+ comparing files in filecomp(). From mingw32 patches submitted
+ by Hector Chu <hkcc2@cantab.net>
+
+ 10/4
+ ----
+
+redir.c
+ - in redirection_error(), use `error' instead of errno when comparing
+ against EBADF. From mingw32 patches submitted by Hector Chu
+ <hkcc2@cantab.net>
+
+shell.c
+ - in unset_bash_input(), reset bash_input.type to st_none after
+ closing the default buffered fd. From mingw32 patches submitted
+ by Hector Chu <hkcc2@cantab.net>
+
+builtins/cd.def
+ - ignore CDPATH when in privileged mode. Suggested by Paul Jarc
+ <prj@po.cwru.edu>
+
+variables.c
+ - change sv_globignore to only act if privileged mode is not enabled.
+ Suggested by Paul Jarc <prj@po.cwru.edu>
+
+doc/bash.1,bashref.texi
+ - document new treatment of CDPATH and GLOBIGNORE when privileged
+ mode is enabled
+
+builtins/read.def
+ - change prompt printing to occur after terminal is set to no-echo
+ mode. Based on suggestion from Stephane Chazelas
+ <stephane_chazelas@yahoo.fr>
+
+lib/readline/signals.c
+ - new variables to keep track of special characters corresponding to
+ SIGINT, SIGQUIT, and SIGTSTP
+ - new variable to keep track of whether tty is echoing control
+ characters corresponding to SIGINT, SIGQUIT, and SIGTSTP
+ - new function, _rl_echo_signal_char(int sig) to display the tty
+ special char generating SIGINT, SIGQUIT, or SIGTSTP. Based on
+ idea and code from Joe Peterson <joe@skyrush.com>
+ - call rl_echo_signal_char in rl_signal_handler: if the terminal
+ settings indicate it, readline will echo characters that generate
+ keyboard signals
+
+lib/readline/rltty.c
+ - set _rl_intr_char, _rl_quit_char, and _rl_susp_char to special
+ characters that generate signals from keyboard
+ - set _rl_echoctl if ECHOCTL tty flag is set
+
+lib/readline/rlprivate.h
+ - extern declarations for _rl_intr_char, _rl_quit_char, and
+ _rl_susp_char
+ - extern declaration for _rl_echoctl
+
+lib/readline/readline.h
+ - extern declaration for rl_echo_signal_char()
+
+lib/readline/doc/rltech.texi
+ - document rl_echo_signal_handler(): available for applications
+ that install their own signal handlers
+
+ 10/5
+ ----
+execute_cmd.c
+ - fix errexit logic to not cause the shell to exit when a command in
+ a pipeline fails
}
else if (absolute_pathname (list->word->word))
dirname = list->word->word;
- else if (cdpath = get_string_value ("CDPATH"))
+ else if (privileged_mode == 0 && (cdpath = get_string_value ("CDPATH")))
{
dirname = list->word->word;
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 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.
+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.
+You should have received a copy of the GNU General Public License
+along with Bash. If not, see <http://www.gnu.org/licenses/>.
$PRODUCES cd.c
#include <config.h>
links
The default is to follow symbolic links, as if `-L' were specified.
+
+Exit Status:
+Returns 0 if the directory is changed; non-zero otherwise.
$END
/* Just set $PWD, don't change OLDPWD. Used by `pwd -P' in posix mode. */
-P print the physical directory, without any symbolic links
By default, `pwd' behaves as if `-L' were specified.
+
+Exit Status:
+Returns 0 unless an invalid option is given or the current directory
+cannot be read.
$END
/* Non-zero means that pwd always prints the physical directory, without
add_unwind_protect (xfree, rlbuf);
#endif
- if (prompt && edit == 0)
- {
- fprintf (stderr, "%s", prompt);
- fflush (stderr);
- }
-
pass_next = 0; /* Non-zero signifies last char was backslash. */
saw_escape = 0; /* Non-zero signifies that we saw an escape char */
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
+ if (prompt && edit == 0)
+ {
+ fprintf (stderr, "%s", prompt);
+ fflush (stderr);
+ }
+
#if defined (__CYGWIN__) && defined (O_TEXT)
setmode (0, O_TEXT);
#endif
-t timeout time out and return failure if a complete line of input is
not read withint TIMEOUT seconds. The value of the TMOUT
variable is the default timeout. TIMEOUT may be a
- fractional number. The exit status is greater than 128 if
- the timeout is exceeded
+ fractional number. If TIMEOUT is 0, read returns success only
+ if input is available on the specified file descriptor. The
+ exit status is greater than 128 if the timeout is exceeded
-u fd read from file descriptor FD instead of the standard input
Exit Status:
terminal, turn them off. */
if ((prompt || edit || silent) && input_is_tty == 0)
{
+itrace("read_builtin: input_is_tty == 0: disabling silent");
prompt = (char *)NULL;
#if defined (READLINE)
itext = (char *)NULL;
add_unwind_protect (xfree, rlbuf);
#endif
+#if 0
if (prompt && edit == 0)
{
fprintf (stderr, "%s", prompt);
fflush (stderr);
}
+#endif
pass_next = 0; /* Non-zero signifies last char was backslash. */
saw_escape = 0; /* Non-zero signifies that we saw an escape char */
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
+#if 1
+ if (prompt && edit == 0)
+ {
+ fprintf (stderr, "%s", prompt);
+ fflush (stderr);
+ }
+#endif
+
#if defined (__CYGWIN__) && defined (O_TEXT)
setmode (0, O_TEXT);
#endif
# if defined (HPUX) && defined (RLIMIT_NEEDS_KERNEL)
# undef _KERNEL
# endif
-#else
+#elif defined (HAVE_SYS_TIMES_H)
# include <sys/times.h>
#endif
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 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.
+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.
+You should have received a copy of the GNU General Public License
+along with Bash. If not, see <http://www.gnu.org/licenses/>.
$PRODUCES ulimit.c
otherwise. */
#define POSIXBLK -2
-#define BLOCKSIZE(x) (((x) == POSIXBLK && posixly_correct) ? 512 : (x))
+#define BLOCKSIZE(x) (((x) == POSIXBLK && posixly_correct) ? 512 : 1024)
extern int posixly_correct;
/* command.h -- The structures used internally to represent commands, and
the extern declarations of the functions used to create them. */
-/* Copyright (C) 1993-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2008 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 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.
+ 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. */
+ 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 (_COMMAND_H_)
#define _COMMAND_H_
/* Command Types: */
enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
cm_connection, cm_function_def, cm_until, cm_group,
- cm_arith, cm_cond, cm_arith_for, cm_subshell };
+ cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc };
/* Possible values for the `flags' field of a WORD_DESC. */
#define W_HASDOLLAR 0x000001 /* Dollar sign present. */
#define CMD_AMPERSAND 0x200 /* command & */
#define CMD_STDIN_REDIR 0x400 /* async command needs implicit </dev/null */
#define CMD_COMMAND_BUILTIN 0x0800 /* command executed by `command' builtin */
+#define CMD_COPROC_SUBSHELL 0x1000
+#define CMD_NOERREXIT 0x2000 /* Don't exit even if errexit set */
/* What a command looks like. */
typedef struct command {
struct arith_for_com *ArithFor;
#endif
struct subshell_com *Subshell;
+ struct coproc_com *Coproc;
} value;
} COMMAND;
/* Structures used to represent the CASE command. */
/* Values for FLAGS word in a PATTERN_LIST */
-#define CASEPAT_FALLTHROUGH 0x01
-#define CASEPAT_TESTNEXT 0x02
+#define CASEPAT_FALLTHROUGH 0x01
+#define CASEPAT_TESTNEXT 0x02
/* Pattern/action structure for CASE_COM. */
typedef struct pattern_list {
COMMAND *command;
} SUBSHELL_COM;
+typedef struct coproc {
+ char *c_name;
+ pid_t c_pid;
+ int c_rfd;
+ int c_wfd;
+ int c_rsave;
+ int c_wsave;
+ int c_flags;
+ int c_status;
+} Coproc;
+
+typedef struct coproc_com {
+ int flags;
+ char *name;
+ COMMAND *command;
+} COPROC_COM;
+
extern COMMAND *global_command;
+extern Coproc sh_coproc;
/* Possible command errors */
#define CMDERR_DEFAULT 0
.TP 8
.B filenames
Tell readline that the compspec generates filenames, so it can perform any
-filename\-specific processing (like adding a slash to directory names or
-suppressing trailing spaces). Intended to be used with shell functions.
+filename\-specific processing (like adding a slash to directory names,
+quoting special characters, or suppressing trailing spaces).
+Intended to be used with shell functions.
.TP 8
.B nospace
Tell readline not to append a space (the default) to words completed at
files are not processed, shell functions are not inherited from the
environment, and the
.SM
-.B SHELLOPTS
-variable, if it appears in the environment, is ignored.
+.BR SHELLOPTS ,
+.BR CDPATH ,
+and
+.B GLOBIGNORE
+variables, if they appear in the environment, are ignored.
If the shell is started with the effective user (group) id not equal to the
real user (group) id, and the \fB\-p\fP option is not supplied, these actions
are taken and the effective user id is set to the real user id.
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
-.\" Last Change: Sat Sep 6 13:05:54 EDT 2008
+.\" Last Change: Sat Sep 13 18:27:41 EDT 2008
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
-.TH BASH 1 "2008 September 6" "GNU Bash-4.0"
+.TH BASH 1 "2008 September 13" "GNU Bash-4.0"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
shell, unless the
.B \-\-noediting
option is given at shell invocation.
+Line editing is also used when using the \fB\-e\fP option to the
+\fBread\fP builtin.
By default, the line editing commands are similar to those of emacs.
A vi-style line editing interface is also available.
-To turn off line editing after the shell is running, use the
-.B +o emacs
+Line editing can be enabled at any time using the
+.B \-o emacs
or
-.B +o vi
+.B \-o vi
options to the
.B set
builtin (see
.SM
.B SHELL BUILTIN COMMANDS
below).
+To turn off line editing after the shell is running, use the
+.B +o emacs
+or
+.B +o vi
+options to the
+.B set
+builtin.
.SS "Readline Notation"
.PP
In this section, the emacs-style notation is used to denote
.TP 8
.B filenames
Tell readline that the compspec generates filenames, so it can perform any
-filename\-specific processing (like adding a slash to directory names or
-suppressing trailing spaces). Intended to be used with shell functions.
+filename\-specific processing (like adding a slash to directory names,
+quoting special characters, or suppressing trailing spaces).
+Intended to be used with shell functions.
.TP 8
.B nospace
Tell readline not to append a space (the default) to words completed at
.SM
.B READLINE
above) is used to obtain the line.
+Readline uses the current (or default, if line editing was not previously
+active) editing settings.
.TP
.B \-i \fItext\fP
If
with the
.B \-\-noediting
option.
+This also affects the editing interface used for \fBread \-e\fP.
.TP 8
.B errtrace
Same as
.TP 8
.B vi
Use a vi-style command line editing interface.
+This also affects the editing interface used for \fBread \-e\fP.
.TP 8
.B xtrace
Same as
Turn on privileged mode.
In this mode, the @env{$BASH_ENV} and @env{$ENV} files are not
processed, shell functions are not inherited from the environment,
-and the @env{SHELLOPTS} variable, if it appears in the environment,
-is ignored.
+and the @env{SHELLOPTS}, @env{CDPATH} and @env{GLOBIGNORE} variables,
+if they appear in the environment, are ignored.
If the shell is started with the effective user (group) id not equal to the
real user (group) id, and the @code{-p} option is not supplied, these actions
are taken and the effective user id is set to the real user id.
@item -e
Readline (@pxref{Command Line Editing}) is used to obtain the line.
+Readline uses the current (or default, if line editing was not previously
+active) editing settings.
@item -i @var{text}
If Readline is being used to read the line, @var{text} is placed into
@item emacs
Use an @code{emacs}-style line editing interface (@pxref{Command Line Editing}).
+This also affects the editing interface used for @code{read -e}.
@item errexit
Same as @code{-e}.
@item vi
Use a @code{vi}-style line editing interface.
+This also affects the editing interface used for @code{read -e}.
@item xtrace
Same as @code{-x}.
}
}
- if (was_error_trap && ignore_return == 0 && invert == 0 && exec_result != EXECUTION_SUCCESS)
+ /* 10/6/2008 -- added test for pipe_in and pipe_out because they indicate
+ the presence of a pipeline, and (until Posix changes things), a
+ pipeline failure should not cause the parent shell to exit on an
+ unsuccessful return status, even in the presence of errexit.. */
+ if (was_error_trap && ignore_return == 0 && invert == 0 && pipe_in == NO_PIPE && pipe_out == NO_PIPE && exec_result != EXECUTION_SUCCESS)
{
last_command_exit_value = exec_result;
run_error_trap ();
if (ignore_return == 0 && invert == 0 &&
((posixly_correct && interactive == 0 && special_builtin_failed) ||
- (exit_immediately_on_error && (exec_result != EXECUTION_SUCCESS))))
+ (exit_immediately_on_error && pipe_in == NO_PIPE && pipe_out == NO_PIPE && exec_result != EXECUTION_SUCCESS)))
{
last_command_exit_value = exec_result;
run_pending_traps ();
add_unwind_protect ((Function *)dispose_redirects, exec_undo_list);
ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0;
-
+itrace("execute_command_internal: ignore_return = %d", ignore_return);
QUIT;
switch (command->type)
}
}
- if (was_error_trap && ignore_return == 0 && invert == 0 && exec_result != EXECUTION_SUCCESS)
+ /* 10/6/2008 -- added test for pipe_in and pipe_out because they indicate
+ the presence of a pipeline, and (until Posix changes things), a
+ pipeline failure should not cause the parent shell to exit on an
+ unsuccessful return status, even in the presence of errexit.. */
+ if (was_error_trap && ignore_return == 0 && invert == 0 && pipe_in == NO_PIPE && pipe_out == NO_PIPE && exec_result != EXECUTION_SUCCESS)
{
last_command_exit_value = exec_result;
+itrace("execute_command: simple_command: exit_immediately_on_error = %d pipe_in = %d pipe_out = %d running error trap", exit_immediately_on_error, pipe_in, pipe_out);
run_error_trap ();
}
if (ignore_return == 0 && invert == 0 &&
((posixly_correct && interactive == 0 && special_builtin_failed) ||
- (exit_immediately_on_error && (exec_result != EXECUTION_SUCCESS))))
+ (exit_immediately_on_error && pipe_in == NO_PIPE && pipe_out == NO_PIPE && exec_result != EXECUTION_SUCCESS)))
{
+itrace("execute_command: simple_command: exec_result = %d, exiting immediately", exec_result);
last_command_exit_value = exec_result;
run_pending_traps ();
jump_to_top_level (ERREXIT);
prev = pipe_in;
cmd = command;
+itrace("execute_pipeline: ignore_return = %d", ignore_return);
while (cmd && cmd->type == cm_connection &&
cmd->value.Connection && cmd->value.Connection->connector == '|')
{
and the connector is OR_OR, then execute the second command,
otherwise return. */
+ executing_list++;
if (command->value.Connection->first)
command->value.Connection->first->flags |= CMD_IGNORE_RETURN;
exec_result = execute_command (command->value.Connection->second);
}
+ executing_list--;
break;
default:
/* Do this now, because execute_disk_command will do it anyway in the
vast majority of cases. */
maybe_make_export_env ();
-
+itrace("execute_simple_command: %s: dofork = 1", the_printed_command_except_trap);
/* Don't let a DEBUG trap overwrite the command string to be saved with
the process/job associated with this child. */
if (make_child (savestring (the_printed_command_except_trap), async) == 0)
#endif
command_line = (char *)NULL; /* don't free this. */
bind_lastarg ((char *)NULL);
+itrace("execute_simple_command: parent: returning %d", result);
return (result);
}
}
((subshell_environment & SUBSHELL_ASYNC) == 0 || pipe_out != NO_PIPE);
#endif
+itrace("execute_subshell_builtin_or_function:");
/* A subshell is neither a login shell nor interactive. */
login_shell = interactive = 0;
Readline to update its idea of the terminal size when a @code{SIGWINCH}
is received.
+@deftypefun rl_echo_signal_char (int sig)
+If an application wishes to install its own signal handlers, but still
+have readline display characters that generate signals, calling this
+function with @var{sig} set to @code{SIGINT}, @code{SIGQUIT}, or
+@code{SIGTSTP} will display the character generating that signal.
+@end deftypefun
+
@deftypefun void rl_resize_terminal (void)
Update Readline's internal screen size by reading values from the kernel.
@end deftypefun
Readline is currently executing the readline signal handler.
@item RL_STATE_UNDOING
Readline is performing an undo.
+@item RL_STATE_INPUTPENDING
+Readline has input pending due to a call to @code{rl_execute_next()}.
+@item RL_STATE_TTYCSAVED
+Readline has saved the values of the terminal's special characters.
+@item RL_STATE_CALLBACK
+Readline is currently using the alternate (callback) interface
+(@pxref{Alternate Interface}).
+@item RL_STATE_VIMOTION
+Readline is reading the argument to a vi-mode "motion" command.
+@item RL_STATE_MULTIKEY
+Readline is reading a multiple-keystroke command.
+@item RL_STATE_VICMDONCE
+Readline has entered vi command (movement) mode at least one time during
+the current call to @code{readline()}.
@item RL_STATE_DONE
Readline has read a key sequence bound to @code{accept-line}
and is about to return the line to the caller.
GNU Readline library. This application interactively allows users
to manipulate files and their modes. */
-#include <stdio.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <sys/types.h>
-#include <sys/file.h>
+#ifdef HAVE_SYS_FILE_H
+# include <sys/file.h>
+#endif
#include <sys/stat.h>
-#include <sys/errno.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+
+#if defined (HAVE_STRING_H)
+# include <string.h>
+#else /* !HAVE_STRING_H */
+# include <strings.h>
+#endif /* !HAVE_STRING_H */
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+#include <time.h>
#include <readline/readline.h>
#include <readline/history.h>
-extern char *xmalloc ();
+extern char *xmalloc PARAMS((size_t));
/* The names of functions that actually do the manipulation. */
-int com_list __P((char *));
-int com_view __P((char *));
-int com_rename __P((char *));
-int com_stat __P((char *));
-int com_pwd __P((char *));
-int com_delete __P((char *));
-int com_help __P((char *));
-int com_cd __P((char *));
-int com_quit __P((char *));
+int com_list PARAMS((char *));
+int com_view PARAMS((char *));
+int com_rename PARAMS((char *));
+int com_stat PARAMS((char *));
+int com_pwd PARAMS((char *));
+int com_delete PARAMS((char *));
+int com_help PARAMS((char *));
+int com_cd PARAMS((char *));
+int com_quit PARAMS((char *));
/* A structure which contains information on the commands this program
can understand. */
/* The name of this program, as taken from argv[0]. */
char *progname;
-/* When non-zero, this means the user is done using this program. */
+/* When non-zero, this global means the user is done using this program. */
int done;
char *
dupstr (s)
- int s;
+ char *s;
@{
char *r;
/* */
/* **************************************************************** */
-char *command_generator __P((const char *, int));
-char **fileman_completion __P((const char *, int, int));
+char *command_generator PARAMS((const char *, int));
+char **fileman_completion PARAMS((const char *, int, int));
-/* Tell the GNU Readline library how to complete. We want to try to
- complete on command names if this is the first word in the line, or
- on filenames if not. */
+/* Tell the GNU Readline library how to complete. We want to try to complete
+ on command names if this is the first word in the line, or on filenames
+ if not. */
initialize_readline ()
@{
/* Allow conditional parsing of the ~/.inputrc file. */
rl_attempted_completion_function = fileman_completion;
@}
-/* Attempt to complete on the contents of TEXT. START and END
- bound the region of rl_line_buffer that contains the word to
- complete. TEXT is the word to complete. We can use the entire
- contents of rl_line_buffer in case we want to do some simple
- parsing. Returnthe array of matches, or NULL if there aren't any. */
+/* Attempt to complete on the contents of TEXT. START and END bound the
+ region of rl_line_buffer that contains the word to complete. TEXT is
+ the word to complete. We can use the entire contents of rl_line_buffer
+ in case we want to do some simple parsing. Return the array of matches,
+ or NULL if there aren't any. */
char **
fileman_completion (text, start, end)
const char *text;
return (matches);
@}
-/* Generator function for command completion. STATE lets us
- know whether to start from scratch; without any state
- (i.e. STATE == 0), then we start at the top of the list. */
+/* Generator function for command completion. STATE lets us know whether
+ to start from scratch; without any state (i.e. STATE == 0), then we
+ start at the top of the list. */
char *
command_generator (text, state)
const char *text;
static int list_index, len;
char *name;
- /* If this is a new word to complete, initialize now. This
- includes saving the length of TEXT for efficiency, and
- initializing the index variable to 0. */
+ /* If this is a new word to complete, initialize now. This includes
+ saving the length of TEXT for efficiency, and initializing the index
+ variable to 0. */
if (!state)
@{
list_index = 0;
len = strlen (text);
@}
- /* Return the next name which partially matches from the
- command list. */
+ /* Return the next name which partially matches from the command list. */
while (name = commands[list_index].name)
@{
list_index++;
if (!valid_argument ("view", arg))
return 1;
+#if defined (__MSDOS__)
+ /* more.com doesn't grok slashes in pathnames */
+ sprintf (syscom, "less %s", arg);
+#else
sprintf (syscom, "more %s", arg);
+#endif
return (system (syscom));
@}
printf ("Statistics for `%s':\n", arg);
- printf ("%s has %d link%s, and is %d byte%s in length.\n", arg,
+ printf ("%s has %d link%s, and is %d byte%s in length.\n",
+ arg,
finfo.st_nlink,
(finfo.st_nlink == 1) ? "" : "s",
finfo.st_size,
return 0;
@}
-/* The user wishes to quit using this program. Just set DONE
- non-zero. */
+/* The user wishes to quit using this program. Just set DONE non-zero. */
com_quit (arg)
char *arg;
@{
char *caller;
@{
fprintf (stderr,
- "%s: Too dangerous for me to distribute.\n",
+ "%s: Too dangerous for me to distribute. Write it yourself.\n",
caller);
- fprintf (stderr, "Write it yourself.\n");
@}
-/* Return non-zero if ARG is a valid argument for CALLER,
- else print an error message and return zero. */
+/* Return non-zero if ARG is a valid argument for CALLER, else print
+ an error message and return zero. */
int
valid_argument (caller, arg)
char *caller, *arg;
@item filenames
Tell Readline that the compspec generates filenames, so it can perform any
-filename-specific processing (like adding a slash to directory names or
-suppressing trailing spaces). This option is intended to be used with
-shell functions specified with @option{-F}.
+filename-specific processing (like adding a slash to directory names
+quoting special characters, or suppressing trailing spaces).
+This option is intended to be used with shell functions specified
+with @option{-F}.
@item nospace
Tell Readline not to append a space (the default) to words completed at
@set EDITION 6.0
@set VERSION 6.0
-@set UPDATED 12 August 2008
-@set UPDATED-MONTH August 2008
+@set UPDATED 4 October 2008
+@set UPDATED-MONTH October 2008
-@set LASTCHANGE Tue Aug 12 16:41:31 EDT 2008
+@set LASTCHANGE Sun Oct 5 00:18:13 EDT 2008
Copyright (C) 1988-2008 Free Software Foundation, Inc.
@end ignore
-@set EDITION 5.2
-@set VERSION 5.2
-@set UPDATED 8 May 2008
-@set UPDATED-MONTH May 2008
+@set EDITION 6.0
+@set VERSION 6.0
+@set UPDATED 12 August 2008
+@set UPDATED-MONTH August 2008
-@set LASTCHANGE Thu May 8 09:29:33 EDT 2008
+@set LASTCHANGE Tue Aug 12 16:41:31 EDT 2008
{
HIST_ENTRY *hs;
+ if (string == 0)
+ return;
hs = the_history[history_length - 1];
FREE (hs->timestamp);
hs->timestamp = savestring (string);
/* history.c -- standalone history library */
-/* Copyright (C) 1989-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2008 Free Software Foundation, Inc.
- This file contains the GNU History Library (the Library), a set of
+ This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
- The Library is free software; you can redistribute it and/or modify
+ History 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.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- The Library 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.
+ History 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.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with History. If not, see <http://www.gnu.org/licenses/>.
+*/
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
{
HIST_ENTRY *hs;
+ if (string == 0)
+ return;
hs = the_history[history_length - 1];
FREE (hs->timestamp);
hs->timestamp = savestring (string);
/* Stop stifling the history. This returns the previous maximum
number of history entries. The value is positive if the history
- was stifled, negative if it wasn't. */
+ was stifled, negative if it wasn't. */
int
unstifle_history ()
{
extern void rl_cleanup_after_signal PARAMS((void));
extern void rl_reset_after_signal PARAMS((void));
extern void rl_free_line_state PARAMS((void));
-
+
+extern void rl_echo_signal_char PARAMS((int));
+
extern int rl_set_paren_blink_timeout PARAMS((int));
/* Undocumented. */
/* Copyright (C) 1987-2008 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.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library 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
+ Readline 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.
- The GNU Readline Library 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
+ Readline 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.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
#if !defined (_READLINE_H_)
#define _READLINE_H_
#endif
/* Hex-encoded Readline version number. */
-#define RL_READLINE_VERSION 0x0502 /* Readline 5.2 */
-#define RL_VERSION_MAJOR 5
-#define RL_VERSION_MINOR 2
+#define RL_READLINE_VERSION 0x0600 /* Readline 6.0 */
+#define RL_VERSION_MAJOR 6
+#define RL_VERSION_MINOR 0
/* Readline data structures. */
extern void rl_cleanup_after_signal PARAMS((void));
extern void rl_reset_after_signal PARAMS((void));
extern void rl_free_line_state PARAMS((void));
-
+
extern int rl_set_paren_blink_timeout PARAMS((int));
/* Undocumented. */
filename completer. */
extern rl_compentry_func_t *rl_completion_entry_function;
+/* Optional generator for menu completion. Default is
+ rl_completion_entry_function (rl_filename_completion_function). */
+ extern rl_compentry_func_t *rl_menu_completion_entry_function;
+
/* If rl_ignore_some_completions_function is non-NULL it is the address
of a function to call after all of the possible matches have been
generated, but before the actual completion is done to the input line.
/* search.c */
extern _rl_search_cxt *_rl_nscxt;
+/* signals.c */
+extern int _rl_echoctl;
+
+extern _rl_intr_char;
+extern _rl_quit_char;
+extern _rl_susp_char;
+
/* terminal.c */
extern int _rl_enable_keypad;
extern int _rl_enable_meta;
extern void _rl_block_sigint PARAMS((void));
extern void _rl_release_sigint PARAMS((void));
+extern void _rl_echo_signal_char PARAMS((int));
+
/* terminal.c */
extern void _rl_get_screen_size PARAMS((int, int));
extern int _rl_init_terminal_io PARAMS((const char *));
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
extern void _rl_ttymsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
extern void _rl_errmsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
+extern void _rl_trace (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
#else
extern void _rl_ttymsg ();
extern void _rl_errmsg ();
+extern void _rl_trace ();
#endif
+extern int _rl_tropen PARAMS((void));
+
extern int _rl_abort_internal PARAMS((void));
extern char *_rl_strindex PARAMS((const char *, const char *));
extern int _rl_qsort_string_compare PARAMS((char **, char **));
/* search.c */
extern _rl_search_cxt *_rl_nscxt;
+/* signals.c */
+extern int _rl_echoctl;
+
+extern _rl_intr_char;
+extern _rl_quit_char;
+extern _rl_susp_char;
+
/* terminal.c */
extern int _rl_enable_keypad;
extern int _rl_enable_meta;
if (tiop->flags & TCHARS_SET)
{
- _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
- _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
+ _rl_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
+ _rl_quit_char = _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
+
_rl_tty_chars.t_start = tiop->tchars.t_startc;
_rl_tty_chars.t_stop = tiop->tchars.t_stopc;
_rl_tty_chars.t_eof = tiop->tchars.t_eofc;
if (tiop->flags & LTCHARS_SET)
{
- _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
+ _rl_susp_char = _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
+
_rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
_rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
_rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
TIOTYPE oldtio, *tiop;
{
_rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
+ _rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL);
/* Copy the original settings to the structure we're going to use for
our settings. */
#ifdef VREPRINT
_rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
#endif
- _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
- _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
+ _rl_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
+ _rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
#ifdef VSUSP
- _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
+ _rl_susp_char = _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
#endif
#ifdef VDSUSP
_rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
TIOTYPE oldtio, *tiop;
{
_rl_echoing_p = (oldtio.c_lflag & ECHO);
+ _rl_echoctl = (oldtio.c_lflag & ECHOCTL);
tiop->c_lflag &= ~(ICANON | ECHO);
/* Copyright (C) 1992-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.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library 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
+ Readline 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.
- The GNU Readline Library 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
+ Readline 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.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
-static void block_sigint PARAMS((void));
-static void release_sigint PARAMS((void));
-
static void set_winsize PARAMS((int));
-/* **************************************************************** */
-/* */
-/* Signal Management */
-/* */
-/* **************************************************************** */
-
-#if defined (HAVE_POSIX_SIGNALS)
-static sigset_t sigint_set, sigint_oset;
-#else /* !HAVE_POSIX_SIGNALS */
-# if defined (HAVE_BSD_SIGNALS)
-static int sigint_oldmask;
-# endif /* HAVE_BSD_SIGNALS */
-#endif /* !HAVE_POSIX_SIGNALS */
-
-static int sigint_blocked;
-
-/* Cause SIGINT to not be delivered until the corresponding call to
- release_sigint(). */
-static void
-block_sigint ()
-{
- if (sigint_blocked)
- return;
-
-#if defined (HAVE_POSIX_SIGNALS)
- sigemptyset (&sigint_set);
- sigemptyset (&sigint_oset);
- sigaddset (&sigint_set, SIGINT);
- sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
-#else /* !HAVE_POSIX_SIGNALS */
-# if defined (HAVE_BSD_SIGNALS)
- sigint_oldmask = sigblock (sigmask (SIGINT));
-# else /* !HAVE_BSD_SIGNALS */
-# if defined (HAVE_USG_SIGHOLD)
- sighold (SIGINT);
-# endif /* HAVE_USG_SIGHOLD */
-# endif /* !HAVE_BSD_SIGNALS */
-#endif /* !HAVE_POSIX_SIGNALS */
-
- sigint_blocked = 1;
-}
-
-/* Allow SIGINT to be delivered. */
-static void
-release_sigint ()
-{
- if (sigint_blocked == 0)
- return;
-
-#if defined (HAVE_POSIX_SIGNALS)
- sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
-#else
-# if defined (HAVE_BSD_SIGNALS)
- sigsetmask (sigint_oldmask);
-# else /* !HAVE_BSD_SIGNALS */
-# if defined (HAVE_USG_SIGHOLD)
- sigrelse (SIGINT);
-# endif /* HAVE_USG_SIGHOLD */
-# endif /* !HAVE_BSD_SIGNALS */
-#endif /* !HAVE_POSIX_SIGNALS */
-
- sigint_blocked = 0;
-}
-
/* **************************************************************** */
/* */
/* Saving and Restoring the TTY */
if (tiop->flags & TCHARS_SET)
{
- _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
- _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
+ _rl_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
+ _rl_quit_char = _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
+
_rl_tty_chars.t_start = tiop->tchars.t_startc;
_rl_tty_chars.t_stop = tiop->tchars.t_stopc;
_rl_tty_chars.t_eof = tiop->tchars.t_eofc;
if (tiop->flags & LTCHARS_SET)
{
- _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
+ _rl_susp_char = _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
+
_rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
_rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
_rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
ioctl (tty, TIOCSETN, &(tiop->sgttyb));
tiop->flags &= ~SGTTY_SET;
}
- readline_echoing_p = 1;
+ _rl_echoing_p = 1;
#if defined (TIOCLSET)
if (tiop->flags & LFLAG_SET)
int meta_flag;
TIOTYPE oldtio, *tiop;
{
- readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
+ _rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
/* Copy the original settings to the structure we're going to use for
our settings. */
#ifdef VREPRINT
_rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
#endif
- _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
- _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
+ _rl_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
+ _rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
#ifdef VSUSP
- _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
+ _rl_susp_char = _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
#endif
#ifdef VDSUSP
_rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
int meta_flag;
TIOTYPE oldtio, *tiop;
{
- readline_echoing_p = (oldtio.c_lflag & ECHO);
+ _rl_echoing_p = (oldtio.c_lflag & ECHO);
tiop->c_lflag &= ~(ICANON | ECHO);
rl_prep_terminal (meta_flag)
int meta_flag;
{
- readline_echoing_p = 1;
+ _rl_echoing_p = 1;
}
void
return;
/* Try to keep this function from being INTerrupted. */
- block_sigint ();
+ _rl_block_sigint ();
tty = fileno (rl_instream);
#else
if (errno == ENOTTY || errno == EINVAL)
#endif
- readline_echoing_p = 1; /* XXX */
- release_sigint ();
+ _rl_echoing_p = 1; /* XXX */
+
+ _rl_release_sigint ();
return;
}
if (set_tty_settings (tty, &tio) < 0)
{
- release_sigint ();
+ _rl_release_sigint ();
return;
}
terminal_prepped = 1;
RL_SETSTATE(RL_STATE_TERMPREPPED);
- release_sigint ();
+ _rl_release_sigint ();
}
/* Restore the terminal's normal settings and modes. */
return;
/* Try to keep this function from being interrupted. */
- block_sigint ();
+ _rl_block_sigint ();
tty = fileno (rl_instream);
if (set_tty_settings (tty, &otio) < 0)
{
- release_sigint ();
+ _rl_release_sigint ();
return;
}
terminal_prepped = 0;
RL_UNSETSTATE(RL_STATE_TERMPREPPED);
- release_sigint ();
+ _rl_release_sigint ();
}
#endif /* !NO_TTY_DRIVER */
\f
int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
#endif
+/* Private variables. */
+/* If non-zero, print characters corresponding to received signals. */
+int _rl_echoctl = 0;
+
+int _rl_intr_char = 0;
+int _rl_quit_char = 0;
+int _rl_susp_char = 0;
+
static int signals_set_flag;
static int sigwinch_set_flag;
#if defined (SIGQUIT)
case SIGQUIT:
#endif
+ rl_echo_signal_char (sig);
rl_cleanup_after_signal ();
#if defined (HAVE_POSIX_SIGNALS)
sigint_blocked = 0;
}
+
+/* **************************************************************** */
+/* */
+/* Echoing special control characters */
+/* */
+/* **************************************************************** */
+void
+rl_echo_signal_char (sig)
+ int sig;
+{
+ char cstr[3];
+ int cslen, c;
+
+ if (_rl_echoctl == 0)
+ return;
+
+ switch (sig)
+ {
+ case SIGINT: c = _rl_intr_char; break;
+ case SIGQUIT: c = _rl_quit_char; break;
+ case SIGTSTP: c = _rl_susp_char; break;
+ default: return;
+ }
+
+ if (CTRL_CHAR (c) || c == RUBOUT)
+ {
+ cstr[0] = '^';
+ cstr[1] = CTRL_CHAR (c) ? UNCTRL (c) : '?';
+ cstr[cslen = 2] = '\0';
+ }
+ else
+ {
+ cstr[0] = c;
+ cstr[cslen = 1] = '\0';
+ }
+
+ _rl_output_some_chars (cstr, cslen);
+}
/* signals.c -- signal handling support for readline. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2008 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.
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
- The GNU Readline Library 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
+ Readline 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.
- The GNU Readline Library 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
+ Readline 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.
- The GNU General Public License is often shipped with GNU software, and
- is generally kept in a file called COPYING or LICENSE. If you do not
- have a copy of the license, write to the Free Software Foundation,
- 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL */
-#if defined (HANDLE_SIGNALS)
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
+#if defined (HANDLE_SIGNALS)
+
#if !defined (RETSIGTYPE)
# if defined (VOID_SIGHANDLER)
# define RETSIGTYPE void
int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
#endif
+/* Private variables. */
+/* If non-zero, print characters corresponding to received signals. */
+int _rl_echoctl = 0;
+
+int _rl_intr_char = 0;
+int _rl_quit_char = 0;
+int _rl_susp_char = 0;
+
static int signals_set_flag;
static int sigwinch_set_flag;
struct sigaction act;
act.sa_handler = handler;
+# if defined (SIGWINCH)
act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
+# else
+ act.sa_flags = 0;
+# endif /* SIGWINCH */
sigemptyset (&act.sa_mask);
sigemptyset (&ohandler->sa_mask);
sigaction (sig, &act, &old_handler);
}
#endif /* HANDLE_SIGNALS */
+
+/* **************************************************************** */
+/* */
+/* SIGINT Management */
+/* */
+/* **************************************************************** */
+
+#if defined (HAVE_POSIX_SIGNALS)
+static sigset_t sigint_set, sigint_oset;
+#else /* !HAVE_POSIX_SIGNALS */
+# if defined (HAVE_BSD_SIGNALS)
+static int sigint_oldmask;
+# endif /* HAVE_BSD_SIGNALS */
+#endif /* !HAVE_POSIX_SIGNALS */
+
+static int sigint_blocked;
+
+/* Cause SIGINT to not be delivered until the corresponding call to
+ release_sigint(). */
+void
+_rl_block_sigint ()
+{
+ if (sigint_blocked)
+ return;
+
+#if defined (HAVE_POSIX_SIGNALS)
+ sigemptyset (&sigint_set);
+ sigemptyset (&sigint_oset);
+ sigaddset (&sigint_set, SIGINT);
+ sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
+#else /* !HAVE_POSIX_SIGNALS */
+# if defined (HAVE_BSD_SIGNALS)
+ sigint_oldmask = sigblock (sigmask (SIGINT));
+# else /* !HAVE_BSD_SIGNALS */
+# if defined (HAVE_USG_SIGHOLD)
+ sighold (SIGINT);
+# endif /* HAVE_USG_SIGHOLD */
+# endif /* !HAVE_BSD_SIGNALS */
+#endif /* !HAVE_POSIX_SIGNALS */
+
+ sigint_blocked = 1;
+}
+
+/* Allow SIGINT to be delivered. */
+void
+_rl_release_sigint ()
+{
+ if (sigint_blocked == 0)
+ return;
+
+#if defined (HAVE_POSIX_SIGNALS)
+ sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
+#else
+# if defined (HAVE_BSD_SIGNALS)
+ sigsetmask (sigint_oldmask);
+# else /* !HAVE_BSD_SIGNALS */
+# if defined (HAVE_USG_SIGHOLD)
+ sigrelse (SIGINT);
+# endif /* HAVE_USG_SIGHOLD */
+# endif /* !HAVE_BSD_SIGNALS */
+#endif /* !HAVE_POSIX_SIGNALS */
+
+ sigint_blocked = 0;
+}
+
+/* **************************************************************** */
+/* */
+/* Echoing special control characters */
+/* */
+/* **************************************************************** */
+void
+rl_echo_signal_char (sig)
+ int sig;
+{
+ char cstr[3];
+ int cslen, c;
+
+ if (_rl_echoctl == 0)
+ return;
+
+ switch (sig)
+ {
+ case SIGINT: c = _rl_intr_char; break;
+ case SIGQUIT: c = _rl_quit_char; break;
+ case SIGTSTP: c = _rl_susp_char; break;
+ default: return;
+ }
+
+ if (CTRL_CHAR (c) || c == RUBOUT)
+ {
+ cstr[0] = '^';
+ cstr[1] = CTRL_CHAR (c) ? UNCTRL (c) : '?';
+ cstr[cslen = 2] = '\0';
+ }
+ else
+ {
+ cstr[0] = c;
+ cstr[cslen = 1] = '\0';
+ }
+
+ _rl_output_some_chars (cstr, cslen);
+}
return (0);
if (pid_list[i].flags & PROC_RUNNING)
return (0);
- return (get_termsig (pid_list[i].status));
+ return (get_termsig ((WAIT)pid_list[i].status));
}
/* Set LAST_COMMAND_EXIT_SIGNAL depending on STATUS. If STATUS is -1, look
-/* The thing that makes children, remembers them, and contains wait loops. */
+/* nojobs.c - functions that make children, remember them, and handle their termination. */
/* This file works under BSD, System V, minix, and Posix systems. It does
not implement job control. */
-/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2008 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 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.
+ 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. */
+ 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"
int async_p;
{
pid_t pid;
-#if defined (HAVE_WAITPID)
- int retry = 1;
-#endif /* HAVE_WAITPID */
+ int forksleep;
/* Discard saved memory. */
if (command)
sync_buffered_stream (default_buffered_input);
#endif /* BUFFERED_INPUT */
- /* Create the child, handle severe errors. */
-#if defined (HAVE_WAITPID)
- retry_fork:
-#endif /* HAVE_WAITPID */
-
- if ((pid = fork ()) < 0)
+ /* Create the child, handle severe errors. Retry on EAGAIN. */
+ forksleep = 1;
+ while ((pid = fork ()) < 0 && errno == EAGAIN && forksleep < FORKSLEEP_MAX)
{
+ sys_error ("fork: retry");
#if defined (HAVE_WAITPID)
/* Posix systems with a non-blocking waitpid () system call available
get another chance after zombies are reaped. */
- if (errno == EAGAIN && retry)
- {
- reap_zombie_children ();
- retry = 0;
- goto retry_fork;
- }
+ reap_zombie_children ();
+ if (forksleep > 1 && sleep (forksleep) != 0)
+ break;
+#else
+ if (sleep (forksleep) != 0)
+ break;
#endif /* HAVE_WAITPID */
+ forksleep <<= 1;
+ }
+ if (pid < 0)
+ {
sys_error ("fork");
-
throw_to_top_level ();
}
{
fprintf (stderr, "%s", j_strsignal (WTERMSIG (status)));
if (WIFCORED (status))
- fprintf (stderr, " (core dumped)");
+ fprintf (stderr, _(" (core dumped)"));
fprintf (stderr, "\n");
}
filename = _("file descriptor out of range");
#ifdef EBADF
/* This error can never involve NOCLOBBER */
- else if (error != NOCLOBBER_REDIRECT && temp->redirector >= 0 && errno == EBADF)
+ else if (error != NOCLOBBER_REDIRECT && temp->redirector >= 0 && error == EBADF)
{
/* If we're dealing with two file descriptors, we have to guess about
which one is invalid; in the cases of r_{duplicating,move}_input and
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 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.
+ 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. */
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
#include "config.h"
#if !defined (__GNUC__) && !defined (HAVE_ALLOCA_H) && defined (_AIX)
exec 4294967297>x */
filename = _("file descriptor out of range");
#ifdef EBADF
- else if (temp->redirector >= 0 && errno == EBADF)
+ /* This error can never involve NOCLOBBER */
+ else if (error != NOCLOBBER_REDIRECT && temp->redirector >= 0 && errno == EBADF)
{
/* If we're dealing with two file descriptors, we have to guess about
which one is invalid; in the cases of r_{duplicating,move}_input and
{
close (redir_fd);
#if defined (COPROCESS_SUPPORT)
- coproc_fdchk (&sh_coproc, redir_fd);
+ coproc_fdchk (redir_fd); /* XXX - loses coproc fds */
#endif
}
}
add_undo_redirect (redirector, ri);
#if defined (COPROCESS_SUPPORT)
- coproc_fdchk (&sh_coproc, redirector);
+ coproc_fdchk (redirector);
#endif
#if defined (BUFFERED_INPUT)
{
close_buffered_fd (default_buffered_input);
default_buffered_input = bash_input.location.buffered_fd = -1;
+ bash_input.type = st_none; /* XXX */
}
#else /* !BUFFERED_INPUT */
if (default_input)
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 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.
+ 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.
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
Birthdate:
Sunday, January 10th, 1988.
Initial author: Brian Fox
/* running_under_emacs == 2 for `eterm' */
running_under_emacs = (emacs != 0) || (term && STREQN (term, "emacs", 5));
- running_under_emacs += term && STREQN (term, "eterm", 5) && strstr (emacs, "term"));
+ running_under_emacs += term && STREQN (term, "eterm", 5) && strstr (emacs, "term");
if (running_under_emacs)
gnu_error_format = 1;
#endif /* HISTORY */
#if defined (COPROCESS_SUPPORT)
- coproc_dispose (&sh_coproc);
+ coproc_flush ();
#endif
#if defined (JOB_CONTROL)
{
close_buffered_fd (default_buffered_input);
default_buffered_input = bash_input.location.buffered_fd = -1;
+ bash_input.type = st_none;
}
#else /* !BUFFERED_INPUT */
if (default_input)
#include "bashtypes.h"
#include <stdio.h>
#include "chartypes.h"
-#include <pwd.h>
+#if defined (HAVE_PWD_H)
+# include <pwd.h>
+#endif
#include <signal.h>
#include <errno.h>
#include "builtins/getopt.h"
#include "builtins/common.h"
+#include "builtins/builtext.h"
+
#include <tilde/tilde.h>
#include <glob/strmatch.h>
{
case OT: return (r1 < r2 || (r2 == 0 && st1.st_mtime < st2.st_mtime));
case NT: return (r1 > r2 || (r1 == 0 && st1.st_mtime > st2.st_mtime));
- case EF: return ((st1.st_dev == st2.st_dev) && (st1.st_ino == st2.st_ino));
+ case EF: return (same_file (s, t, &st1, &st2));
}
return (FALSE);
}
-/* GNU test program (ksb and mjb) */
+/* test.c - GNU test program (ksb and mjb) */
/* Modified to run with the GNU shell Apr 25, 1988 by bfox. */
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2008 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 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.
+ 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. */
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
/* Define PATTERN_MATCHING to get the csh-like =~ and !~ pattern-matching
binary operators. */
{
case OT: return (r1 < r2 || (r2 == 0 && st1.st_mtime < st2.st_mtime));
case NT: return (r1 > r2 || (r1 == 0 && st1.st_mtime > st2.st_mtime));
- case EF: return ((st1.st_dev == st2.st_dev) && (st1.st_ino == st2.st_ino));
+ case EF: return (same_file (s, t, &st1, &st2);
}
return (FALSE);
}
test_unop (op)
char *op;
{
- if (op[0] != '-')
+ if (op[0] != '-' || op[2] != 0)
return (0);
switch (op[1])
pwd
echo $PWD
-cd $MYDIR
+cd "$MYDIR"
rmdir $FULLDIR
--- /dev/null
+unset CDPATH
+
+MYDIR=$(pwd -P)
+FULLDIR=/tmp/bash-dir-a
+DIR=${FULLDIR##*/}
+
+mkdir $FULLDIR
+CDPATH=.:/tmp
+cd $DIR
+pwd
+echo $PWD
+
+cd $MYDIR
+rmdir $FULLDIR
dirs
# this is for the benefit of pure coverage
-cd $MYDIR
+cd "$MYDIR"
--- /dev/null
+export LC_ALL=C
+export LANG=C
+
+dirs -c
+# error -- nonexistant directory
+pushd /tmp/xxx-notthere
+
+# errors -- empty stack
+pushd
+popd
+
+# errors -- bad numeric arguments -- should not cause the script to exit
+pushd -m
+popd -m
+dirs -m
+dirs 7
+
+MYDIR=$PWD
+unalias cd 2>/dev/null
+
+unalias -a
+
+command cd -P /
+command pwd -P # better be `/'
+
+case "$OLDPWD" in
+$MYDIR) echo ok ;;
+*) echo oops -- bad \$OLDPWD ;;
+esac
+
+pushd /usr
+echo $PWD $OLDPWD
+dirs
+echo ${DIRSTACK[@]}
+
+# this should not change the directory stack at all
+pushd -n +0
+dirs
+
+popd
+pushd /usr
+
+pushd /etc
+dirs
+dirs -l
+dirs -v
+
+# two consecutive `pushd's should swap the top two stack elements, then
+# swap them back, leaving the stack intact
+pushd
+pushd
+
+pushd /tmp
+echo ${DIRSTACK[0]} ; dirs +0
+echo ${DIRSTACK[2]} ; dirs +2
+
+# these should be errors, but not affect the directory stack
+dirs +9; dirs -9
+pushd +9 ; pushd -9
+popd +9 ; popd -9
+
+popd -n +2
+dirs
+echo ${DIRSTACK[@]}
+
+pushd -n /usr
+echo $PWD
+dirs
+echo ${DIRSTACK[@]}
+
+builtin pwd
+
+DIRSTACK[1]=/bin
+dirs
+
+builtin pwd
+popd +2
+builtin pwd -L
+pushd -1
+dirs
+echo ${DIRSTACK[0]}
+
+dirs -c
+dirs
+
+# this is for the benefit of pure coverage
+cd $MYDIR
# this is for the benefit of pure coverage, so it writes the pcv file
# in the right place
-builtin cd $MYDIR
+builtin cd "$MYDIR"
${THIS_SH} ./extglob1.sub
--- /dev/null
+# test the ksh-like extended globbing features: [!@*?+](patlist)
+
+shopt -s extglob
+
+expect()
+{
+ echo expect "$@"
+}
+
+case "/dev/udp/129.22.8.102/45" in
+/dev/@(tcp|udp)/*/*) echo ok 1;;
+*) echo bad 1;;
+esac
+
+# valid numbers
+case 12 in
+0|[1-9]*([0-9])) echo ok 2;;
+*) echo bad 2;;
+esac
+
+case 12abc in
+0|[1-9]*([0-9])) echo bad 3;;
+*) echo ok 3;;
+esac
+
+case 1 in
+0|[1-9]*([0-9])) echo ok 4;;
+*) echo bad 4;;
+esac
+
+# octal numbers
+case 07 in
++([0-7])) echo ok 5;;
+*) echo bad 5;;
+esac
+
+case 0377 in
++([0-7])) echo ok 6;;
+*) echo bad 6;;
+esac
+
+case 09 in
++([0-7])) echo bad 7;;
+*) echo ok 7;;
+esac
+
+# stuff from korn's book
+case paragraph in
+para@(chute|graph)) echo ok 8;;
+*) echo bad 8;;
+esac
+
+case paramour in
+para@(chute|graph)) echo bad 9;;
+*) echo ok 9;;
+esac
+
+case para991 in
+para?([345]|99)1) echo ok 10;;
+*) echo bad 10;;
+esac
+
+case para381 in
+para?([345]|99)1) echo bad 11;;
+*) echo ok 11;;
+esac
+
+case paragraph in
+para*([0-9])) echo bad 12;;
+*) echo ok 12;;
+esac
+
+case para in
+para*([0-9])) echo ok 13;;
+*) echo bad 13;;
+esac
+
+case para13829383746592 in
+para*([0-9])) echo ok 14;;
+*) echo bad 14;;
+esac
+
+case paragraph in
+para*([0-9])) echo bad 15;;
+*) echo ok 15;;
+esac
+
+case para in
+para+([0-9])) echo bad 16;;
+*) echo ok 16;;
+esac
+
+case para987346523 in
+para+([0-9])) echo ok 17;;
+*) echo bad 17;;
+esac
+
+case paragraph in
+para!(*.[0-9])) echo ok 18;;
+*) echo bad 18;;
+esac
+
+case para.38 in
+para!(*.[0-9])) echo ok 19;;
+*) echo bad 19;;
+esac
+
+case para.graph in
+para!(*.[0-9])) echo ok 20;;
+*) echo bad 20;;
+esac
+
+case para39 in
+para!(*.[0-9])) echo ok 21;;
+*) echo bad 21;;
+esac
+
+# tests derived from those in rosenblatt's korn shell book
+
+case "" in
+*(0|1|3|5|7|9)) echo ok 22;;
+*) echo bad 22;
+esac
+
+case 137577991 in
+*(0|1|3|5|7|9)) echo ok 23;;
+*) echo bad 23;
+esac
+
+case 2468 in
+*(0|1|3|5|7|9)) echo bad 24;;
+*) echo ok 24;
+esac
+
+case file.c in
+*.c?(c)) echo ok 25;;
+*) echo bad 25;;
+esac
+
+case file.C in
+*.c?(c)) echo bad 26;;
+*) echo ok 26;;
+esac
+
+case file.cc in
+*.c?(c)) echo ok 27;;
+*) echo bad 27;;
+esac
+
+case file.ccc in
+*.c?(c)) echo bad 28;;
+*) echo ok 28;;
+esac
+
+case parse.y in
+!(*.c|*.h|Makefile.in|config*|README)) echo ok 29;;
+*) echo bad 29;;
+esac
+
+case shell.c in
+!(*.c|*.h|Makefile.in|config*|README)) echo bad 30;;
+*) echo ok 30;;
+esac
+
+case Makefile in
+!(*.c|*.h|Makefile.in|config*|README)) echo ok 31;;
+*) echo bad 31;;
+esac
+
+case "VMS.FILE;1" in
+*\;[1-9]*([0-9])) echo ok 32;;
+*) echo bad 32;;
+esac
+
+case "VMS.FILE;0" in
+*\;[1-9]*([0-9])) echo bad 33;;
+*) echo ok 33;;
+esac
+case "VMS.FILE;" in
+*\;[1-9]*([0-9])) echo bad 34;;
+*) echo ok 34;;
+esac
+case "VMS.FILE;139" in
+*\;[1-9]*([0-9])) echo ok 35;;
+*) echo bad 35;;
+esac
+case "VMS.FILE;1N" in
+*\;[1-9]*([0-9])) echo bad 36;;
+*) echo ok 36;;
+esac
+
+# tests derived from the pd-ksh test suite
+
+MYDIR=$PWD # save where we are
+
+TESTDIR=/tmp/eglob-test-$$
+mkdir $TESTDIR
+builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
+rm -rf *
+
+touch abcx abcz bbc
+expect '!([*)*'
+echo !([*)*
+
+expect '+(a|b[)*'
+echo +(a|b[)*
+
+expect '[a*(]*z'
+echo [a*(]*)z
+
+rm -f abcx abcz bbc
+
+touch abc
+
+expect '+()c'
+echo +()c
+expect '+()x'
+echo +()x
+expect abc
+echo +(*)c
+expect '+(*)x'
+echo +(*)x
+
+# extended globbing should not be performed on the output of substitutions
+x='@(*)'
+expect '@(*)'
+echo $x
+
+expect 'no-file+(a|b)stuff'
+echo no-file+(a|b)stuff
+expect 'no-file+(a*(c)|b)stuff'
+echo no-file+(a*(c)|b)stuff
+
+touch abd acd
+
+expect 'abd acd'
+echo a+(b|c)d
+
+expect 'acd'
+echo a!(@(b|B))d
+
+expect 'abd'
+echo a[b*(foo|bar)]d
+
+# simple kleene star tests
+expect no
+case foo in *(a|b[)) echo yes;; *) echo no;; esac
+
+expect yes
+case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
+
+# this doesn't work right yet; it is an incorrectly formed pattern
+expect yes
+case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
+
+# check extended globbing in pattern removal -- these don't work right yet
+x=abcdef
+
+expect '1: bcdef'
+echo 1: ${x#+(a|abc)}
+expect '2: def'
+echo 2: ${x##+(a|abc)}
+expect '3: abcde'
+echo 3: ${x%+(def|f)}
+expect '4: abc'
+echo 4: ${x%%+(f|def)}
+
+# these work ok
+
+expect '5: ef'
+echo 5: ${x#*(a|b)cd}
+expect '6: ef'
+echo 6: "${x#*(a|b)cd}"
+expect '7: abcdef'
+echo 7: ${x#"*(a|b)cd"}
+
+# More tests derived from a bug report concerning extended glob patterns
+# following a *
+builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
+rm -rf *
+
+touch ab abcdef abef abcfef
+
+expect 'ab abef'
+echo ab*(e|f)
+
+expect 'abcfef abef'
+echo ab?*(e|f)
+
+expect abcdef
+echo ab*d+(e|f)
+
+expect 'ab abcdef abcfef abef'
+echo ab**(e|f)
+
+expect 'abcdef abcfef abef'
+echo ab*+(e|f)
+
+case 'abcfefg' in
+ab**(e|f)) echo ok 37;;
+*) echo bad 37;;
+esac
+
+case 'abcfefg' in
+ab**(e|f)g) echo ok 38;;
+*a) echo bad 38;;
+esac
+
+case ab in
+ab*+(e|f)) echo bad 39;;
+*) echo ok 39;;
+esac
+
+case abef in
+ab***ef) echo ok 40;;
+*) echo bad 40;;
+esac
+
+case abef in
+ab**) echo ok 41;;
+*) echo bad 41;;
+esac
+
+# bug in all versions up to and including bash-2.05b
+case "123abc" in
+*?(a)bc) echo ok 42;;
+*) echo bad 42;;
+esac
+
+# clean up and do the next one
+
+builtin cd /
+rm -rf $TESTDIR
+
+mkdir $TESTDIR
+builtin cd $TESTDIR
+
+LC_COLLATE=C # have to set this; it affects the sorting
+touch a.b a,b a:b a-b a\;b a\ b a_b
+
+echo a[^[:alnum:]]b
+echo a[-.,:\;\ _]b
+
+echo a@([^[:alnum:]])b
+echo a@([-.,:; _])b
+echo a@([.])b
+echo a@([^.])b
+echo a@([^x])b
+echo a+([^[:alnum:]])b
+
+echo a@(.|[^[:alnum:]])b
+
+builtin cd /
+rm -rf $TESTDIR
+
+x=abcdef
+recho "${x#*(a|b)cd}"
+
+# this is for the benefit of pure coverage, so it writes the pcv file
+# in the right place
+builtin cd $MYDIR
+
+${THIS_SH} ./extglob1.sub
+
+exit 0
*) echo bad 3;;
esac
-cd $MYDIR
+cd "$MYDIR"
rm -rf $GDIR
--- /dev/null
+MYDIR=$PWD
+
+: ${TMPDIR:=/tmp}
+GDIR=$TMPDIR/gtest-$$
+
+shopt -s extglob
+
+mkdir $GDIR || exit 1
+cd $GDIR || exit 1
+
+touch a.c
+
+echo +([[:alpha:].])
+echo +([[:alpha:].])+([[:alpha:].])
+echo *([[:alpha:].])
+echo *([[:alpha:].])*([[:alpha:].])
+
+echo ?([[:alpha:].])?([[:alpha:].])?([[:alpha:].])
+echo @([[:alpha:].])@([[:alpha:].])@([[:alpha:].])
+
+case . in
+!([[:alpha:].]) ) echo bad 1;;
+*) echo ok 1;;
+esac
+
+case . in
+?([[:alpha:].]) ) echo ok 2;;
+*) echo bad 2;;
+esac
+
+case . in
+@([[:alpha:].]) ) echo ok 3;;
+*) echo bad 3;;
+esac
+
+cd $MYDIR
+rm -rf $GDIR
*.orig|*~) ;;
run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
run-ifs-tests|run-input-test|run-invert|run-more-exp|run-nquote) echo $x ; sh $x ;;
- run-ifs-0posix|run-posix2|run-posixpat) echo $x ; sh $x ;;
+ run-ifs-posix|run-posix2|run-posixpat) echo $x ; sh $x ;;
run-precedence|run-quote|run-read|run-rhs-exp|run-strip|run-tilde) echo $x ; sh $x ;;
*) ;;
esac
--- /dev/null
+#! /bin/sh
+#
+# run-minimal - a version of run-all for shells configured with
+# --enable-minimal-config
+#
+PATH=.:$PATH # just to get the right version of printenv
+export PATH
+
+# unset BASH_ENV only if it is set
+[ "${BASH_ENV+set}" = "set" ] && unset BASH_ENV
+# ditto for SHELLOPTS
+#[ "${SHELLOPTS+set}" = "set" ] && unset SHELLOPTS
+
+: ${THIS_SH:=../bash}
+export THIS_SH
+
+${THIS_SH} ./version.mini
+
+rm -f /tmp/xx
+
+echo Testing ${THIS_SH}
+echo Any output from any test, unless otherwise noted, indicates a possible anomaly
+for x in run-*
+do
+ case $x in
+ $0) ;;
+ *.orig|*~) ;;
+ run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
+ run-ifs-tests|run-input-test|run-invert|run-more-exp|run-nquote) echo $x ; sh $x ;;
+ run-ifs-0posix|run-posix2|run-posixpat) echo $x ; sh $x ;;
+ run-precedence|run-quote|run-read|run-rhs-exp|run-strip|run-tilde) echo $x ; sh $x ;;
+ *) ;;
+ esac
+done
+
+exit 0
echo warning: some of these tests will fail if you do not have UTF-8 >&2
-echo warning: locales installed on your system
+echo warning: locales installed on your system >&2
${THIS_SH} ./nquote4.tests 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx nquote4.right && rm -f /tmp/xx
--- /dev/null
+echo warning: some of these tests will fail if you do not have UTF-8 >&2
+echo warning: locales installed on your system
+${THIS_SH} ./nquote4.tests 2>&1 | grep -v '^expect' > /tmp/xx
+diff /tmp/xx nquote4.right && rm -f /tmp/xx
#include <stdio.h>
#include "chartypes.h"
-#include <pwd.h>
+#if defined (HAVE_PWD_H)
+# include <pwd.h>
+#endif
#include "bashansi.h"
#include "bashintl.h"
sv_globignore (name)
char *name;
{
- setup_glob_ignore (name);
+ if (privileged_mode == 0)
+ setup_glob_ignore (name);
}
#if defined (READLINE)
#include <stdio.h>
#include "chartypes.h"
-#include <pwd.h>
+#if defined (HAVE_PWD_H)
+# include <pwd.h>
+#endif
#include "bashansi.h"
#include "bashintl.h"
}
if (old_var == 0)
-#if 0
- new_var = bind_variable_internal (name, "", vc->table, HASH_NOSRCH, 0);
-#else
new_var = make_new_variable (name, vc->table);
-#endif
else
{
new_var = make_new_variable (name, vc->table);