From: Chet Ramey Date: Wed, 7 Dec 2011 14:29:49 +0000 (-0500) Subject: commit bash-20081002 snapshot X-Git-Tag: bash-4.3-alpha~264 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e77a3058b64e2135ee0b1f244a7ce412a912f23c;p=thirdparty%2Fbash.git commit bash-20081002 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 5d1095e5c..9a02993e7 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -6953,3 +6953,76 @@ builtins/bind.def - experimental: print a warning, but go on, if line editing not active when bind is invoked. Suggested by Rocky Bernstein + + 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 + + 10/4 + ---- + +redir.c + - in redirection_error(), use `error' instead of errno when comparing + against EBADF. From mingw32 patches submitted by Hector Chu + + +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 + +builtins/cd.def + - ignore CDPATH when in privileged mode. Suggested by Paul Jarc + + +variables.c + - change sv_globignore to only act if privileged mode is not enabled. + Suggested by Paul Jarc + +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 + + +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 + - 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 + diff --git a/CWRU/CWRU.chlog~ b/CWRU/CWRU.chlog~ index 170e30ce4..4b25664c1 100644 --- a/CWRU/CWRU.chlog~ +++ b/CWRU/CWRU.chlog~ @@ -6928,9 +6928,100 @@ jobs.c 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" , 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 + + 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 + + + 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 + + 10/4 + ---- + +redir.c + - in redirection_error(), use `error' instead of errno when comparing + against EBADF. From mingw32 patches submitted by Hector Chu + + +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 + +builtins/cd.def + - ignore CDPATH when in privileged mode. Suggested by Paul Jarc + + +variables.c + - change sv_globignore to only act if privileged mode is not enabled. + Suggested by Paul Jarc + +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 + + +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 + - 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 diff --git a/builtins/cd.def b/builtins/cd.def index 4a0508019..6f5a348fe 100644 --- a/builtins/cd.def +++ b/builtins/cd.def @@ -235,7 +235,7 @@ cd_builtin (list) } 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; diff --git a/builtins/cd.def~ b/builtins/cd.def~ index 629bdc8a8..4a0508019 100644 --- a/builtins/cd.def~ +++ b/builtins/cd.def~ @@ -5,19 +5,18 @@ 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 . $PRODUCES cd.c #include @@ -91,6 +90,9 @@ Options: 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. */ @@ -334,6 +336,10 @@ Options: -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 diff --git a/builtins/read.def b/builtins/read.def index c377015c4..7b461c2cd 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -354,12 +354,6 @@ read_builtin (list) 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 */ @@ -451,6 +445,12 @@ read_builtin (list) 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 diff --git a/builtins/read.def~ b/builtins/read.def~ index 295b98196..b279f37d4 100644 --- a/builtins/read.def~ +++ b/builtins/read.def~ @@ -50,8 +50,9 @@ Options: -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: @@ -341,6 +342,7 @@ read_builtin (list) 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; @@ -353,11 +355,13 @@ read_builtin (list) 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 */ @@ -450,6 +454,14 @@ read_builtin (list) 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 diff --git a/builtins/ulimit.def b/builtins/ulimit.def index 202d2e6d3..9180da046 100644 --- a/builtins/ulimit.def +++ b/builtins/ulimit.def @@ -104,7 +104,7 @@ extern int errno; # if defined (HPUX) && defined (RLIMIT_NEEDS_KERNEL) # undef _KERNEL # endif -#else +#elif defined (HAVE_SYS_TIMES_H) # include #endif diff --git a/builtins/ulimit.def~ b/builtins/ulimit.def~ index f3d11ac08..202d2e6d3 100644 --- a/builtins/ulimit.def~ +++ b/builtins/ulimit.def~ @@ -5,19 +5,18 @@ 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 . $PRODUCES ulimit.c @@ -183,7 +182,7 @@ extern int errno; 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; diff --git a/command.h~ b/command.h~ index 46e5bda92..5d77c7a11 100644 --- a/command.h~ +++ b/command.h~ @@ -1,23 +1,23 @@ /* 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 . +*/ #if !defined (_COMMAND_H_) #define _COMMAND_H_ @@ -66,7 +66,7 @@ enum r_instruction { /* 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. */ @@ -162,6 +162,8 @@ typedef struct element { #define CMD_AMPERSAND 0x200 /* command & */ #define CMD_STDIN_REDIR 0x400 /* async command needs implicit flags & CMD_IGNORE_RETURN) != 0; - +itrace("execute_command_internal: ignore_return = %d", ignore_return); QUIT; switch (command->type) @@ -736,16 +736,22 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, } } - 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); @@ -1924,6 +1930,7 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) 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 == '|') { @@ -2113,6 +2120,7 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close) 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; @@ -2128,6 +2136,7 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close) exec_result = execute_command (command->value.Connection->second); } + executing_list--; break; default: @@ -3401,7 +3410,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close) /* 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) @@ -3437,6 +3446,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close) #endif command_line = (char *)NULL; /* don't free this. */ bind_lastarg ((char *)NULL); +itrace("execute_simple_command: parent: returning %d", result); return (result); } } @@ -4020,6 +4030,7 @@ execute_subshell_builtin_or_function (words, redirects, builtin, var, ((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; diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi index a9def85f3..da1bfcf87 100644 --- a/lib/readline/doc/rltech.texi +++ b/lib/readline/doc/rltech.texi @@ -1434,6 +1434,13 @@ call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force 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 diff --git a/lib/readline/doc/rltech.texi~ b/lib/readline/doc/rltech.texi~ index 79f638b76..a9def85f3 100644 --- a/lib/readline/doc/rltech.texi~ +++ b/lib/readline/doc/rltech.texi~ @@ -523,6 +523,20 @@ Readline is performing word completion. 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. @@ -1898,27 +1912,51 @@ history list. GNU Readline library. This application interactively allows users to manipulate files and their modes. */ -#include +#ifdef HAVE_CONFIG_H +# include +#endif + #include -#include +#ifdef HAVE_SYS_FILE_H +# include +#endif #include -#include + +#ifdef HAVE_UNISTD_H +# include +#endif + +#include +#include +#include + +#if defined (HAVE_STRING_H) +# include +#else /* !HAVE_STRING_H */ +# include +#endif /* !HAVE_STRING_H */ + +#ifdef HAVE_STDLIB_H +# include +#endif + +#include #include #include -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. */ @@ -1951,12 +1989,12 @@ COMMAND *find_command (); /* 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; @@ -2081,12 +2119,12 @@ stripwhite (string) /* */ /* **************************************************************** */ -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. */ @@ -2096,11 +2134,11 @@ initialize_readline () 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; @@ -2119,9 +2157,9 @@ fileman_completion (text, start, end) 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; @@ -2130,17 +2168,16 @@ command_generator (text, state) 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++; @@ -2180,7 +2217,12 @@ com_view (arg) 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)); @} @@ -2207,7 +2249,8 @@ com_stat (arg) 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, @@ -2296,8 +2339,7 @@ com_pwd (ignore) 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; @{ @@ -2310,13 +2352,12 @@ too_dangerous (caller) 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; diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi index afaaab455..9ecfeec69 100644 --- a/lib/readline/doc/rluser.texi +++ b/lib/readline/doc/rluser.texi @@ -1743,9 +1743,10 @@ Perform directory name completion if the compspec generates no matches. @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 diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi index 0d5c5693b..5c98f17d3 100644 --- a/lib/readline/doc/version.texi +++ b/lib/readline/doc/version.texi @@ -4,7 +4,7 @@ Copyright (C) 1988-2008 Free Software Foundation, Inc. @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 diff --git a/lib/readline/doc/version.texi~ b/lib/readline/doc/version.texi~ index 75322efc5..0d5c5693b 100644 --- a/lib/readline/doc/version.texi~ +++ b/lib/readline/doc/version.texi~ @@ -2,9 +2,9 @@ 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 diff --git a/lib/readline/history.c b/lib/readline/history.c index b5ca13e73..f5d1201fe 100644 --- a/lib/readline/history.c +++ b/lib/readline/history.c @@ -318,6 +318,8 @@ add_history_time (string) { HIST_ENTRY *hs; + if (string == 0) + return; hs = the_history[history_length - 1]; FREE (hs->timestamp); hs->timestamp = savestring (string); diff --git a/lib/readline/history.c~ b/lib/readline/history.c~ index 3fbcaeaa0..f5d1201fe 100644 --- a/lib/readline/history.c~ +++ b/lib/readline/history.c~ @@ -1,24 +1,23 @@ /* 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 . +*/ /* The goal is to make the implementation transparent, so that you don't have to know what data types are used, just what functions @@ -319,6 +318,8 @@ add_history_time (string) { HIST_ENTRY *hs; + if (string == 0) + return; hs = the_history[history_length - 1]; FREE (hs->timestamp); hs->timestamp = savestring (string); @@ -483,7 +484,7 @@ stifle_history (max) /* 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 () { diff --git a/lib/readline/readline.h b/lib/readline/readline.h index 4dff05d0f..1fcf91b49 100644 --- a/lib/readline/readline.h +++ b/lib/readline/readline.h @@ -428,7 +428,9 @@ extern int rl_clear_signals PARAMS((void)); 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. */ diff --git a/lib/readline/readline.h~ b/lib/readline/readline.h~ index ddeff0be2..ea57b968b 100644 --- a/lib/readline/readline.h~ +++ b/lib/readline/readline.h~ @@ -2,23 +2,22 @@ /* 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 . +*/ #if !defined (_READLINE_H_) #define _READLINE_H_ @@ -40,9 +39,9 @@ extern "C" { #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. */ @@ -429,7 +428,7 @@ extern int rl_clear_signals PARAMS((void)); 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. */ @@ -605,6 +604,10 @@ extern int rl_catch_sigwinch; 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. diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h index f8758d890..d0463fb2b 100644 --- a/lib/readline/rlprivate.h +++ b/lib/readline/rlprivate.h @@ -423,6 +423,13 @@ extern _rl_keyseq_cxt *_rl_kscxt; /* 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; diff --git a/lib/readline/rlprivate.h~ b/lib/readline/rlprivate.h~ index 028acd191..6c5b2718d 100644 --- a/lib/readline/rlprivate.h~ +++ b/lib/readline/rlprivate.h~ @@ -294,6 +294,8 @@ extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *)); 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 *)); @@ -330,11 +332,15 @@ extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *)); #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 **)); @@ -419,6 +425,13 @@ extern _rl_keyseq_cxt *_rl_kscxt; /* 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; diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c index 567ef5b8d..61f910358 100644 --- a/lib/readline/rltty.c +++ b/lib/readline/rltty.c @@ -137,8 +137,9 @@ save_tty_chars (tiop) 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; @@ -148,7 +149,8 @@ save_tty_chars (tiop) 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; @@ -236,6 +238,7 @@ prepare_terminal_settings (meta_flag, oldtio, tiop) 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. */ @@ -366,10 +369,10 @@ save_tty_chars (tiop) #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]; @@ -514,6 +517,7 @@ prepare_terminal_settings (meta_flag, oldtio, tiop) TIOTYPE oldtio, *tiop; { _rl_echoing_p = (oldtio.c_lflag & ECHO); + _rl_echoctl = (oldtio.c_lflag & ECHOCTL); tiop->c_lflag &= ~(ICANON | ECHO); diff --git a/lib/readline/rltty.c~ b/lib/readline/rltty.c~ index 47c462897..c7552e50b 100644 --- a/lib/readline/rltty.c~ +++ b/lib/readline/rltty.c~ @@ -3,23 +3,23 @@ /* 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 . +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -52,75 +52,8 @@ extern int errno; 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 */ @@ -204,8 +137,9 @@ save_tty_chars (tiop) 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; @@ -215,7 +149,8 @@ save_tty_chars (tiop) 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; @@ -268,7 +203,7 @@ set_tty_settings (tty, tiop) 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) @@ -302,7 +237,7 @@ prepare_terminal_settings (meta_flag, oldtio, tiop) 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. */ @@ -433,10 +368,10 @@ save_tty_chars (tiop) #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]; @@ -580,7 +515,7 @@ prepare_terminal_settings (meta_flag, oldtio, tiop) 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); @@ -643,7 +578,7 @@ void rl_prep_terminal (meta_flag) int meta_flag; { - readline_echoing_p = 1; + _rl_echoing_p = 1; } void @@ -663,7 +598,7 @@ rl_prep_terminal (meta_flag) return; /* Try to keep this function from being INTerrupted. */ - block_sigint (); + _rl_block_sigint (); tty = fileno (rl_instream); @@ -676,8 +611,9 @@ rl_prep_terminal (meta_flag) #else if (errno == ENOTTY || errno == EINVAL) #endif - readline_echoing_p = 1; /* XXX */ - release_sigint (); + _rl_echoing_p = 1; /* XXX */ + + _rl_release_sigint (); return; } @@ -712,7 +648,7 @@ rl_prep_terminal (meta_flag) if (set_tty_settings (tty, &tio) < 0) { - release_sigint (); + _rl_release_sigint (); return; } @@ -723,7 +659,7 @@ rl_prep_terminal (meta_flag) terminal_prepped = 1; RL_SETSTATE(RL_STATE_TERMPREPPED); - release_sigint (); + _rl_release_sigint (); } /* Restore the terminal's normal settings and modes. */ @@ -736,7 +672,7 @@ rl_deprep_terminal () return; /* Try to keep this function from being interrupted. */ - block_sigint (); + _rl_block_sigint (); tty = fileno (rl_instream); @@ -747,14 +683,14 @@ rl_deprep_terminal () 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 */ diff --git a/lib/readline/signals.c b/lib/readline/signals.c index c8f44933d..af9b70b7a 100644 --- a/lib/readline/signals.c +++ b/lib/readline/signals.c @@ -94,6 +94,14 @@ int rl_catch_sigwinch = 1; 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; @@ -159,6 +167,7 @@ rl_signal_handler (sig) #if defined (SIGQUIT) case SIGQUIT: #endif + rl_echo_signal_char (sig); rl_cleanup_after_signal (); #if defined (HAVE_POSIX_SIGNALS) @@ -534,3 +543,41 @@ _rl_release_sigint () 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); +} diff --git a/lib/readline/signals.c~ b/lib/readline/signals.c~ index f79d65b15..bf3e27b32 100644 --- a/lib/readline/signals.c~ +++ b/lib/readline/signals.c~ @@ -1,24 +1,24 @@ /* 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 . +*/ + #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) @@ -40,13 +40,14 @@ # include #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 @@ -93,6 +94,14 @@ int rl_catch_sigwinch = 1; 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; @@ -253,7 +262,11 @@ rl_set_sighandler (sig, handler, ohandler) 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); @@ -465,3 +478,105 @@ rl_free_line_state () } #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); +} diff --git a/nojobs.c b/nojobs.c index 97487154e..176555540 100644 --- a/nojobs.c +++ b/nojobs.c @@ -232,7 +232,7 @@ find_termsig_by_pid (pid) 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 diff --git a/nojobs.c~ b/nojobs.c~ index c8a56275f..97487154e 100644 --- a/nojobs.c~ +++ b/nojobs.c~ @@ -1,25 +1,25 @@ -/* 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 . +*/ #include "config.h" @@ -465,9 +465,7 @@ make_child (command, async_p) int async_p; { pid_t pid; -#if defined (HAVE_WAITPID) - int retry = 1; -#endif /* HAVE_WAITPID */ + int forksleep; /* Discard saved memory. */ if (command) @@ -484,26 +482,27 @@ make_child (command, async_p) 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 (); } @@ -803,7 +802,7 @@ wait_for (pid) { fprintf (stderr, "%s", j_strsignal (WTERMSIG (status))); if (WIFCORED (status)) - fprintf (stderr, " (core dumped)"); + fprintf (stderr, _(" (core dumped)")); fprintf (stderr, "\n"); } diff --git a/redir.c b/redir.c index 6db8d70ee..d4eeeedbf 100644 --- a/redir.c +++ b/redir.c @@ -104,7 +104,7 @@ redirection_error (temp, error) 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 diff --git a/redir.c~ b/redir.c~ index 0343233e1..6db8d70ee 100644 --- a/redir.c~ +++ b/redir.c~ @@ -4,19 +4,20 @@ 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 . +*/ + #include "config.h" #if !defined (__GNUC__) && !defined (HAVE_ALLOCA_H) && defined (_AIX) @@ -102,7 +103,8 @@ redirection_error (temp, error) 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 @@ -939,7 +941,7 @@ do_redirection_internal (redirect, flags) { close (redir_fd); #if defined (COPROCESS_SUPPORT) - coproc_fdchk (&sh_coproc, redir_fd); + coproc_fdchk (redir_fd); /* XXX - loses coproc fds */ #endif } } @@ -952,7 +954,7 @@ do_redirection_internal (redirect, flags) add_undo_redirect (redirector, ri); #if defined (COPROCESS_SUPPORT) - coproc_fdchk (&sh_coproc, redirector); + coproc_fdchk (redirector); #endif #if defined (BUFFERED_INPUT) diff --git a/shell.c b/shell.c index 5a07d3e71..3b7e655f9 100644 --- a/shell.c +++ b/shell.c @@ -1541,6 +1541,7 @@ unset_bash_input (check_zero) { 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) diff --git a/shell.c~ b/shell.c~ index 27bbcb574..e6bfe362d 100644 --- a/shell.c~ +++ b/shell.c~ @@ -4,20 +4,21 @@ 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 . +*/ +/* Birthdate: Sunday, January 10th, 1988. Initial author: Brian Fox @@ -571,7 +572,7 @@ main (argc, argv, env) /* 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; @@ -906,7 +907,7 @@ exit_shell (s) #endif /* HISTORY */ #if defined (COPROCESS_SUPPORT) - coproc_dispose (&sh_coproc); + coproc_flush (); #endif #if defined (JOB_CONTROL) @@ -1540,6 +1541,7 @@ unset_bash_input (check_zero) { 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) diff --git a/subst.c b/subst.c index 846b72111..b327f431b 100644 --- a/subst.c +++ b/subst.c @@ -27,7 +27,9 @@ #include "bashtypes.h" #include #include "chartypes.h" -#include +#if defined (HAVE_PWD_H) +# include +#endif #include #include diff --git a/subst.c~ b/subst.c~ index 9d8785f06..846b72111 100644 --- a/subst.c~ +++ b/subst.c~ @@ -53,6 +53,8 @@ #include "builtins/getopt.h" #include "builtins/common.h" +#include "builtins/builtext.h" + #include #include diff --git a/test.c b/test.c index 542786014..14330f2ee 100644 --- a/test.c +++ b/test.c @@ -310,7 +310,7 @@ filecomp (s, t, op) { 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); } diff --git a/test.c~ b/test.c~ index f01929f70..b4639a891 100644 --- a/test.c~ +++ b/test.c~ @@ -1,24 +1,24 @@ -/* 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 . +*/ /* Define PATTERN_MATCHING to get the csh-like =~ and !~ pattern-matching binary operators. */ @@ -310,7 +310,7 @@ filecomp (s, t, op) { 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); } @@ -659,7 +659,7 @@ int test_unop (op) char *op; { - if (op[0] != '-') + if (op[0] != '-' || op[2] != 0) return (0); switch (op[1]) diff --git a/tests/builtins1.sub b/tests/builtins1.sub index 5b7971136..52185b54f 100644 --- a/tests/builtins1.sub +++ b/tests/builtins1.sub @@ -10,5 +10,5 @@ cd $DIR pwd echo $PWD -cd $MYDIR +cd "$MYDIR" rmdir $FULLDIR diff --git a/tests/builtins1.sub~ b/tests/builtins1.sub~ new file mode 100644 index 000000000..5b7971136 --- /dev/null +++ b/tests/builtins1.sub~ @@ -0,0 +1,14 @@ +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 diff --git a/tests/dstack.tests b/tests/dstack.tests index 6c4cef142..49b97d3ff 100644 --- a/tests/dstack.tests +++ b/tests/dstack.tests @@ -84,4 +84,4 @@ dirs -c dirs # this is for the benefit of pure coverage -cd $MYDIR +cd "$MYDIR" diff --git a/tests/dstack.tests~ b/tests/dstack.tests~ new file mode 100644 index 000000000..6c4cef142 --- /dev/null +++ b/tests/dstack.tests~ @@ -0,0 +1,87 @@ +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 diff --git a/tests/extglob.tests b/tests/extglob.tests index 51e33ee73..c12fcaa22 100644 --- a/tests/extglob.tests +++ b/tests/extglob.tests @@ -358,7 +358,7 @@ 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 +builtin cd "$MYDIR" ${THIS_SH} ./extglob1.sub diff --git a/tests/extglob.tests~ b/tests/extglob.tests~ new file mode 100644 index 000000000..51e33ee73 --- /dev/null +++ b/tests/extglob.tests~ @@ -0,0 +1,365 @@ +# 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 diff --git a/tests/extglob1.sub b/tests/extglob1.sub index 3beec9e86..bf65a9eac 100644 --- a/tests/extglob1.sub +++ b/tests/extglob1.sub @@ -33,5 +33,5 @@ case . in *) echo bad 3;; esac -cd $MYDIR +cd "$MYDIR" rm -rf $GDIR diff --git a/tests/extglob1.sub~ b/tests/extglob1.sub~ new file mode 100644 index 000000000..3beec9e86 --- /dev/null +++ b/tests/extglob1.sub~ @@ -0,0 +1,37 @@ +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 diff --git a/tests/run-minimal b/tests/run-minimal index 5c5dcc498..0054cda85 100644 --- a/tests/run-minimal +++ b/tests/run-minimal @@ -27,7 +27,7 @@ do *.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 diff --git a/tests/run-minimal~ b/tests/run-minimal~ new file mode 100644 index 000000000..5c5dcc498 --- /dev/null +++ b/tests/run-minimal~ @@ -0,0 +1,36 @@ +#! /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 diff --git a/tests/run-nquote4 b/tests/run-nquote4 index f7d05bb29..493f4aa1e 100644 --- a/tests/run-nquote4 +++ b/tests/run-nquote4 @@ -1,4 +1,4 @@ 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 diff --git a/tests/run-nquote4~ b/tests/run-nquote4~ new file mode 100644 index 000000000..f7d05bb29 --- /dev/null +++ b/tests/run-nquote4~ @@ -0,0 +1,4 @@ +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 diff --git a/variables.c b/variables.c index 9f5478082..3b3276cf3 100644 --- a/variables.c +++ b/variables.c @@ -38,7 +38,9 @@ #include #include "chartypes.h" -#include +#if defined (HAVE_PWD_H) +# include +#endif #include "bashansi.h" #include "bashintl.h" @@ -4232,7 +4234,8 @@ void sv_globignore (name) char *name; { - setup_glob_ignore (name); + if (privileged_mode == 0) + setup_glob_ignore (name); } #if defined (READLINE) diff --git a/variables.c~ b/variables.c~ index e47e5bee8..21fffc714 100644 --- a/variables.c~ +++ b/variables.c~ @@ -38,7 +38,9 @@ #include #include "chartypes.h" -#include +#if defined (HAVE_PWD_H) +# include +#endif #include "bashansi.h" #include "bashintl.h" @@ -1912,11 +1914,7 @@ make_local_variable (name) } 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);