mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-12 14:40:50 +02:00
commit bash-20080710 snapshot
This commit is contained in:
@@ -6661,3 +6661,54 @@ Makefile.in,lib/sh/Makefile.in
|
||||
|
||||
doc/{bash.1,bashref.texi}
|
||||
- documented coprocesses and `coproc' reserved word
|
||||
|
||||
7/7
|
||||
---
|
||||
subst.c
|
||||
- fix array_length_reference to use MB_STRLEN instead of STRLEN, so
|
||||
multibyte characters in array values are computed correctly. Fixes
|
||||
bug reported by Wang Xin <wxinee@gmail.com>
|
||||
|
||||
7/10
|
||||
----
|
||||
jobs.c
|
||||
- new function, maybe_give_terminal_to (old, new, flags), sets the
|
||||
terminal pgrp to NEW if and only if it's currently set to OLD
|
||||
- call maybe_give_terminal_to when the parent sets the terminal pgrp
|
||||
to the pipeline pgrp in stop_pipeline, so we don't give the
|
||||
terminal to the new job's pgrp unless it's currently owned by the
|
||||
shell. Fixes race condition described by Joe Peterson
|
||||
<joe@skyrush.com>, where parent bash may change tty pgrp after a
|
||||
grandchild (interactive bash child of su) has changed it to
|
||||
something else. The call to maybe_give_terminal_to makes explicit
|
||||
a previously-implicit assumption
|
||||
|
||||
aclocal.m4
|
||||
- remove dependency on writable /tmp by creating directories in
|
||||
build directory
|
||||
|
||||
shell.c
|
||||
- make changes to how bash sets no_line_editing and running_under_emacs
|
||||
to deal with various emacs terminal emulators; use better check
|
||||
for `eterm', since bash sends $PWD to eterm with control sequences
|
||||
that confuse other programs. Problem reported by Micah Cowan
|
||||
<micah@cowan.name>
|
||||
|
||||
|
||||
7/12
|
||||
----
|
||||
print_cmd.c
|
||||
- break code that prints here-documents into two functions:
|
||||
print_heredoc_header, which prints the operator and delimiter, and
|
||||
print_heredoc_body, which prints the body text and closing delimiter
|
||||
- change print_redirection to call print_heredoc_{header,body}
|
||||
- sentinel variable, printing_connection, used when printing a command
|
||||
of type `connection' (|, &&, ||, etc.)
|
||||
- change print_redirection_list to save any here documents it finds
|
||||
while printing a connection and save them in `deferred_heredocs'
|
||||
- new function, print_deferred_heredocs, called from print_redirection
|
||||
in the cm_connection case, calls print_heredoc_header for all the
|
||||
here documents, then prints the operator (|, &&, ||, etc.), then
|
||||
the here-document body. This preserves syntactic correctness; the
|
||||
old code printed the control operator after the body of the here
|
||||
document. Fixes bug reported by <buport@figpost.com>
|
||||
|
||||
@@ -6658,3 +6658,38 @@ lib/sh/fdprintf.c
|
||||
|
||||
Makefile.in,lib/sh/Makefile.in
|
||||
- add rules to include fdprintf.o
|
||||
|
||||
doc/{bash.1,bashref.texi}
|
||||
- documented coprocesses and `coproc' reserved word
|
||||
|
||||
7/7
|
||||
---
|
||||
subst.c
|
||||
- fix array_length_reference to use MB_STRLEN instead of STRLEN, so
|
||||
multibyte characters in array values are computed correctly. Fixes
|
||||
bug reported by Wang Xin <wxinee@gmail.com>
|
||||
|
||||
7/10
|
||||
----
|
||||
jobs.c
|
||||
- new function, maybe_give_terminal_to (old, new, flags), sets the
|
||||
terminal pgrp to NEW if and only if it's currently set to OLD
|
||||
- call maybe_give_terminal_to when the parent sets the terminal pgrp
|
||||
to the pipeline pgrp in stop_pipeline, so we don't give the
|
||||
terminal to the new job's pgrp unless it's currently owned by the
|
||||
shell. Fixes race condition described by Joe Peterson
|
||||
<joe@skyrush.com>, where parent bash may change tty pgrp after a
|
||||
grandchild (interactive bash child of su) has changed it to
|
||||
something else. The call to maybe_give_terminal_to makes explicit
|
||||
a previously-implicit assumption
|
||||
|
||||
aclocal.m4
|
||||
- remove dependency on writable /tmp by creating directories in
|
||||
build directory
|
||||
|
||||
shell.c
|
||||
- make changes to how bash sets no_line_editing and running_under_emacs
|
||||
to deal with various emacs terminal emulators; use better check
|
||||
for `eterm', since bash sends $PWD to eterm with control sequences
|
||||
that confuse other programs. Problem reported by Micah Cowan
|
||||
<micah@cowan.name>
|
||||
|
||||
Vendored
+11
-11
@@ -336,18 +336,18 @@ main()
|
||||
{
|
||||
DIR *dir;
|
||||
int fd, err;
|
||||
err = mkdir("/tmp/bash-aclocal", 0700);
|
||||
err = mkdir("bash-aclocal", 0700);
|
||||
if (err < 0) {
|
||||
perror("mkdir");
|
||||
exit(1);
|
||||
}
|
||||
unlink("/tmp/bash-aclocal/not_a_directory");
|
||||
fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
|
||||
unlink("bash-aclocal/not_a_directory");
|
||||
fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
|
||||
write(fd, "\n", 1);
|
||||
close(fd);
|
||||
dir = opendir("/tmp/bash-aclocal/not_a_directory");
|
||||
unlink("/tmp/bash-aclocal/not_a_directory");
|
||||
rmdir("/tmp/bash-aclocal");
|
||||
dir = opendir("bash-aclocal/not_a_directory");
|
||||
unlink("bash-aclocal/not_a_directory");
|
||||
rmdir("bash-aclocal");
|
||||
exit (dir == 0);
|
||||
}], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no,
|
||||
[AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no)
|
||||
@@ -1423,19 +1423,19 @@ exit (1);
|
||||
#if defined (NeXT)
|
||||
exit (1);
|
||||
#endif
|
||||
err = mkdir("/tmp/bash-aclocal", 0700);
|
||||
err = mkdir("bash-aclocal", 0700);
|
||||
if (err < 0) {
|
||||
perror ("mkdir");
|
||||
exit(1);
|
||||
}
|
||||
fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
|
||||
fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
|
||||
if (fd == -1) {
|
||||
rmdir ("/tmp/bash-aclocal");
|
||||
rmdir ("bash-aclocal");
|
||||
exit (1);
|
||||
}
|
||||
close(fd);
|
||||
unlink ("/tmp/bash-aclocal/sh-np-autoconf");
|
||||
rmdir ("/tmp/bash-aclocal");
|
||||
unlink ("bash-aclocal/sh-np-autoconf");
|
||||
rmdir ("bash-aclocal");
|
||||
exit(0);
|
||||
}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing,
|
||||
[AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing)
|
||||
|
||||
Vendored
+2
-1
@@ -1677,8 +1677,9 @@ AC_CHECK_HEADERS(wctype.h)
|
||||
AC_CHECK_HEADERS(wchar.h)
|
||||
AC_CHECK_HEADERS(langinfo.h)
|
||||
|
||||
AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
|
||||
AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
|
||||
AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
|
||||
AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
|
||||
|
||||
AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
|
||||
AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL))
|
||||
|
||||
+11
-11
@@ -29310,18 +29310,18 @@ main()
|
||||
{
|
||||
DIR *dir;
|
||||
int fd, err;
|
||||
err = mkdir("/tmp/bash-aclocal", 0700);
|
||||
err = mkdir("bash-aclocal", 0700);
|
||||
if (err < 0) {
|
||||
perror("mkdir");
|
||||
exit(1);
|
||||
}
|
||||
unlink("/tmp/bash-aclocal/not_a_directory");
|
||||
fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
|
||||
unlink("bash-aclocal/not_a_directory");
|
||||
fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
|
||||
write(fd, "\n", 1);
|
||||
close(fd);
|
||||
dir = opendir("/tmp/bash-aclocal/not_a_directory");
|
||||
unlink("/tmp/bash-aclocal/not_a_directory");
|
||||
rmdir("/tmp/bash-aclocal");
|
||||
dir = opendir("bash-aclocal/not_a_directory");
|
||||
unlink("bash-aclocal/not_a_directory");
|
||||
rmdir("bash-aclocal");
|
||||
exit (dir == 0);
|
||||
}
|
||||
_ACEOF
|
||||
@@ -30568,19 +30568,19 @@ exit (1);
|
||||
#if defined (NeXT)
|
||||
exit (1);
|
||||
#endif
|
||||
err = mkdir("/tmp/bash-aclocal", 0700);
|
||||
err = mkdir("bash-aclocal", 0700);
|
||||
if (err < 0) {
|
||||
perror ("mkdir");
|
||||
exit(1);
|
||||
}
|
||||
fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
|
||||
fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
|
||||
if (fd == -1) {
|
||||
rmdir ("/tmp/bash-aclocal");
|
||||
rmdir ("bash-aclocal");
|
||||
exit (1);
|
||||
}
|
||||
close(fd);
|
||||
unlink ("/tmp/bash-aclocal/sh-np-autoconf");
|
||||
rmdir ("/tmp/bash-aclocal");
|
||||
unlink ("bash-aclocal/sh-np-autoconf");
|
||||
rmdir ("bash-aclocal");
|
||||
exit(0);
|
||||
}
|
||||
_ACEOF
|
||||
|
||||
+25
-25
@@ -20,21 +20,21 @@
|
||||
'm4_pattern_forbid' => 1,
|
||||
'AC_CANONICAL_TARGET' => 1,
|
||||
'AC_CONFIG_LIBOBJ_DIR' => 1,
|
||||
'AC_C_VOLATILE' => 1,
|
||||
'AC_TYPE_OFF_T' => 1,
|
||||
'AC_C_VOLATILE' => 1,
|
||||
'AC_FUNC_CLOSEDIR_VOID' => 1,
|
||||
'AC_REPLACE_FNMATCH' => 1,
|
||||
'AC_PROG_LIBTOOL' => 1,
|
||||
'AC_FUNC_STAT' => 1,
|
||||
'AC_FUNC_WAIT3' => 1,
|
||||
'AC_HEADER_TIME' => 1,
|
||||
'AM_AUTOMAKE_VERSION' => 1,
|
||||
'AC_FUNC_LSTAT' => 1,
|
||||
'AC_FUNC_WAIT3' => 1,
|
||||
'AC_STRUCT_TM' => 1,
|
||||
'AC_FUNC_GETMNTENT' => 1,
|
||||
'AC_FUNC_LSTAT' => 1,
|
||||
'AM_AUTOMAKE_VERSION' => 1,
|
||||
'AC_TYPE_MODE_T' => 1,
|
||||
'AC_CHECK_HEADERS' => 1,
|
||||
'AC_FUNC_GETMNTENT' => 1,
|
||||
'AC_FUNC_STRTOD' => 1,
|
||||
'AC_CHECK_HEADERS' => 1,
|
||||
'LT_CONFIG_LTDL_DIR' => 1,
|
||||
'AC_FUNC_STRNLEN' => 1,
|
||||
'm4_sinclude' => 1,
|
||||
@@ -52,22 +52,22 @@
|
||||
'AC_LIBSOURCE' => 1,
|
||||
'AC_FUNC_MBRTOWC' => 1,
|
||||
'AC_STRUCT_ST_BLOCKS' => 1,
|
||||
'AC_CANONICAL_BUILD' => 1,
|
||||
'AM_PROG_FC_C_O' => 1,
|
||||
'AC_TYPE_SIGNAL' => 1,
|
||||
'AM_PROG_FC_C_O' => 1,
|
||||
'AC_CANONICAL_BUILD' => 1,
|
||||
'AC_TYPE_UID_T' => 1,
|
||||
'AC_CONFIG_AUX_DIR' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'AC_PROG_MAKE_SET' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'AC_CONFIG_AUX_DIR' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'sinclude' => 1,
|
||||
'AC_DEFINE_TRACE_LITERAL' => 1,
|
||||
'AC_FUNC_STRERROR_R' => 1,
|
||||
'AC_PROG_CC' => 1,
|
||||
'AC_DECL_SYS_SIGLIST' => 1,
|
||||
'AC_FUNC_FORK' => 1,
|
||||
'AC_FUNC_STRCOLL' => 1,
|
||||
'AC_DECL_SYS_SIGLIST' => 1,
|
||||
'AC_FUNC_VPRINTF' => 1,
|
||||
'AC_FUNC_STRCOLL' => 1,
|
||||
'AC_PROG_YACC' => 1,
|
||||
'AC_SUBST_TRACE' => 1,
|
||||
'AC_STRUCT_TIMEZONE' => 1,
|
||||
@@ -75,54 +75,54 @@
|
||||
'AC_FUNC_CHOWN' => 1,
|
||||
'AC_SUBST' => 1,
|
||||
'AC_FUNC_ALLOCA' => 1,
|
||||
'AC_CANONICAL_HOST' => 1,
|
||||
'AC_FC_SRCEXT' => 1,
|
||||
'AC_CANONICAL_HOST' => 1,
|
||||
'AC_FUNC_GETPGRP' => 1,
|
||||
'AC_PROG_RANLIB' => 1,
|
||||
'AM_INIT_AUTOMAKE' => 1,
|
||||
'AC_FUNC_SETPGRP' => 1,
|
||||
'AM_INIT_AUTOMAKE' => 1,
|
||||
'AC_CONFIG_SUBDIRS' => 1,
|
||||
'AC_FUNC_MMAP' => 1,
|
||||
'AC_FUNC_REALLOC' => 1,
|
||||
'AC_TYPE_SIZE_T' => 1,
|
||||
'AC_CHECK_TYPES' => 1,
|
||||
'AC_REQUIRE_AUX_FILE' => 1,
|
||||
'AC_CONFIG_LINKS' => 1,
|
||||
'AC_REQUIRE_AUX_FILE' => 1,
|
||||
'AC_CHECK_TYPES' => 1,
|
||||
'LT_SUPPORTED_TAG' => 1,
|
||||
'AC_CHECK_MEMBERS' => 1,
|
||||
'AM_MAINTAINER_MODE' => 1,
|
||||
'AC_FUNC_UTIME_NULL' => 1,
|
||||
'AC_FUNC_SELECT_ARGTYPES' => 1,
|
||||
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
|
||||
'AC_FUNC_STRFTIME' => 1,
|
||||
'AC_HEADER_STAT' => 1,
|
||||
'AC_C_INLINE' => 1,
|
||||
'AC_FUNC_STRFTIME' => 1,
|
||||
'AC_PROG_CPP' => 1,
|
||||
'AC_C_CONST' => 1,
|
||||
'AM_ENABLE_MULTILIB' => 1,
|
||||
'AC_PROG_LEX' => 1,
|
||||
'AC_C_INLINE' => 1,
|
||||
'AC_TYPE_PID_T' => 1,
|
||||
'AC_PROG_LEX' => 1,
|
||||
'AM_ENABLE_MULTILIB' => 1,
|
||||
'AC_C_CONST' => 1,
|
||||
'AC_CONFIG_FILES' => 1,
|
||||
'include' => 1,
|
||||
'AC_FUNC_SETVBUF_REVERSED' => 1,
|
||||
'AC_PROG_INSTALL' => 1,
|
||||
'AM_GNU_GETTEXT' => 1,
|
||||
'AC_CHECK_LIB' => 1,
|
||||
'AC_FUNC_OBSTACK' => 1,
|
||||
'AC_CHECK_LIB' => 1,
|
||||
'AC_FUNC_MALLOC' => 1,
|
||||
'AC_FUNC_GETGROUPS' => 1,
|
||||
'AC_FUNC_GETLOADAVG' => 1,
|
||||
'AC_FC_FREEFORM' => 1,
|
||||
'AC_FUNC_GETLOADAVG' => 1,
|
||||
'AH_OUTPUT' => 1,
|
||||
'AC_FUNC_FSEEKO' => 1,
|
||||
'AM_PROG_CC_C_O' => 1,
|
||||
'AC_FUNC_MKTIME' => 1,
|
||||
'AC_CANONICAL_SYSTEM' => 1,
|
||||
'AM_CONDITIONAL' => 1,
|
||||
'AC_FUNC_MKTIME' => 1,
|
||||
'AC_CONFIG_HEADERS' => 1,
|
||||
'AC_HEADER_SYS_WAIT' => 1,
|
||||
'AC_FUNC_MEMCMP' => 1,
|
||||
'AC_PROG_LN_S' => 1,
|
||||
'AC_FUNC_MEMCMP' => 1,
|
||||
'm4_include' => 1,
|
||||
'AC_HEADER_DIRENT' => 1,
|
||||
'AC_CHECK_FUNCS' => 1
|
||||
|
||||
@@ -67,6 +67,8 @@ $END
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bashansi.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
+3
-2
@@ -51,7 +51,8 @@ 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.
|
||||
fractional number. 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:
|
||||
@@ -374,7 +375,7 @@ read_builtin (list)
|
||||
return (EXECUTION_FAILURE);
|
||||
#else
|
||||
input_string[i] = '\0'; /* make sure it's terminated */
|
||||
retval = EXECUTION_FAILURE;
|
||||
retval = 128+SIGALRM;;
|
||||
goto assign_vars;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -29310,18 +29310,18 @@ main()
|
||||
{
|
||||
DIR *dir;
|
||||
int fd, err;
|
||||
err = mkdir("/tmp/bash-aclocal", 0700);
|
||||
err = mkdir("bash-aclocal", 0700);
|
||||
if (err < 0) {
|
||||
perror("mkdir");
|
||||
exit(1);
|
||||
}
|
||||
unlink("/tmp/bash-aclocal/not_a_directory");
|
||||
fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
|
||||
unlink("bash-aclocal/not_a_directory");
|
||||
fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
|
||||
write(fd, "\n", 1);
|
||||
close(fd);
|
||||
dir = opendir("/tmp/bash-aclocal/not_a_directory");
|
||||
unlink("/tmp/bash-aclocal/not_a_directory");
|
||||
rmdir("/tmp/bash-aclocal");
|
||||
dir = opendir("bash-aclocal/not_a_directory");
|
||||
unlink("bash-aclocal/not_a_directory");
|
||||
rmdir("bash-aclocal");
|
||||
exit (dir == 0);
|
||||
}
|
||||
_ACEOF
|
||||
@@ -30568,19 +30568,19 @@ exit (1);
|
||||
#if defined (NeXT)
|
||||
exit (1);
|
||||
#endif
|
||||
err = mkdir("/tmp/bash-aclocal", 0700);
|
||||
err = mkdir("bash-aclocal", 0700);
|
||||
if (err < 0) {
|
||||
perror ("mkdir");
|
||||
exit(1);
|
||||
}
|
||||
fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
|
||||
fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
|
||||
if (fd == -1) {
|
||||
rmdir ("/tmp/bash-aclocal");
|
||||
rmdir ("bash-aclocal");
|
||||
exit (1);
|
||||
}
|
||||
close(fd);
|
||||
unlink ("/tmp/bash-aclocal/sh-np-autoconf");
|
||||
rmdir ("/tmp/bash-aclocal");
|
||||
unlink ("bash-aclocal/sh-np-autoconf");
|
||||
rmdir ("bash-aclocal");
|
||||
exit(0);
|
||||
}
|
||||
_ACEOF
|
||||
|
||||
@@ -1,282 +1,667 @@
|
||||
*** ../bash-20080221/doc/bashref.texi 2008-02-22 21:44:51.000000000 -0500
|
||||
--- doc/bashref.texi 2008-04-25 12:32:42.000000000 -0400
|
||||
*** ../bash-3.2-patched/lib/readline/display.c 2007-12-13 22:31:16.000000000 -0500
|
||||
--- lib/readline/display.c 2008-05-21 21:39:43.000000000 -0400
|
||||
***************
|
||||
*** 681,688 ****
|
||||
waits for each command to terminate in turn. The return status is the
|
||||
exit status of the last command executed.
|
||||
*** 1,5 ****
|
||||
/* display.c -- readline redisplay facility. */
|
||||
|
||||
! The control operators @samp{&&} and @samp{||}
|
||||
! denote @sc{and} lists and @sc{or} lists, respectively.
|
||||
An @sc{and} list has the form
|
||||
@example
|
||||
@var{command1} && @var{command2}
|
||||
--- 681,691 ----
|
||||
waits for each command to terminate in turn. The return status is the
|
||||
exit status of the last command executed.
|
||||
! /* Copyright (C) 1987-2006 Free Software Foundation, Inc.
|
||||
|
||||
! @sc{and} and @sc{or} lists are sequences of one or more pipelines
|
||||
! separated by the control operators @samp{&&} and @samp{||},
|
||||
! respectively. @sc{and} and @sc{or} lists are executed with left
|
||||
! associativity.
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
--- 1,5 ----
|
||||
/* display.c -- readline redisplay facility. */
|
||||
|
||||
! /* Copyright (C) 1987-2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
***************
|
||||
*** 66,79 ****
|
||||
static void cr PARAMS((void));
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static int _rl_col_width PARAMS((const char *, int, int));
|
||||
- static int *_rl_wrapped_line;
|
||||
#else
|
||||
# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s))
|
||||
#endif
|
||||
|
||||
- static int *inv_lbreaks, *vis_lbreaks;
|
||||
- static int inv_lbsize, vis_lbsize;
|
||||
-
|
||||
/* Heuristic used to decide whether it is faster to move from CUR to NEW
|
||||
by backing up or outputting a carriage return and moving forward. CUR
|
||||
--- 66,103 ----
|
||||
static void cr PARAMS((void));
|
||||
|
||||
+ /* State of visible and invisible lines. */
|
||||
+ struct line_state
|
||||
+ {
|
||||
+ char *line;
|
||||
+ int *lbreaks;
|
||||
+ int lbsize;
|
||||
+ #if defined (HANDLE_MULTIBYTE)
|
||||
+ int *wrapped_line;
|
||||
+ int wbsize;
|
||||
+ #endif
|
||||
+ };
|
||||
+
|
||||
+ /* The line display buffers. One is the line currently displayed on
|
||||
+ the screen. The other is the line about to be displayed. */
|
||||
+ static struct line_state line_state_array[2];
|
||||
+ static struct line_state *line_state_visible = &line_state_array[0];
|
||||
+ static struct line_state *line_state_invisible = &line_state_array[1];
|
||||
+ static int line_structures_initialized = 0;
|
||||
+
|
||||
+ /* Backwards-compatible names. */
|
||||
+ #define inv_lbreaks (line_state_invisible->lbreaks)
|
||||
+ #define inv_lbsize (line_state_invisible->lbsize)
|
||||
+ #define vis_lbreaks (line_state_visible->lbreaks)
|
||||
+ #define vis_lbsize (line_state_visible->lbsize)
|
||||
+
|
||||
+ #define visible_line (line_state_visible->line)
|
||||
+ #define invisible_line (line_state_invisible->line)
|
||||
+
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static int _rl_col_width PARAMS((const char *, int, int));
|
||||
#else
|
||||
# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s))
|
||||
#endif
|
||||
|
||||
/* Heuristic used to decide whether it is faster to move from CUR to NEW
|
||||
by backing up or outputting a carriage return and moving forward. CUR
|
||||
***************
|
||||
*** 84,88 ****
|
||||
buffer index in others. This macro is used when deciding whether the
|
||||
current cursor position is in the middle of a prompt string containing
|
||||
! invisible characters. */
|
||||
#define PROMPT_ENDING_INDEX \
|
||||
((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1)
|
||||
--- 108,112 ----
|
||||
buffer index in others. This macro is used when deciding whether the
|
||||
current cursor position is in the middle of a prompt string containing
|
||||
! invisible characters. XXX - might need to take `modmark' into account. */
|
||||
#define PROMPT_ENDING_INDEX \
|
||||
((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1)
|
||||
***************
|
||||
*** 142,145 ****
|
||||
--- 166,170 ----
|
||||
static int cpos_adjusted;
|
||||
static int cpos_buffer_position;
|
||||
+ static int prompt_multibyte_chars;
|
||||
|
||||
/* Number of lines currently on screen minus 1. */
|
||||
***************
|
||||
*** 151,159 ****
|
||||
static int last_lmargin;
|
||||
|
||||
- /* The line display buffers. One is the line currently displayed on
|
||||
- the screen. The other is the line about to be displayed. */
|
||||
- static char *visible_line = (char *)NULL;
|
||||
- static char *invisible_line = (char *)NULL;
|
||||
-
|
||||
/* A buffer for `modeline' messages. */
|
||||
static char msg_buf[128];
|
||||
--- 176,179 ----
|
||||
***************
|
||||
*** 196,199 ****
|
||||
--- 216,223 ----
|
||||
static int prompt_physical_chars;
|
||||
|
||||
+ /* set to a non-zero value by rl_redisplay if we are marking modified history
|
||||
+ lines and the current line is so marked. */
|
||||
+ static int modmark;
|
||||
+
|
||||
/* Variables to save and restore prompt and display information. */
|
||||
|
||||
***************
|
||||
*** 283,286 ****
|
||||
--- 307,315 ----
|
||||
if (!ignoring)
|
||||
{
|
||||
+ /* rl ends up being assigned to prompt_visible_length,
|
||||
+ which is the number of characters in the buffer that
|
||||
+ contribute to characters on the screen, which might
|
||||
+ not be the same as the number of physical characters
|
||||
+ on the screen in the presence of multibyte characters */
|
||||
rl += ind - pind;
|
||||
physchars += _rl_col_width (pmt, pind, ind);
|
||||
***************
|
||||
*** 444,454 ****
|
||||
/* should be enough. */
|
||||
inv_lbsize = vis_lbsize = 256;
|
||||
! inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
|
||||
! vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
! _rl_wrapped_line = (int *)xmalloc (vis_lbsize * sizeof (int));
|
||||
#endif
|
||||
inv_lbreaks[0] = vis_lbreaks[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
--- 473,491 ----
|
||||
/* should be enough. */
|
||||
inv_lbsize = vis_lbsize = 256;
|
||||
!
|
||||
An @sc{and} list has the form
|
||||
@example
|
||||
@var{command1} && @var{command2}
|
||||
***************
|
||||
*** 2298,2304 ****
|
||||
(see the description of @code{hash} in @ref{Bourne Shell Builtins}).
|
||||
A full search of the directories in @env{$PATH}
|
||||
is performed only if the command is not found in the hash table.
|
||||
! If the search is unsuccessful, the shell prints an error
|
||||
message and returns an exit status of 127.
|
||||
|
||||
@item
|
||||
--- 2301,2312 ----
|
||||
(see the description of @code{hash} in @ref{Bourne Shell Builtins}).
|
||||
A full search of the directories in @env{$PATH}
|
||||
is performed only if the command is not found in the hash table.
|
||||
! If the search is unsuccessful, the shell searches for a defined shell
|
||||
! function named @code{command_not_found_handle}.
|
||||
! If that function exists, it is invoked with the original command and
|
||||
! the original command's arguments as its arguments, and the function's
|
||||
! exit status becomes the exit status of the shell.
|
||||
! If that function is not defined, the shell prints an error
|
||||
message and returns an exit status of 127.
|
||||
|
||||
@item
|
||||
***************
|
||||
*** 3129,3134 ****
|
||||
--- 3137,3143 ----
|
||||
Readline initialization file (@pxref{Readline Init File}),
|
||||
but each binding or command must be passed as a separate argument; e.g.,
|
||||
@samp{"\C-x\C-r":re-read-init-file}.
|
||||
+
|
||||
Options, if supplied, have the following meanings:
|
||||
|
||||
@table @code
|
||||
***************
|
||||
*** 3262,3268 ****
|
||||
|
||||
The @option{-p} option will display the attributes and values of each
|
||||
@var{name}.
|
||||
! When @option{-p} is used, additional options are ignored.
|
||||
The @option{-F} option inhibits the display of function definitions;
|
||||
only the function name and attributes are printed.
|
||||
If the @code{extdebug} shell option is enabled using @code{shopt}
|
||||
--- 3271,3286 ----
|
||||
|
||||
The @option{-p} option will display the attributes and values of each
|
||||
@var{name}.
|
||||
! When @option{-p} is used with @var{name} arguments, additional options
|
||||
! are ignored.
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
! line_state_visible->wbsize = vis_lbsize;
|
||||
! line_state_visible->wrapped_line = (int *)xmalloc (line_state_visible->wbsize * sizeof (int));
|
||||
!
|
||||
! When @option{-p} is supplied without @var{name} arguments, @code{declare}
|
||||
! will display the attributes and values of all variables having the
|
||||
! attributes specified by the additional options.
|
||||
! If no other options are supplied with @option{-p}, @code{declare} will
|
||||
! display the attributes and values of all shell variables. The @option{-f}
|
||||
! option will restrict the display to shell functions.
|
||||
! line_state_invisible->wbsize = inv_lbsize;
|
||||
! line_state_invisible->wrapped_line = (int *)xmalloc (line_state_invisible->wbsize * sizeof (int));
|
||||
#endif
|
||||
+
|
||||
+ inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
|
||||
+ vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
|
||||
inv_lbreaks[0] = vis_lbreaks[0] = 0;
|
||||
}
|
||||
+
|
||||
+ line_structures_initialized = 1;
|
||||
}
|
||||
|
||||
***************
|
||||
*** 460,464 ****
|
||||
register char *line;
|
||||
int inv_botlin, lb_botlin, lb_linenum, o_cpos;
|
||||
! int newlines, lpos, temp, modmark, n0, num;
|
||||
char *prompt_this_line;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
--- 497,501 ----
|
||||
register char *line;
|
||||
int inv_botlin, lb_botlin, lb_linenum, o_cpos;
|
||||
! int newlines, lpos, temp, n0, num;
|
||||
char *prompt_this_line;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
***************
|
||||
*** 470,480 ****
|
||||
#endif
|
||||
|
||||
! if (!readline_echoing_p)
|
||||
return;
|
||||
|
||||
if (!rl_display_prompt)
|
||||
rl_display_prompt = "";
|
||||
|
||||
! if (invisible_line == 0 || vis_lbreaks == 0)
|
||||
{
|
||||
init_line_structures (0);
|
||||
--- 507,521 ----
|
||||
#endif
|
||||
|
||||
! if (_rl_echoing_p == 0)
|
||||
return;
|
||||
|
||||
+ /* Block keyboard interrupts because this function manipulates global
|
||||
+ data structures. */
|
||||
+ _rl_block_sigint ();
|
||||
+
|
||||
if (!rl_display_prompt)
|
||||
rl_display_prompt = "";
|
||||
|
||||
! if (line_structures_initialized == 0)
|
||||
{
|
||||
init_line_structures (0);
|
||||
***************
|
||||
*** 485,488 ****
|
||||
--- 526,531 ----
|
||||
cpos_buffer_position = -1;
|
||||
|
||||
+ prompt_multibyte_chars = prompt_visible_length - prompt_physical_chars;
|
||||
+
|
||||
line = invisible_line;
|
||||
out = inv_botlin = 0;
|
||||
***************
|
||||
*** 562,576 ****
|
||||
}
|
||||
|
||||
- #if defined (HANDLE_MULTIBYTE)
|
||||
- #define CHECK_INV_LBREAKS() \
|
||||
- do { \
|
||||
- if (newlines >= (inv_lbsize - 2)) \
|
||||
- { \
|
||||
- inv_lbsize *= 2; \
|
||||
- inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
|
||||
- _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
|
||||
- } \
|
||||
- } while (0)
|
||||
- #else
|
||||
#define CHECK_INV_LBREAKS() \
|
||||
do { \
|
||||
--- 605,608 ----
|
||||
***************
|
||||
*** 581,585 ****
|
||||
} \
|
||||
} while (0)
|
||||
- #endif /* HANDLE_MULTIBYTE */
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
--- 613,616 ----
|
||||
***************
|
||||
*** 593,600 ****
|
||||
inv_lbsize *= 2; \
|
||||
inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
|
||||
- _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
|
||||
} \
|
||||
inv_lbreaks[++newlines] = out; \
|
||||
! _rl_wrapped_line[newlines] = _rl_wrapped_multicolumn; \
|
||||
lpos = 0; \
|
||||
} \
|
||||
--- 624,635 ----
|
||||
inv_lbsize *= 2; \
|
||||
inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
|
||||
} \
|
||||
inv_lbreaks[++newlines] = out; \
|
||||
! if (newlines >= (line_state_invisible->wbsize - 1)) \
|
||||
! { \
|
||||
! line_state_invisible->wbsize *= 2; \
|
||||
! line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, line_state_invisible->wbsize * sizeof(int)); \
|
||||
! } \
|
||||
! line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; \
|
||||
lpos = 0; \
|
||||
} \
|
||||
***************
|
||||
*** 626,630 ****
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
! memset (_rl_wrapped_line, 0, vis_lbsize);
|
||||
num = 0;
|
||||
#endif
|
||||
--- 661,665 ----
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
! memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wbsize * sizeof (int));
|
||||
num = 0;
|
||||
#endif
|
||||
***************
|
||||
*** 648,652 ****
|
||||
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
! if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
n0 = num;
|
||||
--- 683,687 ----
|
||||
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
! if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
|
||||
{
|
||||
n0 = num;
|
||||
***************
|
||||
*** 671,674 ****
|
||||
--- 706,711 ----
|
||||
|
||||
/* Now account for invisible characters in the current line. */
|
||||
+ /* XXX - this assumes that all of the invisible characters are before
|
||||
+ the line wrap. */
|
||||
temp += ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
|
||||
: ((newlines == 1) ? wrap_offset : 0))
|
||||
***************
|
||||
*** 677,681 ****
|
||||
inv_lbreaks[++newlines] = temp;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
! if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
lpos -= _rl_col_width (local_prompt, n0, num);
|
||||
else
|
||||
--- 714,718 ----
|
||||
inv_lbreaks[++newlines] = temp;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
! if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
|
||||
lpos -= _rl_col_width (local_prompt, n0, num);
|
||||
else
|
||||
***************
|
||||
*** 911,914 ****
|
||||
--- 948,955 ----
|
||||
OFFSET (which has already been calculated above). */
|
||||
|
||||
+ #define INVIS_FIRST() (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)
|
||||
+ #define WRAP_OFFSET(line, offset) ((line == 0) \
|
||||
+ ? (offset ? INVIS_FIRST() : 0) \
|
||||
+ : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
|
||||
#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
|
||||
#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
|
||||
***************
|
||||
*** 945,949 ****
|
||||
_rl_last_c_pos > wrap_offset &&
|
||||
o_cpos < prompt_last_invisible)
|
||||
! _rl_last_c_pos -= wrap_offset;
|
||||
|
||||
/* If this is the line with the prompt, we might need to
|
||||
--- 986,1001 ----
|
||||
_rl_last_c_pos > wrap_offset &&
|
||||
o_cpos < prompt_last_invisible)
|
||||
! _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
|
||||
!
|
||||
The @option{-F} option inhibits the display of function definitions;
|
||||
only the function name and attributes are printed.
|
||||
If the @code{extdebug} shell option is enabled using @code{shopt}
|
||||
! else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
|
||||
! (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
|
||||
! cpos_adjusted == 0 &&
|
||||
! _rl_last_c_pos != o_cpos &&
|
||||
! #if 0
|
||||
! _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - (wrap_offset-prompt_invis_chars_first_line)))
|
||||
! #else
|
||||
! _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
|
||||
! #endif
|
||||
! _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
|
||||
|
||||
/* If this is the line with the prompt, we might need to
|
||||
***************
|
||||
*** 3400,3413 ****
|
||||
@item help
|
||||
@btindex help
|
||||
@example
|
||||
! help [-s] [@var{pattern}]
|
||||
@end example
|
||||
Display helpful information about builtin commands.
|
||||
If @var{pattern} is specified, @code{help} gives detailed help
|
||||
on all commands matching @var{pattern}, otherwise a list of
|
||||
the builtins is printed.
|
||||
! The @option{-s} option restricts the information displayed to a short
|
||||
! usage synopsis.
|
||||
The return status is zero unless no command matches @var{pattern}.
|
||||
*** 965,968 ****
|
||||
--- 1017,1033 ----
|
||||
_rl_clear_to_eol (nleft);
|
||||
}
|
||||
+ #if 0
|
||||
+ /* This segment is intended to handle the case where the prompt
|
||||
+ has invisible characters on the second line and the new line
|
||||
+ to be displayed needs to clear the rest of the old characters
|
||||
+ out (e.g., when printing the i-search prompt). In general,
|
||||
+ the case of the new line being shorter than the old.
|
||||
+ Incomplete */
|
||||
+ else if (linenum == prompt_last_screen_line &&
|
||||
+ prompt_physical_chars > _rl_screenwidth &&
|
||||
+ wrap_offset != prompt_invis_chars_first_line &&
|
||||
+ _rl_last_c_pos == out &&
|
||||
+ #endif
|
||||
+
|
||||
|
||||
@item let
|
||||
--- 3418,3441 ----
|
||||
@item help
|
||||
@btindex help
|
||||
@example
|
||||
! help [-dms] [@var{pattern}]
|
||||
@end example
|
||||
Display helpful information about builtin commands.
|
||||
If @var{pattern} is specified, @code{help} gives detailed help
|
||||
on all commands matching @var{pattern}, otherwise a list of
|
||||
the builtins is printed.
|
||||
/* Since the new first line is now visible, save its length. */
|
||||
***************
|
||||
*** 1020,1028 ****
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif
|
||||
_rl_output_some_chars (local_prompt, nleft);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
! _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft) - wrap_offset;
|
||||
else
|
||||
! _rl_last_c_pos = nleft;
|
||||
}
|
||||
|
||||
--- 1085,1096 ----
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif
|
||||
+ if (modmark)
|
||||
+ _rl_output_some_chars ("*", 1);
|
||||
+
|
||||
_rl_output_some_chars (local_prompt, nleft);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
! _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft) - wrap_offset + modmark;
|
||||
else
|
||||
! _rl_last_c_pos = nleft + modmark;
|
||||
}
|
||||
|
||||
***************
|
||||
*** 1160,1174 ****
|
||||
/* Swap visible and non-visible lines. */
|
||||
{
|
||||
! char *vtemp = visible_line;
|
||||
! int *itemp = vis_lbreaks, ntemp = vis_lbsize;
|
||||
!
|
||||
! Options, if supplied, have the following meanings:
|
||||
! visible_line = invisible_line;
|
||||
! invisible_line = vtemp;
|
||||
|
||||
! vis_lbreaks = inv_lbreaks;
|
||||
! inv_lbreaks = itemp;
|
||||
!
|
||||
! @table @code
|
||||
! @item -d
|
||||
! Display a short description of each @var{pattern}
|
||||
! @item -m
|
||||
! Display the description of each @var{pattern} in a manpage-like format
|
||||
! @item -s
|
||||
! Display only a short usage synopsis for each @var{pattern}
|
||||
! @end table
|
||||
!
|
||||
The return status is zero unless no command matches @var{pattern}.
|
||||
! vis_lbsize = inv_lbsize;
|
||||
! inv_lbsize = ntemp;
|
||||
|
||||
@item let
|
||||
rl_display_fixed = 0;
|
||||
--- 1228,1235 ----
|
||||
/* Swap visible and non-visible lines. */
|
||||
{
|
||||
! struct line_state *vtemp = line_state_visible;
|
||||
|
||||
! line_state_visible = line_state_invisible;
|
||||
! line_state_invisible = vtemp;
|
||||
|
||||
rl_display_fixed = 0;
|
||||
***************
|
||||
*** 3443,3448 ****
|
||||
--- 3471,3516 ----
|
||||
Exit a login shell, returning a status of @var{n} to the shell's
|
||||
parent.
|
||||
|
||||
+ @item mapfile
|
||||
+ @btindex mapfile
|
||||
+ @example
|
||||
+ mapfile [-n @var{count}] [-O @var{origin}] [-s @var{count}] [-t] [-u @var{fd}] [
|
||||
+ -C @var{callback}] [-c @var{quantum}] [@var{array}]
|
||||
+ @end example
|
||||
+ Read lines from the standard input into array variable @var{array},
|
||||
+ or from file descriptor @var{fd}
|
||||
+ if the @option{-u} option is supplied.
|
||||
+ The variable @code{MAPFILE} is the default @var{array}.
|
||||
+ Options, if supplied, have the following meanings:
|
||||
+ @table @code
|
||||
*** 1181,1184 ****
|
||||
--- 1242,1247 ----
|
||||
visible_wrap_offset = wrap_offset;
|
||||
}
|
||||
+
|
||||
+ @item -n
|
||||
+ Copy at most @var{count} lines. If @var{count} is 0, all lines are copied.
|
||||
+ @item -O
|
||||
+ Begin assigning to @var{array} at index @var{origin}.
|
||||
+ The default index is 0.
|
||||
+ @item -s
|
||||
+ Discard the first @var{count} lines read.
|
||||
+ @item -t
|
||||
+ Remove a trailing line from each line read.
|
||||
+ @item -u
|
||||
+ Read lines from file descriptor @var{fd} instead of the standard input.
|
||||
+ @item -C
|
||||
+ Evaluate @var{callback} each time @var{quantum}P lines are read.
|
||||
+ The @option{-c} option specifies @var{quantum}.
|
||||
+ @item -c
|
||||
+ Specify the number of lines read between each call to @var{callback}.
|
||||
+ @end table
|
||||
+
|
||||
+ If @option{-C} is specified without @option{-c},
|
||||
+ the default quantum is 5000.
|
||||
+
|
||||
+ If not supplied with an explicit origin, @code{mapfile} will clear @var{array}
|
||||
+ before assigning to it.
|
||||
+
|
||||
+ @code{mapfile} returns successfully unless an invalid option or option
|
||||
+ argument is supplied, or @var{array} is invalid or unassignable.
|
||||
+
|
||||
@item printf
|
||||
@btindex printf
|
||||
@example
|
||||
***************
|
||||
*** 3476,3482 ****
|
||||
@item read
|
||||
@btindex read
|
||||
@example
|
||||
! read [-ers] [-a @var{aname}] [-d @var{delim}] [-n @var{nchars}] [-p @var{prompt}] [-t @var{timeout}] [-u @var{fd}] [@var{name} @dots{}]
|
||||
@end example
|
||||
One line is read from the standard input, or from the file descriptor
|
||||
@var{fd} supplied as an argument to the @option{-u} option, and the first word
|
||||
--- 3544,3550 ----
|
||||
@item read
|
||||
@btindex read
|
||||
@example
|
||||
! read [-ers] [-a @var{aname}] [-d @var{delim}] [-i @var{text}] [-n @var{nchars}] [-p @var{prompt}] [-t @var{timeout}] [-u @var{fd}] [@var{name} @dots{}]
|
||||
@end example
|
||||
One line is read from the standard input, or from the file descriptor
|
||||
@var{fd} supplied as an argument to the @option{-u} option, and the first word
|
||||
***************
|
||||
*** 3510,3515 ****
|
||||
--- 3578,3587 ----
|
||||
@item -e
|
||||
Readline (@pxref{Command Line Editing}) is used to obtain the line.
|
||||
|
||||
+ @item -i @var{text}
|
||||
+ If Readline is being used to read the line, @var{text} is placed into
|
||||
+ the editing buffer before editing begins.
|
||||
+
|
||||
@item -n @var{nchars}
|
||||
@code{read} returns after reading @var{nchars} characters rather than
|
||||
waiting for a complete line of input.
|
||||
***************
|
||||
*** 3581,3588 ****
|
||||
If the @option{-f} option is used, @code{type} does not attempt to find
|
||||
shell functions, as with the @code{command} builtin.
|
||||
|
||||
! The return status is zero if any of the @var{names} are found, non-zero
|
||||
! if none are found.
|
||||
|
||||
@item typeset
|
||||
@btindex typeset
|
||||
--- 3653,3660 ----
|
||||
If the @option{-f} option is used, @code{type} does not attempt to find
|
||||
shell functions, as with the @code{command} builtin.
|
||||
|
||||
! The return status is zero if all of the @var{names} are found, non-zero
|
||||
! if any are not found.
|
||||
|
||||
@item typeset
|
||||
@btindex typeset
|
||||
***************
|
||||
*** 3596,3602 ****
|
||||
@item ulimit
|
||||
@btindex ulimit
|
||||
@example
|
||||
! ulimit [-acdefilmnpqrstuvxSH] [@var{limit}]
|
||||
@end example
|
||||
@code{ulimit} provides control over the resources available to processes
|
||||
started by the shell, on systems that allow such control. If an
|
||||
--- 3668,3674 ----
|
||||
@item ulimit
|
||||
@btindex ulimit
|
||||
@example
|
||||
! ulimit [-abcdefilmnpqrstuvxHST] [@var{limit}]
|
||||
@end example
|
||||
@code{ulimit} provides control over the resources available to processes
|
||||
started by the shell, on systems that allow such control. If an
|
||||
***************
|
||||
*** 3611,3616 ****
|
||||
--- 3683,3691 ----
|
||||
@item -a
|
||||
All current limits are reported.
|
||||
|
||||
+ @item -b
|
||||
+ The maximum socket buffer size.
|
||||
+
|
||||
@item -c
|
||||
The maximum size of core files created.
|
||||
+ _rl_release_sigint ();
|
||||
}
|
||||
|
||||
***************
|
||||
*** 3659,3664 ****
|
||||
--- 3734,3742 ----
|
||||
@item -x
|
||||
The maximum number of file locks.
|
||||
|
||||
+ @item -T
|
||||
+ The maximum number of threads.
|
||||
+
|
||||
@end table
|
||||
|
||||
If @var{limit} is given, it is the new value of the specified resource;
|
||||
*** 1205,1209 ****
|
||||
{
|
||||
register char *ofd, *ols, *oe, *nfd, *nls, *ne;
|
||||
! int temp, lendiff, wsatend, od, nd, o_cpos;
|
||||
int current_invis_chars;
|
||||
int col_lendiff, col_temp;
|
||||
--- 1268,1272 ----
|
||||
{
|
||||
register char *ofd, *ols, *oe, *nfd, *nls, *ne;
|
||||
! int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
|
||||
int current_invis_chars;
|
||||
int col_lendiff, col_temp;
|
||||
***************
|
||||
*** 7049,7056 ****
|
||||
*** 1221,1225 ****
|
||||
temp = _rl_last_c_pos;
|
||||
else
|
||||
! temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
|
||||
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
|
||||
&& _rl_last_v_pos == current_line - 1)
|
||||
--- 1284,1288 ----
|
||||
temp = _rl_last_c_pos;
|
||||
else
|
||||
! temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
|
||||
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
|
||||
&& _rl_last_v_pos == current_line - 1)
|
||||
***************
|
||||
*** 1236,1241 ****
|
||||
character comsumes more than three columns, spaces will be
|
||||
inserted in the string buffer. */
|
||||
! if (_rl_wrapped_line[current_line] > 0)
|
||||
! _rl_clear_to_eol (_rl_wrapped_line[current_line]);
|
||||
|
||||
@item
|
||||
Bash provides a programmable word completion mechanism
|
||||
! (@pxref{Programmable Completion}), and two builtin commands,
|
||||
! @code{complete} and @code{compgen}, to manipulate it.
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
--- 1299,1304 ----
|
||||
character comsumes more than three columns, spaces will be
|
||||
inserted in the string buffer. */
|
||||
! if (current_line < line_state_visible->wbsize && line_state_visible->wrapped_line[current_line] > 0)
|
||||
! _rl_clear_to_eol (line_state_visible->wrapped_line[current_line]);
|
||||
|
||||
@item
|
||||
Bash has command history (@pxref{Bash History Facilities}) and the
|
||||
--- 7127,7135 ----
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
***************
|
||||
*** 1301,1305 ****
|
||||
only change is adding characters. */
|
||||
temp = (omax < nmax) ? omax : nmax;
|
||||
! if (memcmp (old, new, temp) == 0)
|
||||
{
|
||||
ofd = old + temp;
|
||||
--- 1364,1368 ----
|
||||
only change is adding characters. */
|
||||
temp = (omax < nmax) ? omax : nmax;
|
||||
! if (memcmp (old, new, temp) == 0) /* adding at the end */
|
||||
{
|
||||
ofd = old + temp;
|
||||
***************
|
||||
*** 1454,1457 ****
|
||||
--- 1517,1522 ----
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif
|
||||
+ if (modmark)
|
||||
+ _rl_output_some_chars ("*", 1);
|
||||
_rl_output_some_chars (local_prompt, lendiff);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
***************
|
||||
*** 1459,1467 ****
|
||||
/* We take wrap_offset into account here so we can pass correct
|
||||
information to _rl_move_cursor_relative. */
|
||||
! _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff) - wrap_offset;
|
||||
cpos_adjusted = 1;
|
||||
}
|
||||
else
|
||||
! _rl_last_c_pos = lendiff;
|
||||
}
|
||||
|
||||
@item
|
||||
Bash provides a programmable word completion mechanism
|
||||
! (@pxref{Programmable Completion}), and builtin commands
|
||||
! @code{complete}, @code{compgen}, and @code{compopt}, to
|
||||
! manipulate it.
|
||||
--- 1524,1532 ----
|
||||
/* We take wrap_offset into account here so we can pass correct
|
||||
information to _rl_move_cursor_relative. */
|
||||
! _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff) - wrap_offset + modmark;
|
||||
cpos_adjusted = 1;
|
||||
}
|
||||
else
|
||||
! _rl_last_c_pos = lendiff + modmark;
|
||||
}
|
||||
|
||||
@item
|
||||
Bash has command history (@pxref{Bash History Facilities}) and the
|
||||
***************
|
||||
*** 1477,1481 ****
|
||||
invisible characters in the prompt string. Let's see if setting this when
|
||||
we make sure we're at the end of the drawn prompt string works. */
|
||||
! if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 &&
|
||||
(_rl_last_c_pos > 0 || o_cpos > 0) &&
|
||||
_rl_last_c_pos == prompt_physical_chars)
|
||||
--- 1542,1546 ----
|
||||
invisible characters in the prompt string. Let's see if setting this when
|
||||
we make sure we're at the end of the drawn prompt string works. */
|
||||
! if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 &&
|
||||
(_rl_last_c_pos > 0 || o_cpos > 0) &&
|
||||
_rl_last_c_pos == prompt_physical_chars)
|
||||
***************
|
||||
*** 1587,1599 ****
|
||||
{
|
||||
_rl_output_some_chars (nfd + lendiff, temp - lendiff);
|
||||
- #if 1
|
||||
/* XXX -- this bears closer inspection. Fixes a redisplay bug
|
||||
reported against bash-3.0-alpha by Andreas Schwab involving
|
||||
multibyte characters and prompt strings with invisible
|
||||
characters, but was previously disabled. */
|
||||
! _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
|
||||
! #else
|
||||
! _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
|
||||
! #endif
|
||||
}
|
||||
}
|
||||
--- 1652,1664 ----
|
||||
{
|
||||
_rl_output_some_chars (nfd + lendiff, temp - lendiff);
|
||||
/* XXX -- this bears closer inspection. Fixes a redisplay bug
|
||||
reported against bash-3.0-alpha by Andreas Schwab involving
|
||||
multibyte characters and prompt strings with invisible
|
||||
characters, but was previously disabled. */
|
||||
! if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
! twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
|
||||
! else
|
||||
! twidth = temp - lendiff;
|
||||
! _rl_last_c_pos += twidth;
|
||||
}
|
||||
}
|
||||
***************
|
||||
*** 1635,1640 ****
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
! _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
|
||||
! if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
|
||||
{
|
||||
_rl_last_c_pos -= wrap_offset;
|
||||
--- 1700,1705 ----
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
! _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
|
||||
! if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
|
||||
{
|
||||
_rl_last_c_pos -= wrap_offset;
|
||||
***************
|
||||
*** 1642,1647 ****
|
||||
}
|
||||
}
|
||||
! else
|
||||
! _rl_last_c_pos += temp;
|
||||
}
|
||||
}
|
||||
--- 1707,1712 ----
|
||||
}
|
||||
}
|
||||
! else
|
||||
! _rl_last_c_pos += temp;
|
||||
}
|
||||
}
|
||||
***************
|
||||
*** 1789,1793 ****
|
||||
int cpos, dpos; /* current and desired cursor positions */
|
||||
|
||||
! woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
|
||||
cpos = _rl_last_c_pos;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
--- 1854,1858 ----
|
||||
int cpos, dpos; /* current and desired cursor positions */
|
||||
|
||||
! woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
|
||||
cpos = _rl_last_c_pos;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
***************
|
||||
*** 1803,1807 ****
|
||||
prompt string, since they're both buffer indices and DPOS is a
|
||||
desired display position. */
|
||||
! if (new > prompt_last_invisible) /* XXX - don't use woff here */
|
||||
{
|
||||
dpos -= woff;
|
||||
--- 1868,1876 ----
|
||||
prompt string, since they're both buffer indices and DPOS is a
|
||||
desired display position. */
|
||||
! if ((new > prompt_last_invisible) || /* XXX - don't use woff here */
|
||||
! (prompt_physical_chars > _rl_screenwidth &&
|
||||
! _rl_last_v_pos == prompt_last_screen_line &&
|
||||
! wrap_offset != woff &&
|
||||
! new > (prompt_last_invisible-_rl_screenwidth-wrap_offset)))
|
||||
{
|
||||
dpos -= woff;
|
||||
***************
|
||||
*** 2216,2220 ****
|
||||
if (MB_CUR_MAX == 1 || rl_byte_oriented)
|
||||
if (count != col)
|
||||
! fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col);
|
||||
|
||||
/* If IC is defined, then we do not have to "enter" insert mode. */
|
||||
--- 2285,2289 ----
|
||||
if (MB_CUR_MAX == 1 || rl_byte_oriented)
|
||||
if (count != col)
|
||||
! _rl_ttymsg ("debug: insert_some_chars: count (%d) != col (%d)", count, col);
|
||||
|
||||
/* If IC is defined, then we do not have to "enter" insert mode. */
|
||||
***************
|
||||
*** 2357,2364 ****
|
||||
char *t;
|
||||
|
||||
! /* Clear the current line and put the cursor at column 0. Make sure
|
||||
! the right thing happens if we have wrapped to a new screen line. */
|
||||
if (_rl_term_cr)
|
||||
{
|
||||
#if defined (__MSDOS__)
|
||||
putc ('\r', rl_outstream);
|
||||
--- 2426,2437 ----
|
||||
char *t;
|
||||
|
||||
! /* Clear the last line (assuming that the screen size change will result in
|
||||
! either more or fewer characters on that line only) and put the cursor at
|
||||
! column 0. Make sure the right thing happens if we have wrapped to a new
|
||||
! screen line. */
|
||||
if (_rl_term_cr)
|
||||
{
|
||||
+ _rl_move_vert (_rl_vis_botlin);
|
||||
+
|
||||
#if defined (__MSDOS__)
|
||||
putc ('\r', rl_outstream);
|
||||
***************
|
||||
*** 2396,2400 ****
|
||||
_rl_clean_up_for_exit ()
|
||||
{
|
||||
! if (readline_echoing_p)
|
||||
{
|
||||
_rl_move_vert (_rl_vis_botlin);
|
||||
--- 2469,2473 ----
|
||||
_rl_clean_up_for_exit ()
|
||||
{
|
||||
! if (_rl_echoing_p)
|
||||
{
|
||||
_rl_move_vert (_rl_vis_botlin);
|
||||
***************
|
||||
*** 2452,2456 ****
|
||||
--- 2525,2532 ----
|
||||
return 0;
|
||||
if (MB_CUR_MAX == 1 || rl_byte_oriented)
|
||||
+ {
|
||||
+ _rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1");
|
||||
return (end - start);
|
||||
+ }
|
||||
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
|
||||
@@ -905,6 +905,10 @@ command (see
|
||||
below).
|
||||
The file descriptors can be utilized as arguments to shell commands
|
||||
and redirections using standard word expansions.
|
||||
The process id of the shell spawned to execute the coprocess is
|
||||
available as the value of the variable \fINAME\fP_PID.
|
||||
The \fBwait\fP
|
||||
builtin command may be used to wait for the coprocess to terminate.
|
||||
.PP
|
||||
The return status of a coprocess is the exit status of \fIcommand\fP.
|
||||
.SS Shell Function Definitions
|
||||
|
||||
+3
-1
@@ -888,7 +888,7 @@ The format for a coprocess is:
|
||||
This creates a coprocess named \fINAME\fP.
|
||||
If \fINAME\fP is not supplied, the default name is \fICOPROC\fP.
|
||||
When the coproc is executed, the shell creates an array variable (see
|
||||
.B arrays
|
||||
.B Arrays
|
||||
below) named \fINAME\fP in the context of the executing shell.
|
||||
The standard output of
|
||||
.I command
|
||||
@@ -905,6 +905,8 @@ command (see
|
||||
below).
|
||||
The file descriptors can be utilized as arguments to shell commands
|
||||
and redirections using standard word expansions.
|
||||
The process id of the shell spawned to execute the coprocess is
|
||||
available as the value of the variable \fINAME\fP_PID.
|
||||
.PP
|
||||
The return status of a coprocess is the exit status of \fIcommand\fP.
|
||||
.SS Shell Function Definitions
|
||||
|
||||
@@ -1108,6 +1108,11 @@ command (@pxref{Redirections}).
|
||||
The file descriptors can be utilized as arguments to shell commands
|
||||
and redirections using standard word expansions.
|
||||
|
||||
The process id of the shell spawned to execute the coprocess is
|
||||
available as the value of the variable @var{NAME}_PID.
|
||||
The @code{wait}
|
||||
builtin command may be used to wait for the coprocess to terminate.
|
||||
|
||||
The return status of a coprocess is the exit status of @var{command}.
|
||||
|
||||
@node Shell Functions
|
||||
|
||||
@@ -1108,6 +1108,9 @@ command (@pxref{Redirections}).
|
||||
The file descriptors can be utilized as arguments to shell commands
|
||||
and redirections using standard word expansions.
|
||||
|
||||
The process id of the shell spawned to execute the coprocess is
|
||||
available as the value of the variable @var{NAME}_PID.
|
||||
|
||||
The return status of a coprocess is the exit status of @var{command}.
|
||||
|
||||
@node Shell Functions
|
||||
|
||||
@@ -65,9 +65,10 @@ reader_loop ()
|
||||
int our_indirection_level;
|
||||
COMMAND * volatile current_command;
|
||||
|
||||
current_command = (COMMAND *)NULL;
|
||||
USE_VAR(current_command);
|
||||
|
||||
current_command = (COMMAND *)NULL;
|
||||
|
||||
our_indirection_level = ++indirection_level;
|
||||
|
||||
while (EOF_Reached == 0)
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
/* eval.c -- reading and evaluating commands. */
|
||||
|
||||
/* Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
Bash is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "bashansi.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bashintl.h"
|
||||
|
||||
#include "shell.h"
|
||||
#include "flags.h"
|
||||
#include "trap.h"
|
||||
|
||||
#include "builtins/common.h"
|
||||
|
||||
#include "input.h"
|
||||
#include "execute_cmd.h"
|
||||
|
||||
#if defined (HISTORY)
|
||||
# include "bashhist.h"
|
||||
#endif
|
||||
|
||||
extern int EOF_reached;
|
||||
extern int indirection_level;
|
||||
extern int posixly_correct;
|
||||
extern int subshell_environment, running_under_emacs;
|
||||
extern int last_command_exit_value, stdin_redir;
|
||||
extern int need_here_doc;
|
||||
extern int current_command_number, current_command_line_count, line_number;
|
||||
extern int expand_aliases;
|
||||
|
||||
static void send_pwd_to_eterm __P((void));
|
||||
static sighandler alrm_catcher __P((int));
|
||||
|
||||
/* Read and execute commands until EOF is reached. This assumes that
|
||||
the input source has already been initialized. */
|
||||
int
|
||||
reader_loop ()
|
||||
{
|
||||
int our_indirection_level;
|
||||
COMMAND * volatile current_command;
|
||||
|
||||
current_command = (COMMAND *)NULL;
|
||||
USE_VAR(current_command);
|
||||
|
||||
our_indirection_level = ++indirection_level;
|
||||
|
||||
while (EOF_Reached == 0)
|
||||
{
|
||||
int code;
|
||||
|
||||
code = setjmp (top_level);
|
||||
|
||||
#if defined (PROCESS_SUBSTITUTION)
|
||||
unlink_fifo_list ();
|
||||
#endif /* PROCESS_SUBSTITUTION */
|
||||
|
||||
if (interactive_shell && signal_is_ignored (SIGINT) == 0)
|
||||
set_signal_handler (SIGINT, sigint_sighandler);
|
||||
|
||||
if (code != NOT_JUMPED)
|
||||
{
|
||||
indirection_level = our_indirection_level;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
/* Some kind of throw to top_level has occured. */
|
||||
case FORCE_EOF:
|
||||
case ERREXIT:
|
||||
case EXITPROG:
|
||||
current_command = (COMMAND *)NULL;
|
||||
if (exit_immediately_on_error)
|
||||
variable_context = 0; /* not in a function */
|
||||
EOF_Reached = EOF;
|
||||
goto exec_done;
|
||||
|
||||
case DISCARD:
|
||||
/* Make sure the exit status is reset to a non-zero value, but
|
||||
leave existing non-zero values (e.g., > 128 on signal)
|
||||
alone. */
|
||||
if (last_command_exit_value == 0)
|
||||
last_command_exit_value = EXECUTION_FAILURE;
|
||||
if (subshell_environment)
|
||||
{
|
||||
current_command = (COMMAND *)NULL;
|
||||
EOF_Reached = EOF;
|
||||
goto exec_done;
|
||||
}
|
||||
/* Obstack free command elements, etc. */
|
||||
if (current_command)
|
||||
{
|
||||
dispose_command (current_command);
|
||||
current_command = (COMMAND *)NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
command_error ("reader_loop", CMDERR_BADJUMP, code, 0);
|
||||
}
|
||||
}
|
||||
|
||||
executing = 0;
|
||||
if (temporary_env)
|
||||
dispose_used_env_vars ();
|
||||
|
||||
#if (defined (ultrix) && defined (mips)) || defined (C_ALLOCA)
|
||||
/* Attempt to reclaim memory allocated with alloca (). */
|
||||
(void) alloca (0);
|
||||
#endif
|
||||
|
||||
if (read_command () == 0)
|
||||
{
|
||||
if (interactive_shell == 0 && read_but_dont_execute)
|
||||
{
|
||||
last_command_exit_value = EXECUTION_SUCCESS;
|
||||
dispose_command (global_command);
|
||||
global_command = (COMMAND *)NULL;
|
||||
}
|
||||
else if (current_command = global_command)
|
||||
{
|
||||
global_command = (COMMAND *)NULL;
|
||||
current_command_number++;
|
||||
|
||||
executing = 1;
|
||||
stdin_redir = 0;
|
||||
execute_command (current_command);
|
||||
|
||||
exec_done:
|
||||
QUIT;
|
||||
|
||||
if (current_command)
|
||||
{
|
||||
dispose_command (current_command);
|
||||
current_command = (COMMAND *)NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Parse error, maybe discard rest of stream if not interactive. */
|
||||
if (interactive == 0)
|
||||
EOF_Reached = EOF;
|
||||
}
|
||||
if (just_one_command)
|
||||
EOF_Reached = EOF;
|
||||
}
|
||||
indirection_level--;
|
||||
return (last_command_exit_value);
|
||||
}
|
||||
|
||||
static sighandler
|
||||
alrm_catcher(i)
|
||||
int i;
|
||||
{
|
||||
printf (_("\007timed out waiting for input: auto-logout\n"));
|
||||
fflush (stdout);
|
||||
bash_logout (); /* run ~/.bash_logout if this is a login shell */
|
||||
jump_to_top_level (EXITPROG);
|
||||
SIGRETURN (0);
|
||||
}
|
||||
|
||||
/* Send an escape sequence to emacs term mode to tell it the
|
||||
current working directory. */
|
||||
static void
|
||||
send_pwd_to_eterm ()
|
||||
{
|
||||
char *pwd;
|
||||
|
||||
pwd = get_string_value ("PWD");
|
||||
if (pwd == 0)
|
||||
pwd = get_working_directory ("eterm");
|
||||
fprintf (stderr, "\032/%s\n", pwd);
|
||||
}
|
||||
|
||||
/* Call the YACC-generated parser and return the status of the parse.
|
||||
Input is read from the current input stream (bash_input). yyparse
|
||||
leaves the parsed command in the global variable GLOBAL_COMMAND.
|
||||
This is where PROMPT_COMMAND is executed. */
|
||||
int
|
||||
parse_command ()
|
||||
{
|
||||
int r;
|
||||
char *command_to_execute;
|
||||
|
||||
need_here_doc = 0;
|
||||
run_pending_traps ();
|
||||
|
||||
/* Allow the execution of a random command just before the printing
|
||||
of each primary prompt. If the shell variable PROMPT_COMMAND
|
||||
is set then the value of it is the command to execute. */
|
||||
if (interactive && bash_input.type != st_string)
|
||||
{
|
||||
command_to_execute = get_string_value ("PROMPT_COMMAND");
|
||||
if (command_to_execute)
|
||||
execute_variable_command (command_to_execute, "PROMPT_COMMAND");
|
||||
|
||||
if (running_under_emacs == 2)
|
||||
send_pwd_to_eterm (); /* Yuck */
|
||||
}
|
||||
|
||||
current_command_line_count = 0;
|
||||
r = yyparse ();
|
||||
|
||||
if (need_here_doc)
|
||||
gather_here_documents ();
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
/* Read and parse a command, returning the status of the parse. The command
|
||||
is left in the globval variable GLOBAL_COMMAND for use by reader_loop.
|
||||
This is where the shell timeout code is executed. */
|
||||
int
|
||||
read_command ()
|
||||
{
|
||||
SHELL_VAR *tmout_var;
|
||||
int tmout_len, result;
|
||||
SigHandler *old_alrm;
|
||||
|
||||
set_current_prompt_level (1);
|
||||
global_command = (COMMAND *)NULL;
|
||||
|
||||
/* Only do timeouts if interactive. */
|
||||
tmout_var = (SHELL_VAR *)NULL;
|
||||
tmout_len = 0;
|
||||
old_alrm = (SigHandler *)NULL;
|
||||
|
||||
if (interactive)
|
||||
{
|
||||
tmout_var = find_variable ("TMOUT");
|
||||
|
||||
if (tmout_var && var_isset (tmout_var))
|
||||
{
|
||||
tmout_len = atoi (value_cell (tmout_var));
|
||||
if (tmout_len > 0)
|
||||
{
|
||||
old_alrm = set_signal_handler (SIGALRM, alrm_catcher);
|
||||
alarm (tmout_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QUIT;
|
||||
|
||||
current_command_line_count = 0;
|
||||
result = parse_command ();
|
||||
|
||||
if (interactive && tmout_var && (tmout_len > 0))
|
||||
{
|
||||
alarm(0);
|
||||
set_signal_handler (SIGALRM, old_alrm);
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
+8
-1
@@ -1555,8 +1555,11 @@ coproc_pidchk (pid)
|
||||
|
||||
cp = getcoprocbypid (pid);
|
||||
if (cp)
|
||||
{
|
||||
itrace("coproc_pidchk: pid %d has died", pid);
|
||||
coproc_dispose (cp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
coproc_setvars (cp)
|
||||
@@ -1649,10 +1652,14 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close)
|
||||
Coproc *cp;
|
||||
char *tcmd;
|
||||
|
||||
if (sh_coproc.c_pid != -1)
|
||||
if (sh_coproc.c_pid != NO_PID)
|
||||
{
|
||||
#if 0
|
||||
internal_error ("execute_coproc: coproc [%d:%s] already exists", sh_coproc.c_pid, sh_coproc.c_name);
|
||||
return (last_command_exit_value = EXECUTION_FAILURE);
|
||||
#else
|
||||
internal_warning ("execute_coproc: coproc [%d:%s] still exists", sh_coproc.c_pid, sh_coproc.c_name);
|
||||
#endif
|
||||
}
|
||||
coproc_init (&sh_coproc);
|
||||
|
||||
|
||||
+7
-1
@@ -1649,10 +1649,14 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close)
|
||||
Coproc *cp;
|
||||
char *tcmd;
|
||||
|
||||
if (sh_coproc.c_pid != -1)
|
||||
if (sh_coproc.c_pid != NO_PID)
|
||||
{
|
||||
#if 0
|
||||
internal_error ("execute_coproc: coproc [%d:%s] already exists", sh_coproc.c_pid, sh_coproc.c_name);
|
||||
return (last_command_exit_value = EXECUTION_FAILURE);
|
||||
#else
|
||||
internal_warning ("execute_coproc: coproc [%d:%s] still exists", sh_coproc.c_pid, sh_coproc.c_name);
|
||||
#endif
|
||||
}
|
||||
coproc_init (&sh_coproc);
|
||||
|
||||
@@ -1683,7 +1687,9 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close)
|
||||
|
||||
coproc_setvars (cp);
|
||||
|
||||
#if defined (DEBUG)
|
||||
itrace ("execute_coproc: [%d] %s", coproc_pid, the_printed_command);
|
||||
#endif
|
||||
|
||||
close_pipes (pipe_in, pipe_out);
|
||||
#if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD)
|
||||
|
||||
@@ -265,6 +265,7 @@ static void set_current_job __P((int));
|
||||
static void reset_current __P((void));
|
||||
static void set_job_running __P((int));
|
||||
static void setjstatus __P((int));
|
||||
static int maybe_give_terminal_to __P((pid_t, pid_t, int));
|
||||
static void mark_all_jobs_as_dead __P((void));
|
||||
static void mark_dead_jobs_as_notified __P((int));
|
||||
static void restore_sigint_handler __P((void));
|
||||
@@ -636,7 +637,7 @@ stop_pipeline (async, deferred)
|
||||
*
|
||||
*/
|
||||
if (job_control && newjob->pgrp && (subshell_environment&SUBSHELL_ASYNC) == 0)
|
||||
give_terminal_to (newjob->pgrp, 0);
|
||||
maybe_give_terminal_to (shell_pgrp, newjob->pgrp, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3832,6 +3833,32 @@ give_terminal_to (pgrp, force)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Give terminal to NPGRP iff it's currently owned by OPGRP. FLAGS are the
|
||||
flags to pass to give_terminal_to(). */
|
||||
static int
|
||||
maybe_give_terminal_to (opgrp, npgrp, flags)
|
||||
pid_t opgrp, npgrp;
|
||||
int flags;
|
||||
{
|
||||
int tpgrp;
|
||||
|
||||
tpgrp = tcgetpgrp (shell_tty);
|
||||
if (tpgrp == npgrp)
|
||||
{
|
||||
terminal_pgrp = npgrp;
|
||||
return 0;
|
||||
}
|
||||
else if (tpgrp != opgrp)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
internal_warning ("maybe_give_terminal_to: terminal pgrp == %d shell pgrp = %d", tpgrp, opgrp);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return (give_terminal_to (npgrp, flags));
|
||||
}
|
||||
|
||||
/* Clear out any jobs in the job array. This is intended to be used by
|
||||
children of the shell, who should not have any job structures as baggage
|
||||
when they start executing (forking subshells for parenthesized execution
|
||||
|
||||
+4165
File diff suppressed because it is too large
Load Diff
+51
-60
@@ -1,65 +1,56 @@
|
||||
*** ../bash-20070510/jobs.c Thu Mar 8 16:05:50 2007
|
||||
--- jobs.c Fri May 18 11:40:14 2007
|
||||
*** jobs.c.20080704 2008-07-10 15:14:13.000000000 -0400
|
||||
--- jobs.c 2008-07-10 15:17:59.000000000 -0400
|
||||
***************
|
||||
*** 784,792 ****
|
||||
{
|
||||
old = js.j_firstj++;
|
||||
while (js.j_firstj != old)
|
||||
{
|
||||
if (js.j_firstj >= js.j_jobslots)
|
||||
js.j_firstj = 0;
|
||||
! if (jobs[js.j_firstj])
|
||||
break;
|
||||
js.j_firstj++;
|
||||
--- 784,794 ----
|
||||
{
|
||||
old = js.j_firstj++;
|
||||
+ if (old >= js.j_jobslots)
|
||||
+ old = js.j_jobslots - 1;
|
||||
while (js.j_firstj != old)
|
||||
{
|
||||
if (js.j_firstj >= js.j_jobslots)
|
||||
js.j_firstj = 0;
|
||||
! if (jobs[js.j_firstj] || js.j_firstj == old) /* needed if old == 0 */
|
||||
break;
|
||||
js.j_firstj++;
|
||||
*** 266,269 ****
|
||||
--- 266,270 ----
|
||||
static void set_job_running __P((int));
|
||||
static void setjstatus __P((int));
|
||||
+ static int maybe_give_terminal_to __P((pid_t, pid_t, int));
|
||||
static void mark_all_jobs_as_dead __P((void));
|
||||
static void mark_dead_jobs_as_notified __P((int));
|
||||
***************
|
||||
*** 798,806 ****
|
||||
{
|
||||
old = js.j_lastj--;
|
||||
while (js.j_lastj != old)
|
||||
{
|
||||
if (js.j_lastj < 0)
|
||||
js.j_lastj = js.j_jobslots - 1;
|
||||
! if (jobs[js.j_lastj])
|
||||
break;
|
||||
js.j_lastj--;
|
||||
--- 800,810 ----
|
||||
{
|
||||
old = js.j_lastj--;
|
||||
+ if (old < 0)
|
||||
+ old = 0;
|
||||
while (js.j_lastj != old)
|
||||
{
|
||||
if (js.j_lastj < 0)
|
||||
js.j_lastj = js.j_jobslots - 1;
|
||||
! if (jobs[js.j_lastj] || js.j_lastj == old) /* needed if old == js.j_jobslots */
|
||||
break;
|
||||
js.j_lastj--;
|
||||
*** 637,641 ****
|
||||
*/
|
||||
if (job_control && newjob->pgrp && (subshell_environment&SUBSHELL_ASYNC) == 0)
|
||||
! give_terminal_to (newjob->pgrp, 0);
|
||||
}
|
||||
}
|
||||
--- 638,642 ----
|
||||
*/
|
||||
if (job_control && newjob->pgrp && (subshell_environment&SUBSHELL_ASYNC) == 0)
|
||||
! maybe_give_terminal_to (shell_pgrp, newjob->pgrp, 0);
|
||||
}
|
||||
}
|
||||
***************
|
||||
*** 964,968 ****
|
||||
realloc_jobs_list ();
|
||||
|
||||
! return (js.j_lastj ? js.j_lastj + 1 : 0);
|
||||
}
|
||||
|
||||
--- 975,983 ----
|
||||
realloc_jobs_list ();
|
||||
|
||||
! #ifdef DEBUG
|
||||
! itrace("compact_jobs_list: returning %d", (js.j_lastj || jobs[js.j_lastj]) ? js.j_lastj + 1 : 0);
|
||||
! #endif
|
||||
!
|
||||
! return ((js.j_lastj || jobs[js.j_lastj]) ? js.j_lastj + 1 : 0);
|
||||
*** 3833,3836 ****
|
||||
--- 3834,3863 ----
|
||||
}
|
||||
|
||||
+ /* Give terminal to NPGRP iff it's currently owned by OPGRP. FLAGS are the
|
||||
+ flags to pass to give_terminal_to(). */
|
||||
+ static int
|
||||
+ maybe_give_terminal_to (opgrp, npgrp, flags)
|
||||
+ pid_t opgrp, npgrp;
|
||||
+ int flags;
|
||||
+ {
|
||||
+ int tpgrp;
|
||||
+
|
||||
+ tpgrp = tcgetpgrp (shell_tty);
|
||||
+ if (tpgrp == npgrp)
|
||||
+ {
|
||||
+ terminal_pgrp = npgrp;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ else if (tpgrp != opgrp)
|
||||
+ {
|
||||
+ #if defined (DEBUG)
|
||||
+ internal_warning ("maybe_give_terminal_to: terminal pgrp == %d shell pgrp = %d", tpgrp, opgrp);
|
||||
+ #endif
|
||||
+ return -1;
|
||||
+ }
|
||||
+ else
|
||||
+ return (give_terminal_to (npgrp, flags));
|
||||
+ }
|
||||
+
|
||||
/* Clear out any jobs in the job array. This is intended to be used by
|
||||
children of the shell, who should not have any job structures as baggage
|
||||
|
||||
@@ -265,6 +265,7 @@ static void set_current_job __P((int));
|
||||
static void reset_current __P((void));
|
||||
static void set_job_running __P((int));
|
||||
static void setjstatus __P((int));
|
||||
static int maybe_give_terminal_to __P((pid_t, pid_t, int));
|
||||
static void mark_all_jobs_as_dead __P((void));
|
||||
static void mark_dead_jobs_as_notified __P((int));
|
||||
static void restore_sigint_handler __P((void));
|
||||
@@ -636,7 +637,7 @@ stop_pipeline (async, deferred)
|
||||
*
|
||||
*/
|
||||
if (job_control && newjob->pgrp && (subshell_environment&SUBSHELL_ASYNC) == 0)
|
||||
give_terminal_to (newjob->pgrp, 0);
|
||||
maybe_give_terminal_to (shell_pgrp, newjob->pgrp, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3057,6 +3058,8 @@ waitchld (wpid, block)
|
||||
break;
|
||||
}
|
||||
|
||||
itrace("waitchld: waitpid returns %d", pid);
|
||||
|
||||
/* If waitpid returns 0, there are running children. If it returns -1,
|
||||
the only other error POSIX says it can return is EINTR. */
|
||||
CHECK_TERMSIG;
|
||||
@@ -3074,6 +3077,10 @@ waitchld (wpid, block)
|
||||
/* Locate our PROCESS for this pid. */
|
||||
child = find_process (pid, 1, &job); /* want living procs only */
|
||||
|
||||
#if defined (COPROCESS_SUPPORT)
|
||||
coproc_pidchk (pid);
|
||||
#endif
|
||||
|
||||
/* It is not an error to have a child terminate that we did
|
||||
not have a record of. This child could have been part of
|
||||
a pipeline in backquote substitution. Even so, I'm not
|
||||
@@ -3828,6 +3835,32 @@ give_terminal_to (pgrp, force)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Give terminal to NPGRP iff it's currently owned by OPGRP. FLAGS are the
|
||||
flags to pass to give_terminal_to(). */
|
||||
static int
|
||||
maybe_give_terminal_to (opgrp, npgrp, flags)
|
||||
pid_t opgrp, npgrp;
|
||||
int flags;
|
||||
{
|
||||
int tpgrp;
|
||||
|
||||
tpgrp = tcgetpgrp (shell_tty);
|
||||
if (tpgrp == npgrp)
|
||||
{
|
||||
terminal_pgrp = npgrp;
|
||||
return 0;
|
||||
}
|
||||
else if (tpgrp != opgrp)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
internal_warning ("maybe_give_terminal_to: terminal pgrp == %d shell pgrp = %d", tpgrp, opgrp);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return (give_terminal_to (npgrp, flags));
|
||||
}
|
||||
|
||||
/* Clear out any jobs in the job array. This is intended to be used by
|
||||
children of the shell, who should not have any job structures as baggage
|
||||
when they start executing (forking subshells for parenthesized execution
|
||||
|
||||
@@ -519,6 +519,7 @@ it_init_joblist (itp, jstate)
|
||||
JOB *j;
|
||||
JOB_STATE ws; /* wanted state */
|
||||
|
||||
ws = -1;
|
||||
if (jstate == 0)
|
||||
ws = JRUNNING;
|
||||
else if (jstate == 1)
|
||||
|
||||
+12
-5
@@ -164,7 +164,8 @@ ITEMLIST it_stopped = { LIST_DYNAMIC, it_init_stopped, (STRINGLIST *)0 };
|
||||
ITEMLIST it_users = { LIST_DYNAMIC }; /* unused */
|
||||
ITEMLIST it_variables = { LIST_DYNAMIC, it_init_variables, (STRINGLIST *)0 };
|
||||
|
||||
COMPSPEC *curcs;
|
||||
COMPSPEC *pcomp_curcs;
|
||||
const char *pcomp_curcmd;
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Debugging code */
|
||||
@@ -1380,7 +1381,7 @@ pcomp_set_compspec_options (cs, flags, set_or_unset)
|
||||
COMPSPEC *cs;
|
||||
int flags, set_or_unset;
|
||||
{
|
||||
if (cs == 0 && ((cs = curcs) == 0))
|
||||
if (cs == 0 && ((cs = pcomp_curcs) == 0))
|
||||
return;
|
||||
if (set_or_unset)
|
||||
cs->options |= flags;
|
||||
@@ -1400,6 +1401,7 @@ programmable_completions (cmd, word, start, end, foundp)
|
||||
COMPSPEC *cs, *oldcs;
|
||||
STRINGLIST *ret;
|
||||
char **rmatches, *t;
|
||||
const char *oldcmd;
|
||||
|
||||
/* We look at the basename of CMD if the full command does not have
|
||||
an associated COMPSPEC. */
|
||||
@@ -1419,8 +1421,11 @@ programmable_completions (cmd, word, start, end, foundp)
|
||||
|
||||
cs = compspec_copy (cs);
|
||||
|
||||
oldcs = curcs;
|
||||
curcs = cs;
|
||||
oldcs = pcomp_curcs;
|
||||
oldcmd = pcomp_curcmd;
|
||||
|
||||
pcomp_curcs = cs;
|
||||
pcomp_curcmd = cmd;
|
||||
|
||||
/* Signal the caller that we found a COMPSPEC for this command, and pass
|
||||
back any meta-options associated with the compspec. */
|
||||
@@ -1429,7 +1434,9 @@ programmable_completions (cmd, word, start, end, foundp)
|
||||
|
||||
ret = gen_compspec_completions (cs, cmd, word, start, end);
|
||||
|
||||
curcs = oldcs;
|
||||
pcomp_curcs = oldcs;
|
||||
pcomp_curcmd = oldcmd;
|
||||
|
||||
compspec_dispose (cs);
|
||||
|
||||
if (ret)
|
||||
|
||||
+119
-27
@@ -78,6 +78,10 @@ static void command_print_word_list __P((WORD_LIST *, char *));
|
||||
static void print_case_clauses __P((PATTERN_LIST *));
|
||||
static void print_redirection_list __P((REDIRECT *));
|
||||
static void print_redirection __P((REDIRECT *));
|
||||
static void print_heredoc_header __P((REDIRECT *));
|
||||
static void print_heredoc_body __P((REDIRECT *));
|
||||
static void print_heredocs __P((REDIRECT *));
|
||||
static void print_deferred_heredocs __P((const char *));
|
||||
|
||||
static void print_for_command __P((FOR_COM *));
|
||||
#if defined (ARITH_FOR_COMMAND)
|
||||
@@ -108,6 +112,8 @@ int command_string_index = 0;
|
||||
static int inside_function_def;
|
||||
static int skip_this_indent;
|
||||
static int was_heredoc;
|
||||
static int printing_connection;
|
||||
static REDIRECT *deferred_heredocs;
|
||||
|
||||
/* The depth of the group commands that we are currently printing. This
|
||||
includes the group command that is a function body. */
|
||||
@@ -134,6 +140,7 @@ make_command_string (command)
|
||||
COMMAND *command;
|
||||
{
|
||||
command_string_index = was_heredoc = 0;
|
||||
deferred_heredocs = 0;
|
||||
make_command_string_internal (command);
|
||||
return (the_printed_command);
|
||||
}
|
||||
@@ -143,6 +150,8 @@ static void
|
||||
make_command_string_internal (command)
|
||||
COMMAND *command;
|
||||
{
|
||||
char s[3];
|
||||
|
||||
if (command == 0)
|
||||
cprintf ("");
|
||||
else
|
||||
@@ -215,6 +224,7 @@ make_command_string_internal (command)
|
||||
case cm_connection:
|
||||
|
||||
skip_this_indent++;
|
||||
printing_connection++;
|
||||
make_command_string_internal (command->value.Connection->first);
|
||||
|
||||
switch (command->value.Connection->connector)
|
||||
@@ -223,7 +233,13 @@ make_command_string_internal (command)
|
||||
case '|':
|
||||
{
|
||||
char c = command->value.Connection->connector;
|
||||
cprintf (" %c", c);
|
||||
|
||||
s[0] = ' ';
|
||||
s[1] = c;
|
||||
s[2] = '\0';
|
||||
|
||||
print_deferred_heredocs (s);
|
||||
|
||||
if (c != '&' || command->value.Connection->second)
|
||||
{
|
||||
cprintf (" ");
|
||||
@@ -233,22 +249,29 @@ make_command_string_internal (command)
|
||||
break;
|
||||
|
||||
case AND_AND:
|
||||
cprintf (" && ");
|
||||
print_deferred_heredocs (" && ");
|
||||
if (command->value.Connection->second)
|
||||
skip_this_indent++;
|
||||
break;
|
||||
|
||||
case OR_OR:
|
||||
cprintf (" || ");
|
||||
print_deferred_heredocs (" || ");
|
||||
if (command->value.Connection->second)
|
||||
skip_this_indent++;
|
||||
break;
|
||||
|
||||
case ';':
|
||||
#if 0
|
||||
if (was_heredoc == 0)
|
||||
cprintf (";");
|
||||
else
|
||||
was_heredoc = 0;
|
||||
#else
|
||||
if (deferred_heredocs == 0)
|
||||
cprintf (";");
|
||||
else
|
||||
print_deferred_heredocs (";");
|
||||
#endif
|
||||
|
||||
if (inside_function_def)
|
||||
cprintf ("\n");
|
||||
@@ -267,6 +290,7 @@ make_command_string_internal (command)
|
||||
}
|
||||
|
||||
make_command_string_internal (command->value.Connection->second);
|
||||
printing_connection--;
|
||||
break;
|
||||
|
||||
case cm_function_def:
|
||||
@@ -817,6 +841,56 @@ print_simple_command (simple_command)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_heredocs (heredocs)
|
||||
REDIRECT *heredocs;
|
||||
{
|
||||
REDIRECT *hdtail;
|
||||
|
||||
cprintf (" ");
|
||||
for (hdtail = heredocs; hdtail; hdtail = hdtail->next)
|
||||
{
|
||||
print_redirection (hdtail);
|
||||
cprintf ("\n");
|
||||
}
|
||||
was_heredoc = 1;
|
||||
}
|
||||
|
||||
/* Print heredocs that are attached to the command before the connector
|
||||
represented by CSTRING. The parsing semantics require us to print the
|
||||
here-doc delimiters, then the connector (CSTRING), then the here-doc
|
||||
bodies. We don't print the connector if it's a `;', but we use it to
|
||||
note not to print an extra space after the last heredoc body and
|
||||
newline. */
|
||||
static void
|
||||
print_deferred_heredocs (cstring)
|
||||
const char *cstring;
|
||||
{
|
||||
REDIRECT *hdtail;
|
||||
|
||||
for (hdtail = deferred_heredocs; hdtail; hdtail = hdtail->next)
|
||||
{
|
||||
cprintf (" ");
|
||||
print_heredoc_header (hdtail);
|
||||
}
|
||||
if (cstring[0] != ';' || cstring[1])
|
||||
cprintf ("%s", cstring);
|
||||
if (deferred_heredocs)
|
||||
cprintf ("\n");
|
||||
for (hdtail = deferred_heredocs; hdtail; hdtail = hdtail->next)
|
||||
{
|
||||
print_heredoc_body (hdtail);
|
||||
cprintf ("\n");
|
||||
}
|
||||
if (deferred_heredocs)
|
||||
{
|
||||
if (cstring[0] != ';' || cstring[1])
|
||||
cprintf (" "); /* make sure there's at least one space */
|
||||
dispose_redirects (deferred_heredocs);
|
||||
}
|
||||
deferred_heredocs = (REDIRECT *)NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
print_redirection_list (redirects)
|
||||
REDIRECT *redirects;
|
||||
@@ -860,19 +934,47 @@ print_redirection_list (redirects)
|
||||
|
||||
/* Now that we've printed all the other redirections (on one line),
|
||||
print the here documents. */
|
||||
if (heredocs)
|
||||
if (heredocs && printing_connection)
|
||||
deferred_heredocs = heredocs;
|
||||
else if (heredocs)
|
||||
{
|
||||
cprintf (" ");
|
||||
for (hdtail = heredocs; hdtail; hdtail = hdtail->next)
|
||||
{
|
||||
print_redirection (hdtail);
|
||||
cprintf ("\n");
|
||||
}
|
||||
print_heredocs (heredocs);
|
||||
dispose_redirects (heredocs);
|
||||
was_heredoc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_heredoc_header (redirect)
|
||||
REDIRECT *redirect;
|
||||
{
|
||||
int kill_leading;
|
||||
char *x;
|
||||
|
||||
kill_leading = redirect->instruction == r_deblank_reading_until;
|
||||
|
||||
/* Here doc header */
|
||||
if (redirect->redirector != 0)
|
||||
cprintf ("%d", redirect->redirector);
|
||||
|
||||
/* If the here document delimiter is quoted, single-quote it. */
|
||||
if (redirect->redirectee.filename->flags & W_QUOTED)
|
||||
{
|
||||
x = sh_single_quote (redirect->here_doc_eof);
|
||||
cprintf ("<<%s%s", kill_leading ? "-" : "", x);
|
||||
free (x);
|
||||
}
|
||||
else
|
||||
cprintf ("<<%s%s", kill_leading ? "-" : "", redirect->here_doc_eof);
|
||||
}
|
||||
|
||||
static void
|
||||
print_heredoc_body (redirect)
|
||||
REDIRECT *redirect;
|
||||
{
|
||||
/* Here doc body */
|
||||
cprintf ("%s%s", redirect->redirectee.filename->word, redirect->here_doc_eof);
|
||||
}
|
||||
|
||||
static void
|
||||
print_redirection (redirect)
|
||||
REDIRECT *redirect;
|
||||
@@ -910,23 +1012,10 @@ print_redirection (redirect)
|
||||
break;
|
||||
|
||||
case r_deblank_reading_until:
|
||||
kill_leading++;
|
||||
/* ... */
|
||||
case r_reading_until:
|
||||
if (redirector != 0)
|
||||
cprintf ("%d", redirector);
|
||||
/* If the here document delimiter is quoted, single-quote it. */
|
||||
if (redirect->redirectee.filename->flags & W_QUOTED)
|
||||
{
|
||||
char *x;
|
||||
x = sh_single_quote (redirect->here_doc_eof);
|
||||
cprintf ("<<%s%s\n", kill_leading? "-" : "", x);
|
||||
free (x);
|
||||
}
|
||||
else
|
||||
cprintf ("<<%s%s\n", kill_leading? "-" : "", redirect->here_doc_eof);
|
||||
cprintf ("%s%s",
|
||||
redirect->redirectee.filename->word, redirect->here_doc_eof);
|
||||
print_heredoc_header (redirect);
|
||||
cprintf ("\n");
|
||||
print_heredoc_body (redirect);
|
||||
break;
|
||||
|
||||
case r_reading_string:
|
||||
@@ -1006,6 +1095,8 @@ reset_locals ()
|
||||
{
|
||||
inside_function_def = 0;
|
||||
indentation = 0;
|
||||
printing_connection = 0;
|
||||
deferred_heredocs = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1071,6 +1162,7 @@ named_function_string (name, command, flags)
|
||||
old_indent = indentation;
|
||||
old_amount = indentation_amount;
|
||||
command_string_index = was_heredoc = 0;
|
||||
deferred_heredocs = 0;
|
||||
|
||||
if (name && *name)
|
||||
cprintf ("%s ", name);
|
||||
|
||||
+1326
File diff suppressed because it is too large
Load Diff
+119
-27
@@ -78,6 +78,10 @@ static void command_print_word_list __P((WORD_LIST *, char *));
|
||||
static void print_case_clauses __P((PATTERN_LIST *));
|
||||
static void print_redirection_list __P((REDIRECT *));
|
||||
static void print_redirection __P((REDIRECT *));
|
||||
static void print_heredoc_header __P((REDIRECT *));
|
||||
static void print_heredoc_body __P((REDIRECT *));
|
||||
static void print_heredocs __P((REDIRECT *));
|
||||
static void print_deferred_heredocs __P((const char *));
|
||||
|
||||
static void print_for_command __P((FOR_COM *));
|
||||
#if defined (ARITH_FOR_COMMAND)
|
||||
@@ -108,6 +112,8 @@ int command_string_index = 0;
|
||||
static int inside_function_def;
|
||||
static int skip_this_indent;
|
||||
static int was_heredoc;
|
||||
static int printing_connection;
|
||||
static REDIRECT *deferred_heredocs;
|
||||
|
||||
/* The depth of the group commands that we are currently printing. This
|
||||
includes the group command that is a function body. */
|
||||
@@ -134,6 +140,7 @@ make_command_string (command)
|
||||
COMMAND *command;
|
||||
{
|
||||
command_string_index = was_heredoc = 0;
|
||||
deferred_heredocs = 0;
|
||||
make_command_string_internal (command);
|
||||
return (the_printed_command);
|
||||
}
|
||||
@@ -143,6 +150,8 @@ static void
|
||||
make_command_string_internal (command)
|
||||
COMMAND *command;
|
||||
{
|
||||
char s[3];
|
||||
|
||||
if (command == 0)
|
||||
cprintf ("");
|
||||
else
|
||||
@@ -215,6 +224,7 @@ make_command_string_internal (command)
|
||||
case cm_connection:
|
||||
|
||||
skip_this_indent++;
|
||||
printing_connection++;
|
||||
make_command_string_internal (command->value.Connection->first);
|
||||
|
||||
switch (command->value.Connection->connector)
|
||||
@@ -223,7 +233,13 @@ make_command_string_internal (command)
|
||||
case '|':
|
||||
{
|
||||
char c = command->value.Connection->connector;
|
||||
cprintf (" %c", c);
|
||||
|
||||
s[0] = ' ';
|
||||
s[1] = c;
|
||||
s[2] = '\0';
|
||||
|
||||
print_deferred_heredocs (s);
|
||||
|
||||
if (c != '&' || command->value.Connection->second)
|
||||
{
|
||||
cprintf (" ");
|
||||
@@ -233,22 +249,29 @@ make_command_string_internal (command)
|
||||
break;
|
||||
|
||||
case AND_AND:
|
||||
cprintf (" && ");
|
||||
print_deferred_heredocs (" && ");
|
||||
if (command->value.Connection->second)
|
||||
skip_this_indent++;
|
||||
break;
|
||||
|
||||
case OR_OR:
|
||||
cprintf (" || ");
|
||||
print_deferred_heredocs (" || ");
|
||||
if (command->value.Connection->second)
|
||||
skip_this_indent++;
|
||||
break;
|
||||
|
||||
case ';':
|
||||
#if 0
|
||||
if (was_heredoc == 0)
|
||||
cprintf (";");
|
||||
else
|
||||
was_heredoc = 0;
|
||||
#else
|
||||
if (deferred_heredocs == 0)
|
||||
cprintf (";");
|
||||
else
|
||||
print_deferred_heredocs (";");
|
||||
#endif
|
||||
|
||||
if (inside_function_def)
|
||||
cprintf ("\n");
|
||||
@@ -267,6 +290,7 @@ make_command_string_internal (command)
|
||||
}
|
||||
|
||||
make_command_string_internal (command->value.Connection->second);
|
||||
printing_connection--;
|
||||
break;
|
||||
|
||||
case cm_function_def:
|
||||
@@ -284,6 +308,12 @@ make_command_string_internal (command)
|
||||
cprintf (" )");
|
||||
break;
|
||||
|
||||
case cm_coproc:
|
||||
cprintf ("coproc %s ", command->value.Coproc->name);
|
||||
skip_this_indent++;
|
||||
make_command_string_internal (command->value.Coproc->command);
|
||||
break;
|
||||
|
||||
default:
|
||||
command_error ("print_command", CMDERR_BADTYPE, command->type, 0);
|
||||
break;
|
||||
@@ -811,6 +841,50 @@ print_simple_command (simple_command)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_heredocs (heredocs)
|
||||
REDIRECT *heredocs;
|
||||
{
|
||||
REDIRECT *hdtail;
|
||||
|
||||
cprintf (" ");
|
||||
for (hdtail = heredocs; hdtail; hdtail = hdtail->next)
|
||||
{
|
||||
print_redirection (hdtail);
|
||||
cprintf ("\n");
|
||||
}
|
||||
was_heredoc = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
print_deferred_heredocs (cstring)
|
||||
const char *cstring;
|
||||
{
|
||||
REDIRECT *hdtail;
|
||||
|
||||
for (hdtail = deferred_heredocs; hdtail; hdtail = hdtail->next)
|
||||
{
|
||||
cprintf (" ");
|
||||
print_heredoc_header (hdtail);
|
||||
}
|
||||
if (cstring[0] != ';' || cstring[1])
|
||||
cprintf ("%s", cstring);
|
||||
if (deferred_heredocs)
|
||||
cprintf ("\n");
|
||||
for (hdtail = deferred_heredocs; hdtail; hdtail = hdtail->next)
|
||||
{
|
||||
print_heredoc_body (hdtail);
|
||||
cprintf ("\n");
|
||||
}
|
||||
if (deferred_heredocs)
|
||||
{
|
||||
if (cstring[0] != ';' || cstring[1])
|
||||
cprintf (" "); /* make sure there's at least one space */
|
||||
dispose_redirects (deferred_heredocs);
|
||||
}
|
||||
deferred_heredocs = (REDIRECT *)NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
print_redirection_list (redirects)
|
||||
REDIRECT *redirects;
|
||||
@@ -854,19 +928,47 @@ print_redirection_list (redirects)
|
||||
|
||||
/* Now that we've printed all the other redirections (on one line),
|
||||
print the here documents. */
|
||||
if (heredocs)
|
||||
if (heredocs && printing_connection)
|
||||
deferred_heredocs = heredocs;
|
||||
else if (heredocs)
|
||||
{
|
||||
cprintf (" ");
|
||||
for (hdtail = heredocs; hdtail; hdtail = hdtail->next)
|
||||
{
|
||||
print_redirection (hdtail);
|
||||
cprintf ("\n");
|
||||
}
|
||||
print_heredocs (heredocs);
|
||||
dispose_redirects (heredocs);
|
||||
was_heredoc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_heredoc_header (redirect)
|
||||
REDIRECT *redirect;
|
||||
{
|
||||
int kill_leading;
|
||||
char *x;
|
||||
|
||||
kill_leading = redirect->instruction == r_deblank_reading_until;
|
||||
|
||||
/* Here doc header */
|
||||
if (redirect->redirector != 0)
|
||||
cprintf ("%d", redirect->redirector);
|
||||
|
||||
/* If the here document delimiter is quoted, single-quote it. */
|
||||
if (redirect->redirectee.filename->flags & W_QUOTED)
|
||||
{
|
||||
x = sh_single_quote (redirect->here_doc_eof);
|
||||
cprintf ("<<%s%s", kill_leading ? "-" : "", x);
|
||||
free (x);
|
||||
}
|
||||
else
|
||||
cprintf ("<<%s%s", kill_leading ? "-" : "", redirect->here_doc_eof);
|
||||
}
|
||||
|
||||
static void
|
||||
print_heredoc_body (redirect)
|
||||
REDIRECT *redirect;
|
||||
{
|
||||
/* Here doc body */
|
||||
cprintf ("%s%s", redirect->redirectee.filename->word, redirect->here_doc_eof);
|
||||
}
|
||||
|
||||
static void
|
||||
print_redirection (redirect)
|
||||
REDIRECT *redirect;
|
||||
@@ -904,23 +1006,10 @@ print_redirection (redirect)
|
||||
break;
|
||||
|
||||
case r_deblank_reading_until:
|
||||
kill_leading++;
|
||||
/* ... */
|
||||
case r_reading_until:
|
||||
if (redirector != 0)
|
||||
cprintf ("%d", redirector);
|
||||
/* If the here document delimiter is quoted, single-quote it. */
|
||||
if (redirect->redirectee.filename->flags & W_QUOTED)
|
||||
{
|
||||
char *x;
|
||||
x = sh_single_quote (redirect->here_doc_eof);
|
||||
cprintf ("<<%s%s\n", kill_leading? "-" : "", x);
|
||||
free (x);
|
||||
}
|
||||
else
|
||||
cprintf ("<<%s%s\n", kill_leading? "-" : "", redirect->here_doc_eof);
|
||||
cprintf ("%s%s",
|
||||
redirect->redirectee.filename->word, redirect->here_doc_eof);
|
||||
print_heredoc_header (redirect);
|
||||
cprintf ("\n");
|
||||
print_heredoc_body (redirect);
|
||||
break;
|
||||
|
||||
case r_reading_string:
|
||||
@@ -1000,6 +1089,8 @@ reset_locals ()
|
||||
{
|
||||
inside_function_def = 0;
|
||||
indentation = 0;
|
||||
printing_connection = 0;
|
||||
deferred_heredocs = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1065,6 +1156,7 @@ named_function_string (name, command, flags)
|
||||
old_indent = indentation;
|
||||
old_amount = indentation_amount;
|
||||
command_string_index = was_heredoc = 0;
|
||||
deferred_heredocs = 0;
|
||||
|
||||
if (name && *name)
|
||||
cprintf ("%s ", name);
|
||||
|
||||
@@ -553,19 +553,26 @@ main (argc, argv, env)
|
||||
set_default_lang ();
|
||||
set_default_locale_vars ();
|
||||
|
||||
/*
|
||||
* M-x term -> TERM=eterm EMACS=22.1 (term:0.96) (eterm)
|
||||
* M-x shell -> TERM=dumb EMACS=t (no line editing)
|
||||
* M-x terminal -> TERM=emacs-em7955 EMACS= (line editing)
|
||||
*/
|
||||
if (interactive_shell)
|
||||
{
|
||||
char *term, *emacs;
|
||||
|
||||
term = get_string_value ("TERM");
|
||||
no_line_editing |= term && (STREQ (term, "emacs"));
|
||||
emacs = get_string_value ("EMACS");
|
||||
running_under_emacs = emacs ? ((strstr (emacs, "term") != 0) ? 2 : 1) : 0;
|
||||
#if 0
|
||||
no_line_editing |= emacs && emacs[0] == 't' && emacs[1] == '\0';
|
||||
#else
|
||||
|
||||
/* Not sure any emacs terminal emulator sets TERM=emacs any more */
|
||||
no_line_editing |= term && (STREQ (term, "emacs"));
|
||||
no_line_editing |= emacs && emacs[0] == 't' && emacs[1] == '\0' && STREQ (term, "dumb");
|
||||
#endif
|
||||
|
||||
/* 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");
|
||||
|
||||
if (running_under_emacs)
|
||||
gnu_error_format = 1;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* shell.c -- GNU's idea of the POSIX shell specification. */
|
||||
|
||||
/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2008 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -553,19 +553,26 @@ main (argc, argv, env)
|
||||
set_default_lang ();
|
||||
set_default_locale_vars ();
|
||||
|
||||
/*
|
||||
* M-x term -> TERM=eterm EMACS=22.1 (term:0.96) (eterm)
|
||||
* M-x shell -> TERM=dumb EMACS=t (no line editing)
|
||||
* M-x terminal -> TERM=emacs-em7955 EMACS= (line editing)
|
||||
*/
|
||||
if (interactive_shell)
|
||||
{
|
||||
char *term, *emacs;
|
||||
|
||||
term = get_string_value ("TERM");
|
||||
no_line_editing |= term && (STREQ (term, "emacs"));
|
||||
emacs = get_string_value ("EMACS");
|
||||
running_under_emacs = emacs ? ((strstr (emacs, "term") != 0) ? 2 : 1) : 0;
|
||||
#if 0
|
||||
no_line_editing |= emacs && emacs[0] == 't' && emacs[1] == '\0';
|
||||
#else
|
||||
|
||||
/* Not sure any emacs terminal emulator sets TERM=emacs any more */
|
||||
no_line_editing |= term && (STREQ (term, "emacs"));
|
||||
no_line_editing |= emacs && emacs[0] == 't' && emacs[1] == '\0' && STREQ (term, "dumb");
|
||||
#endif
|
||||
|
||||
/* 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"));
|
||||
|
||||
if (running_under_emacs)
|
||||
gnu_error_format = 1;
|
||||
}
|
||||
@@ -898,6 +905,10 @@ exit_shell (s)
|
||||
maybe_save_shell_history ();
|
||||
#endif /* HISTORY */
|
||||
|
||||
#if defined (COPROCESS_SUPPORT)
|
||||
coproc_dispose (&sh_coproc);
|
||||
#endif
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
/* If the user has run `shopt -s huponexit', hangup all jobs when we exit
|
||||
an interactive login shell. ksh does this unconditionally. */
|
||||
|
||||
@@ -408,7 +408,7 @@ throw_to_top_level ()
|
||||
|
||||
#if defined (READLINE)
|
||||
if (interactive)
|
||||
bashline_reinitialize ();
|
||||
bashline_reset ();
|
||||
#endif /* READLINE */
|
||||
|
||||
#if defined (PROCESS_SUBSTITUTION)
|
||||
@@ -490,6 +490,7 @@ termsig_handler (sig)
|
||||
unlink_fifo_list ();
|
||||
#endif /* PROCESS_SUBSTITUTION */
|
||||
|
||||
itrace("received terminating signal %d", terminating_signal);
|
||||
run_exit_trap ();
|
||||
set_signal_handler (sig, SIG_DFL);
|
||||
kill (getpid (), sig);
|
||||
|
||||
@@ -4996,7 +4996,7 @@ array_length_reference (s)
|
||||
t = (ind == 0) ? value_cell (var) : (char *)NULL;
|
||||
}
|
||||
|
||||
len = STRLEN (t);
|
||||
len = MB_STRLEN (t);
|
||||
return (len);
|
||||
}
|
||||
#endif /* ARRAY_VARS */
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
${THIS_SH} ./invert.tests | grep -v '^expect' > /tmp/xx
|
||||
${THIS_SH} ./invert.tests 2>&1 | grep -v '^expect' > /tmp/xx
|
||||
diff /tmp/xx invert.right && rm -f /tmp/xx
|
||||
|
||||
@@ -357,6 +357,7 @@ trap_handler (sig)
|
||||
{
|
||||
int oerrno;
|
||||
|
||||
itrace("trap_handler: signal %d", sig);
|
||||
if ((sigmodes[sig] & SIG_TRAPPED) == 0)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
@@ -430,6 +431,7 @@ set_impossible_sigchld_trap ()
|
||||
{
|
||||
restore_default_signal (SIGCHLD);
|
||||
change_signal (SIGCHLD, (char *)IMPOSSIBLE_TRAP_HANDLER);
|
||||
sigmodes[SIGCHLD] &= ~SIG_TRAPPED; /* maybe_set_sigchld_trap checks this */
|
||||
}
|
||||
#endif /* JOB_CONTROL && SIGCHLD */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user