commit bash-20041007 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 13:37:49 -05:00
parent 7a2f2783f4
commit cac4cdbf5e
26 changed files with 2215 additions and 177 deletions
+37
View File
@@ -10281,3 +10281,40 @@ lib/readline/complete.c
subst.c
- use W_COMPASSIGN flag in do_assignment_internal instead of deciding
lexically which assignments are compound array assignments
10/6
----
support/shobj-conf
- additions for System V.5 from Boyd Gerber <gerberb@zenez.com>
subst.c
- in command_substitute, if subshell_environment includes
SUBSHELL_ASYNC, call make_child with the `async_p' argument set to
non-zero. This keeps command substitutions for async commands or
pipelines from trying to give the terminal back to the shell's
pgrp. make sure to save and restore last_asynchronous_pid. Fix
suggested by <pierre.humblet@ieee.org>
10/7
----
config.h.in
- add a placeholder definition for WCONTINUED_BROKEN
10/9
----
aclocal.m4
- add BASH_CHECK_WCONTINUED, checks for glibc bug where WCONTINUED is
defined but rejected as invalid by waitpid(2)
configure.in
- add call to BASH_CHECK_WCONTINUED, defines WCONTINUED_BROKEN
redir.c
- experimental change to add_undo_redirect to save manipulations to
file descriptors >= SHELL_FD_BASE (10) on the list of redirections
to be undone even if `exec' causes the list to be discarded
doc/{bash.1,bashref.texi}
- note that redirections using file descriptors > 9 should be used
carefully, because they might conflict with file descriptors the
shell uses internally
+38
View File
@@ -10275,3 +10275,41 @@ doc/{bash.1,bashref.texi}
lib/readline/complete.c
- fixed rl_menu_complete so that a negative argument cycles backwards
through the list
10/3
----
subst.c
- use W_COMPASSIGN flag in do_assignment_internal instead of deciding
lexically which assignments are compound array assignments
10/6
----
support/shobj-conf
- additions for System V.5 from Boyd Gerber <gerberb@zenez.com>
subst.c
- in command_substitute, if subshell_environment includes
SUBSHELL_ASYNC, call make_child with the `async_p' argument set to
non-zero. This keeps command substitutions for async commands or
pipelines from trying to give the terminal back to the shell's
pgrp. make sure to save and restore last_asynchronous_pid. Fix
suggested by <pierre.humblet@ieee.org>
10/7
----
config.h.in
- add a placeholder definition for WCONTINUED_BROKEN
10/9
----
aclocal.m4
- add BASH_CHECK_WCONTINUED, checks for glibc bug where WCONTINUED is
defined but rejected as invalid by waitpid(2)
configure.in
- add call to BASH_CHECK_WCONTINUED, defines WCONTINUED_BROKEN
redir.c
- experimental change to add_undo_redirect to save manipulations to
file descriptors >= SHELL_FD_BASE (10) on the list of redirections
to be undone even if `exec' causes the list to be discarded
+7 -1
View File
@@ -731,6 +731,8 @@ tests/extglob.tests f
tests/extglob.right f
tests/extglob2.tests f
tests/extglob2.right f
tests/extglob3.tests f
tests/extglob3.right f
tests/func.tests f
tests/func.right f
tests/func1.sub f
@@ -840,6 +842,7 @@ tests/run-execscript f
tests/run-exp-tests f
tests/run-extglob f
tests/run-extglob2 f
tests/run-extglob3 f
tests/run-func f
tests/run-getopts f
tests/run-glob-test f
@@ -873,6 +876,7 @@ tests/run-shopt f
tests/run-strip f
tests/run-test f
tests/run-tilde f
tests/run-tilde2 f
tests/run-trap f
tests/run-type f
tests/run-varenv f
@@ -886,8 +890,10 @@ tests/strip.tests f
tests/strip.right f
tests/test.tests f
tests/test.right f
tests/tilde-tests f
tests/tilde.tests f
tests/tilde.right f
tests/tilde2.tests f
tests/tilde2.right f
tests/trap.tests f
tests/trap.right f
tests/trap1.sub f 755
Vendored
+33
View File
@@ -1859,6 +1859,39 @@ AC_DEFINE(CTYPE_NON_ASCII)
fi
])
AC_DEFUN(BASH_CHECK_WCONTINUED,
[
AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken)
AC_CACHE_VAL(bash_cv_wcontinued_broken,
[AC_TRY_RUN([
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
main()
{
int x;
x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED);
if (x == -1 && errno == EINVAL)
exit (1);
else
exit (0);
}
], bash_cv_wcontinued_broken=no,bash_cv_wcontinued_broken=yes,
[AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no)
bash_cv_wcontinued_broken=no]
)])
AC_MSG_RESULT($bash_cv_wcontinued_broken)
if test $bash_cv_wcontinued_broken = yes; then
AC_DEFINE(WCONTINUED_BROKEN)
fi
])
dnl
dnl tests added for bashdb
dnl
Vendored
+41 -1
View File
@@ -1541,7 +1541,14 @@ AC_DEFUN(BASH_CHECK_DEV_FD,
[AC_MSG_CHECKING(whether /dev/fd is available)
AC_CACHE_VAL(bash_cv_dev_fd,
[if test -d /dev/fd && test -r /dev/fd/0 < /dev/null; then
bash_cv_dev_fd=standard
# check for systems like FreeBSD 5 that only provide /dev/fd/[012]
exec 3<&0
if test -r /dev/fd/3; then
bash_cv_dev_fd=standard
else
bash_cv_dev_fd=absent
fi
exec 3<&-
elif test -d /proc/self/fd && test -r /proc/self/fd/0 < /dev/null; then
bash_cv_dev_fd=whacky
else
@@ -1852,6 +1859,39 @@ AC_DEFINE(CTYPE_NON_ASCII)
fi
])
AC_DEFUN(BASH_CHECK_WCONTINUED,
[
AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken)
AC_CACHE_VAL(bash_cv_wcontinued_broken,
[AC_TRY_RUN([
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
main()
{
int x;
x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED);
if (x == -1 && errno == EINVAL)
exit (1);
else
exit (0);
}
], bash_cv_wcontinued_broken=no,bash_cv_wcontined_broken=yes,
[AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no)
bash_cv_wcontinued_broken=no]
)])
AC_MSG_RESULT($bash_cv_wcontinued_broken)
if test $bash_cv_wcontinued_broken = yes; then
AC_DEFINE(WCONTINUED_BROKEN)
fi
])
dnl
dnl tests added for bashdb
dnl
+75 -1
View File
@@ -1,5 +1,5 @@
@%:@! /bin/sh
@%:@ From configure.in for Bash 3.0, version 3.169, from autoconf version AC_ACVERSION.
@%:@ From configure.in for Bash 3.0, version 3.170, from autoconf version AC_ACVERSION.
@%:@ Guess values for system-dependent variables and create Makefiles.
@%:@ Generated by GNU Autoconf 2.57 for bash 3.1-devel.
@%:@
@@ -23202,6 +23202,80 @@ _ACEOF
fi
echo "$as_me:$LINENO: checking whether WCONTINUED flag to waitpid is unavailable or available but broken" >&5
echo $ECHO_N "checking whether WCONTINUED flag to waitpid is unavailable or available but broken... $ECHO_C" >&6
if test "${bash_cv_wcontinued_broken+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
{ echo "$as_me:$LINENO: WARNING: cannot check WCONTINUED if cross compiling -- defaulting to no" >&5
echo "$as_me: WARNING: cannot check WCONTINUED if cross compiling -- defaulting to no" >&2;}
bash_cv_wcontinued_broken=no
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
main()
{
int x;
x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED);
if (x == -1 && errno == EINVAL)
exit (1);
else
exit (0);
}
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
bash_cv_wcontinued_broken=no
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
bash_cv_wcontinued_broken=yes
fi
rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
echo "$as_me:$LINENO: result: $bash_cv_wcontinued_broken" >&5
echo "${ECHO_T}$bash_cv_wcontinued_broken" >&6
if test $bash_cv_wcontinued_broken = yes; then
cat >>confdefs.h <<\_ACEOF
@%:@define WCONTINUED_BROKEN 1
_ACEOF
fi
echo "$as_me:$LINENO: checking for speed_t in sys/types.h" >&5
echo $ECHO_N "checking for speed_t in sys/types.h... $ECHO_C" >&6
if test "${bash_cv_speed_t_in_sys_types+set}" = set; then
+84 -84
View File
@@ -15,96 +15,96 @@
'configure.in'
],
{
'AC_HEADER_MAJOR' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AC_HEADER_STAT' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_FUNC_STAT' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_FUNC_CHOWN' => 1,
'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_TYPE_PID_T' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_FUNC_VPRINTF' => 1,
'AH_OUTPUT' => 1,
'm4_pattern_allow' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_HEADER_STDC' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'm4_include' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_C_CONST' => 1,
'AC_FUNC_SETPGRP' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_C_VOLATILE' => 1,
'AC_FUNC_FSEEKO' => 1,
'AC_FUNC_MBRTOWC' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_CHECK_TYPES' => 1,
'AC_CONFIG_FILES' => 1,
'AC_CHECK_LIB' => 1,
'include' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_PATH_X' => 1,
'AC_PROG_CC' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AC_HEADER_TIME' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_LIBSOURCE' => 1,
'AC_PROG_LN_S' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_PROG_LEX' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_CHECK_MEMBERS' => 1,
'AC_FUNC_ERROR_AT_LINE' => 1,
'AM_CONDITIONAL' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'AC_FUNC_REALLOC' => 1,
'AM_PROG_CC_C_O' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_PROG_MAKE_SET' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_PROG_CXX' => 1,
'AC_FUNC_MMAP' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_PROG_AWK' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_ALLOCA' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_PROG_RANLIB' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_PROG_CPP' => 1,
'AC_C_INLINE' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_TYPE_UID_T' => 1,
'AC_PROG_YACC' => 1,
'AC_FUNC_STRNLEN' => 1,
'AC_PROG_INSTALL' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_CHECK_FUNCS' => 1,
'AM_MAINTAINER_MODE' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_FUNC_REALLOC' => 1,
'AC_C_CONST' => 1,
'AC_C_VOLATILE' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'AC_SUBST' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_CHECK_MEMBERS' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_INIT' => 1,
'AC_FUNC_SETPGRP' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_FUNC_GETMNTENT' => 1,
'm4_pattern_forbid' => 1
'AC_FUNC_LSTAT' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_PROG_CC' => 1,
'AM_CONDITIONAL' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_FUNC_STRTOD' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_TYPE_UID_T' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_PROG_YACC' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_HEADER_STAT' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_PROG_CXX' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_FSEEKO' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_PROG_RANLIB' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_TYPE_PID_T' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
'AC_PROG_LEX' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_PATH_X' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_CHECK_TYPES' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'include' => 1,
'AC_LIBSOURCE' => 1,
'AC_CHECK_FUNCS' => 1,
'm4_include' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_FUNC_STAT' => 1,
'AC_FUNC_CHOWN' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_FUNC_STRNLEN' => 1,
'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_PROG_LN_S' => 1,
'AC_PROG_INSTALL' => 1,
'm4_pattern_allow' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_PROG_AWK' => 1,
'AC_INIT' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_CHECK_LIB' => 1,
'AC_HEADER_MAJOR' => 1,
'AC_FUNC_MBRTOWC' => 1,
'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
'AC_FUNC_MMAP' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_C_INLINE' => 1,
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_FUNC_ALLOCA' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_FUNC_ERROR_AT_LINE' => 1,
'AH_OUTPUT' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_PROG_MAKE_SET' => 1,
'm4_pattern_forbid' => 1,
'AC_HEADER_STDC' => 1,
'AC_CHECK_HEADERS' => 1
}
], 'Request' )
);
+51 -50
View File
@@ -1122,64 +1122,65 @@ m4trace:configure.in:859: -1- AH_OUTPUT([GWINSZ_IN_SYS_IOCTL], [/* Define to 1 i
#undef GWINSZ_IN_SYS_IOCTL])
m4trace:configure.in:860: -1- AC_DEFINE_TRACE_LITERAL([TIOCSTAT_IN_SYS_IOCTL])
m4trace:configure.in:861: -1- AC_DEFINE_TRACE_LITERAL([FIONREAD_IN_SYS_IOCTL])
m4trace:configure.in:864: -1- AC_DEFINE_TRACE_LITERAL([SPEED_T_IN_SYS_TYPES])
m4trace:configure.in:865: -1- AC_DEFINE_TRACE_LITERAL([HAVE_GETPW_DECLS])
m4trace:configure.in:866: -1- AC_DEFINE_TRACE_LITERAL([UNUSABLE_RT_SIGNALS])
m4trace:configure.in:867: -1- AC_SUBST([SIGLIST_O])
m4trace:configure.in:871: -1- AC_DEFINE_TRACE_LITERAL([RLIMIT_NEEDS_KERNEL])
m4trace:configure.in:879: -1- AC_CHECK_LIB([termcap], [tgetent], [bash_cv_termcap_lib=libtermcap], [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
m4trace:configure.in:863: -1- AC_DEFINE_TRACE_LITERAL([WCONTINUED_BROKEN])
m4trace:configure.in:866: -1- AC_DEFINE_TRACE_LITERAL([SPEED_T_IN_SYS_TYPES])
m4trace:configure.in:867: -1- AC_DEFINE_TRACE_LITERAL([HAVE_GETPW_DECLS])
m4trace:configure.in:868: -1- AC_DEFINE_TRACE_LITERAL([UNUSABLE_RT_SIGNALS])
m4trace:configure.in:869: -1- AC_SUBST([SIGLIST_O])
m4trace:configure.in:873: -1- AC_DEFINE_TRACE_LITERAL([RLIMIT_NEEDS_KERNEL])
m4trace:configure.in:881: -1- AC_CHECK_LIB([termcap], [tgetent], [bash_cv_termcap_lib=libtermcap], [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
[AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
[AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
bash_cv_termcap_lib=gnutermcap)])])])
m4trace:configure.in:879: -1- AC_CHECK_LIB([tinfo], [tgetent], [bash_cv_termcap_lib=libtinfo], [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
m4trace:configure.in:881: -1- AC_CHECK_LIB([tinfo], [tgetent], [bash_cv_termcap_lib=libtinfo], [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
[AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
bash_cv_termcap_lib=gnutermcap)])])
m4trace:configure.in:879: -1- AC_CHECK_LIB([curses], [tgetent], [bash_cv_termcap_lib=libcurses], [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
m4trace:configure.in:881: -1- AC_CHECK_LIB([curses], [tgetent], [bash_cv_termcap_lib=libcurses], [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
bash_cv_termcap_lib=gnutermcap)])
m4trace:configure.in:879: -1- AC_CHECK_LIB([ncurses], [tgetent], [bash_cv_termcap_lib=libncurses], [bash_cv_termcap_lib=gnutermcap])
m4trace:configure.in:881: -1- AC_SUBST([TERMCAP_LIB])
m4trace:configure.in:882: -1- AC_SUBST([TERMCAP_DEP])
m4trace:configure.in:884: -1- AC_DEFINE_TRACE_LITERAL([HAVE_DEV_FD])
m4trace:configure.in:884: -1- AC_DEFINE_TRACE_LITERAL([DEV_FD_PREFIX])
m4trace:configure.in:884: -1- AC_DEFINE_TRACE_LITERAL([HAVE_DEV_FD])
m4trace:configure.in:884: -1- AC_DEFINE_TRACE_LITERAL([DEV_FD_PREFIX])
m4trace:configure.in:885: -1- AC_DEFINE_TRACE_LITERAL([HAVE_DEV_STDIN])
m4trace:configure.in:886: -1- AC_DEFINE_TRACE_LITERAL([DEFAULT_MAIL_DIRECTORY])
m4trace:configure.in:893: -1- AC_DEFINE_TRACE_LITERAL([JOB_CONTROL])
m4trace:configure.in:899: -1- AC_SUBST([JOBS_O])
m4trace:configure.in:912: -1- AC_DEFINE_TRACE_LITERAL([SVR4_2])
m4trace:configure.in:913: -1- AC_DEFINE_TRACE_LITERAL([SVR4])
m4trace:configure.in:914: -1- AC_DEFINE_TRACE_LITERAL([SVR4])
m4trace:configure.in:915: -1- AC_DEFINE_TRACE_LITERAL([SVR5])
m4trace:configure.in:972: -1- AC_SUBST([SHOBJ_CC])
m4trace:configure.in:973: -1- AC_SUBST([SHOBJ_CFLAGS])
m4trace:configure.in:974: -1- AC_SUBST([SHOBJ_LD])
m4trace:configure.in:975: -1- AC_SUBST([SHOBJ_LDFLAGS])
m4trace:configure.in:976: -1- AC_SUBST([SHOBJ_XLDFLAGS])
m4trace:configure.in:977: -1- AC_SUBST([SHOBJ_LIBS])
m4trace:configure.in:978: -1- AC_SUBST([SHOBJ_STATUS])
m4trace:configure.in:999: -1- AC_SUBST([PROFILE_FLAGS])
m4trace:configure.in:1001: -1- AC_SUBST([incdir])
m4trace:configure.in:1002: -1- AC_SUBST([BUILD_DIR])
m4trace:configure.in:1004: -1- AC_SUBST([YACC])
m4trace:configure.in:1005: -1- AC_SUBST([AR])
m4trace:configure.in:1006: -1- AC_SUBST([ARFLAGS])
m4trace:configure.in:1008: -1- AC_SUBST([BASHVERS])
m4trace:configure.in:1009: -1- AC_SUBST([RELSTATUS])
m4trace:configure.in:1010: -1- AC_SUBST([DEBUG])
m4trace:configure.in:1011: -1- AC_SUBST([MALLOC_DEBUG])
m4trace:configure.in:1013: -1- AC_SUBST([host_cpu])
m4trace:configure.in:1014: -1- AC_SUBST([host_vendor])
m4trace:configure.in:1015: -1- AC_SUBST([host_os])
m4trace:configure.in:1017: -1- AC_SUBST([LOCAL_LIBS])
m4trace:configure.in:1018: -1- AC_SUBST([LOCAL_CFLAGS])
m4trace:configure.in:1019: -1- AC_SUBST([LOCAL_LDFLAGS])
m4trace:configure.in:1020: -1- AC_SUBST([LOCAL_DEFS])
m4trace:configure.in:1034: -1- AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
m4trace:configure.in:881: -1- AC_CHECK_LIB([ncurses], [tgetent], [bash_cv_termcap_lib=libncurses], [bash_cv_termcap_lib=gnutermcap])
m4trace:configure.in:883: -1- AC_SUBST([TERMCAP_LIB])
m4trace:configure.in:884: -1- AC_SUBST([TERMCAP_DEP])
m4trace:configure.in:886: -1- AC_DEFINE_TRACE_LITERAL([HAVE_DEV_FD])
m4trace:configure.in:886: -1- AC_DEFINE_TRACE_LITERAL([DEV_FD_PREFIX])
m4trace:configure.in:886: -1- AC_DEFINE_TRACE_LITERAL([HAVE_DEV_FD])
m4trace:configure.in:886: -1- AC_DEFINE_TRACE_LITERAL([DEV_FD_PREFIX])
m4trace:configure.in:887: -1- AC_DEFINE_TRACE_LITERAL([HAVE_DEV_STDIN])
m4trace:configure.in:888: -1- AC_DEFINE_TRACE_LITERAL([DEFAULT_MAIL_DIRECTORY])
m4trace:configure.in:895: -1- AC_DEFINE_TRACE_LITERAL([JOB_CONTROL])
m4trace:configure.in:901: -1- AC_SUBST([JOBS_O])
m4trace:configure.in:914: -1- AC_DEFINE_TRACE_LITERAL([SVR4_2])
m4trace:configure.in:915: -1- AC_DEFINE_TRACE_LITERAL([SVR4])
m4trace:configure.in:916: -1- AC_DEFINE_TRACE_LITERAL([SVR4])
m4trace:configure.in:917: -1- AC_DEFINE_TRACE_LITERAL([SVR5])
m4trace:configure.in:974: -1- AC_SUBST([SHOBJ_CC])
m4trace:configure.in:975: -1- AC_SUBST([SHOBJ_CFLAGS])
m4trace:configure.in:976: -1- AC_SUBST([SHOBJ_LD])
m4trace:configure.in:977: -1- AC_SUBST([SHOBJ_LDFLAGS])
m4trace:configure.in:978: -1- AC_SUBST([SHOBJ_XLDFLAGS])
m4trace:configure.in:979: -1- AC_SUBST([SHOBJ_LIBS])
m4trace:configure.in:980: -1- AC_SUBST([SHOBJ_STATUS])
m4trace:configure.in:1001: -1- AC_SUBST([PROFILE_FLAGS])
m4trace:configure.in:1003: -1- AC_SUBST([incdir])
m4trace:configure.in:1004: -1- AC_SUBST([BUILD_DIR])
m4trace:configure.in:1006: -1- AC_SUBST([YACC])
m4trace:configure.in:1007: -1- AC_SUBST([AR])
m4trace:configure.in:1008: -1- AC_SUBST([ARFLAGS])
m4trace:configure.in:1010: -1- AC_SUBST([BASHVERS])
m4trace:configure.in:1011: -1- AC_SUBST([RELSTATUS])
m4trace:configure.in:1012: -1- AC_SUBST([DEBUG])
m4trace:configure.in:1013: -1- AC_SUBST([MALLOC_DEBUG])
m4trace:configure.in:1015: -1- AC_SUBST([host_cpu])
m4trace:configure.in:1016: -1- AC_SUBST([host_vendor])
m4trace:configure.in:1017: -1- AC_SUBST([host_os])
m4trace:configure.in:1019: -1- AC_SUBST([LOCAL_LIBS])
m4trace:configure.in:1020: -1- AC_SUBST([LOCAL_CFLAGS])
m4trace:configure.in:1021: -1- AC_SUBST([LOCAL_LDFLAGS])
m4trace:configure.in:1022: -1- AC_SUBST([LOCAL_DEFS])
m4trace:configure.in:1036: -1- AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
lib/intl/Makefile \
lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
examples/loadables/Makefile examples/loadables/perl/Makefile \
pathnames.h])
m4trace:configure.in:1034: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
m4trace:configure.in:1034: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
m4trace:configure.in:1036: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
m4trace:configure.in:1036: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
+3 -1
View File
@@ -386,7 +386,6 @@
#undef HAVE_LIBC_FNM_EXTMATCH
#undef HAVE_DECL_CONFSTR
#undef HAVE_DECL_PRINTF
@@ -403,6 +402,9 @@
#undef HAVE_MBSTATE_T
/* Define if WCONTINUED is defined in system headers, but rejected by waitpid */
#undef WCONTINUED_BROKEN
/* These are checked with BASH_CHECK_DECL */
#undef HAVE_DECL_STRTOIMAX
Vendored
+75 -1
View File
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in for Bash 3.0, version 3.169, from autoconf version AC_ACVERSION.
# From configure.in for Bash 3.0, version 3.170, from autoconf version AC_ACVERSION.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.57 for bash 3.1-devel.
#
@@ -23202,6 +23202,80 @@ _ACEOF
fi
echo "$as_me:$LINENO: checking whether WCONTINUED flag to waitpid is unavailable or available but broken" >&5
echo $ECHO_N "checking whether WCONTINUED flag to waitpid is unavailable or available but broken... $ECHO_C" >&6
if test "${bash_cv_wcontinued_broken+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
{ echo "$as_me:$LINENO: WARNING: cannot check WCONTINUED if cross compiling -- defaulting to no" >&5
echo "$as_me: WARNING: cannot check WCONTINUED if cross compiling -- defaulting to no" >&2;}
bash_cv_wcontinued_broken=no
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
main()
{
int x;
x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED);
if (x == -1 && errno == EINVAL)
exit (1);
else
exit (0);
}
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
bash_cv_wcontinued_broken=no
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
bash_cv_wcontinued_broken=yes
fi
rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
echo "$as_me:$LINENO: result: $bash_cv_wcontinued_broken" >&5
echo "${ECHO_T}$bash_cv_wcontinued_broken" >&6
if test $bash_cv_wcontinued_broken = yes; then
cat >>confdefs.h <<\_ACEOF
#define WCONTINUED_BROKEN 1
_ACEOF
fi
echo "$as_me:$LINENO: checking for speed_t in sys/types.h" >&5
echo $ECHO_N "checking for speed_t in sys/types.h... $ECHO_C" >&6
if test "${bash_cv_speed_t_in_sys_types+set}" = set; then
+3 -1
View File
@@ -22,7 +22,7 @@ dnl Process this file with autoconf to produce a configure script.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AC_REVISION([for Bash 3.0, version 3.169, from autoconf version] AC_ACVERSION)dnl
AC_REVISION([for Bash 3.0, version 3.170, from autoconf version] AC_ACVERSION)dnl
define(bashvers, 3.1)
define(relstatus, devel)
@@ -860,6 +860,8 @@ AC_HEADER_TIOCGWINSZ
BASH_HAVE_TIOCSTAT
BASH_HAVE_FIONREAD
BASH_CHECK_WCONTINUED
dnl miscellaneous
BASH_CHECK_SPEED_T
BASH_CHECK_GETPW_FUNCS
+4 -4
View File
@@ -22,10 +22,10 @@ dnl Process this file with autoconf to produce a configure script.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AC_REVISION([for Bash 3.0, version 3.168, from autoconf version] AC_ACVERSION)dnl
AC_REVISION([for Bash 3.0, version 3.169, from autoconf version] AC_ACVERSION)dnl
define(bashvers, 3.0)
define(relstatus, release)
define(bashvers, 3.1)
define(relstatus, devel)
AC_INIT(bash, bashvers-relstatus, bug-bash@gnu.org)
@@ -646,7 +646,7 @@ AC_CHECK_FUNCS(bcopy bzero confstr sysconf pathconf setenv putenv unsetenv \
getaddrinfo gethostbyname getservbyname getservent inet_aton \
vsnprintf snprintf vasprintf asprintf fnmatch regcomp regexec)
AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit)
AC_REPLACE_FUNCS(getcwd strcasecmp strerror strftime strpbrk memset strstr)
AC_REPLACE_FUNCS(getcwd strcasecmp strerror strftime strpbrk memset strstr strnlen)
AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax)
AC_CHECK_DECLS([confstr])
+4
View File
@@ -2950,6 +2950,10 @@ a UDP connection to the corresponding socket.
.RE
.PP
A failure to open or create a file causes the redirection to fail.
.PP
Redirections using file descriptors greater than 9 should be used with
care, as they may conflict with file descriptors the shell uses
internally.
.SS Redirecting Input
.PP
Redirection of input causes the file whose name results from
+3 -3
View File
@@ -6,12 +6,12 @@
.\" Case Western Reserve University
.\" chet@po.CWRU.Edu
.\"
.\" Last Change: Thu Sep 30 22:29:05 EDT 2004
.\" Last Change: Sat Oct 2 18:05:57 EDT 2004
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2004 Sep 30" "GNU Bash-3.0"
.TH BASH 1 "2004 Oct 2" "GNU Bash-3.1-devel"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -2853,7 +2853,7 @@ Matches zero or more occurrences of the given patterns
Matches one or more occurrences of the given patterns
.TP
\fB@(\fP\^\fIpattern-list\^\fP\fB)\fP
Matches exactly one of the given patterns
Matches one of the given patterns
.TP
\fB!(\fP\^\fIpattern-list\^\fP\fB)\fP
Matches anything except one of the given patterns
+4
View File
@@ -2017,6 +2017,10 @@ connection to the corresponding socket.
A failure to open or create a file causes the redirection to fail.
Redirections using file descriptors greater than 9 should be used with
care, as they may conflict with file descriptors the shell uses
internally.
@subsection Redirecting Input
Redirection of input causes the file whose name results from
the expansion of @var{word}
+1 -1
View File
@@ -1931,7 +1931,7 @@ Matches zero or more occurrences of the given patterns.
Matches one or more occurrences of the given patterns.
@item @@(@var{pattern-list})
Matches exactly one of the given patterns.
Matches one of the given patterns.
@item !(@var{pattern-list})
Matches anything except one of the given patterns.
+2 -2
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2004 Free Software Foundation, Inc.
@set EDITION 3.1-devel
@set VERSION 3.1-devel
@set UPDATED 2 October 2004
@set UPDATED 9 October 2004
@set UPDATED-MONTH October 2004
@set LASTCHANGE Sat Oct 2 18:05:41 EDT 2004
@set LASTCHANGE Sat Oct 9 18:40:05 EDT 2004
+4 -4
View File
@@ -2,9 +2,9 @@
Copyright (C) 1988-2004 Free Software Foundation, Inc.
@end ignore
@set EDITION 3.0
@set VERSION 3.0
@set UPDATED 2 October 2004
@set EDITION 3.1-devel
@set VERSION 3.1-devel
@set UPDATED 9 October 2004
@set UPDATED-MONTH October 2004
@set LASTCHANGE Sat Oct 2 18:05:41 EDT 2004
@set LASTCHANGE
+8 -19
View File
@@ -160,7 +160,7 @@ static int execute_while_command __P((WHILE_COM *));
static int execute_until_command __P((WHILE_COM *));
static int execute_while_or_until __P((WHILE_COM *, int));
static int execute_if_command __P((IF_COM *));
static int execute_null_command __P((REDIRECT *, int, int, int, pid_t));
static int execute_null_command __P((REDIRECT *, int, int, int));
static void fix_assignment_words __P((WORD_LIST *));
static int execute_simple_command __P((SIMPLE_COM *, int, int, int, struct fd_bitmap *));
static int execute_builtin __P((sh_builtin_func_t *, WORD_LIST *, int, int));
@@ -491,7 +491,6 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
{
int exec_result, invert, ignore_return, was_error_trap;
REDIRECT *my_undo_list, *exec_undo_list;
volatile pid_t last_pid;
volatile int save_line_number;
if (command == 0 || breaking || continuing || read_but_dont_execute)
@@ -648,7 +647,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
/* We can't rely on variables retaining their values across a
call to execute_simple_command if a longjmp occurs as the
result of a `return' builtin. This is true for sure with gcc. */
last_pid = last_made_pid;
last_made_pid = NO_PID;
was_error_trap = signal_is_trapped (ERROR_TRAP) && signal_is_ignored (ERROR_TRAP) == 0;
if (ignore_return && command->value.Simple)
@@ -678,7 +677,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
/* XXX - this is something to watch out for if there are problems
when the shell is compiled without job control. */
if (already_making_children && pipe_out == NO_PIPE &&
last_pid != last_made_pid)
last_made_pid != NO_PID)
{
stop_pipeline (asynchronous, (COMMAND *)NULL);
@@ -698,14 +697,6 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
subshells forked to execute builtin commands (e.g., in
pipelines) to be waited for twice. */
exec_result = wait_for (last_made_pid);
#if defined (RECYCLES_PIDS)
/* LynxOS, for one, recycles pids very quickly -- so quickly
that a new process may have the same pid as the last one
created. This has been reported to fix the problem on that
OS, and a similar problem on Cygwin. */
if (exec_result == 0)
last_made_pid = NO_PID;
#endif
}
}
@@ -2583,10 +2574,9 @@ bind_lastarg (arg)
to be run asynchronously. This handles all the side effects that are
supposed to take place. */
static int
execute_null_command (redirects, pipe_in, pipe_out, async, old_last_command_subst_pid)
execute_null_command (redirects, pipe_in, pipe_out, async)
REDIRECT *redirects;
int pipe_in, pipe_out, async;
pid_t old_last_command_subst_pid;
{
int r;
@@ -2632,7 +2622,7 @@ execute_null_command (redirects, pipe_in, pipe_out, async, old_last_command_subs
if (r != 0)
return (EXECUTION_FAILURE);
else if (old_last_command_subst_pid != last_command_subst_pid)
else if (last_command_subst_pid != NO_PID)
return (last_command_exit_value);
else
return (EXECUTION_SUCCESS);
@@ -2680,7 +2670,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
WORD_LIST *words, *lastword;
char *command_line, *lastarg, *temp;
int first_word_quoted, result, builtin_is_special, already_forked, dofork;
pid_t old_last_command_subst_pid, old_last_async_pid;
pid_t old_last_async_pid;
sh_builtin_func_t *builtin;
SHELL_VAR *func;
@@ -2715,7 +2705,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
first_word_quoted =
simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0;
old_last_command_subst_pid = last_command_subst_pid;
last_command_subst_pid = NO_PID;
old_last_async_pid = last_asynchronous_pid;
already_forked = dofork = 0;
@@ -2809,8 +2799,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
this_command_name = 0;
result = execute_null_command (simple_command->redirects,
pipe_in, pipe_out,
already_forked ? 0 : async,
old_last_command_subst_pid);
already_forked ? 0 : async);
if (already_forked)
exit (result);
else
+614
View File
@@ -0,0 +1,614 @@
/* input.c -- functions to perform buffered input with synchronization. */
/* Copyright (C) 1992 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"
#include "bashtypes.h"
#if !defined (_MINIX) && defined (HAVE_SYS_FILE_H)
# include <sys/file.h>
#endif
#include "filecntl.h"
#include "posixstat.h"
#include <stdio.h>
#include <errno.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "bashansi.h"
#include "bashintl.h"
#include "command.h"
#include "general.h"
#include "input.h"
#include "error.h"
#include "externs.h"
#if !defined (errno)
extern int errno;
#endif /* !errno */
/* Functions to handle reading input on systems that don't restart read(2)
if a signal is received. */
static char localbuf[128];
static int local_index, local_bufused;
/* Posix and USG systems do not guarantee to restart read () if it is
interrupted by a signal. We do the read ourselves, and restart it
if it returns EINTR. */
int
getc_with_restart (stream)
FILE *stream;
{
unsigned char uc;
/* Try local buffering to reduce the number of read(2) calls. */
if (local_index == local_bufused || local_bufused == 0)
{
while (1)
{
local_bufused = read (fileno (stream), localbuf, sizeof(localbuf));
if (local_bufused > 0)
break;
else if (local_bufused == 0 || errno != EINTR)
{
local_index = 0;
return EOF;
}
}
local_index = 0;
}
uc = localbuf[local_index++];
return uc;
}
int
ungetc_with_restart (c, stream)
int c;
FILE *stream;
{
if (local_index == 0 || c == EOF)
return EOF;
localbuf[--local_index] = c;
return c;
}
#if defined (BUFFERED_INPUT)
/* A facility similar to stdio, but input-only. */
#if defined (USING_BASH_MALLOC)
# define MAX_INPUT_BUFFER_SIZE 8176
#else
# define MAX_INPUT_BUFFER_SIZE 8192
#endif
#if !defined (SEEK_CUR)
# define SEEK_CUR 1
#endif /* !SEEK_CUR */
#ifdef max
# undef max
#endif
#define max(a, b) (((a) > (b)) ? (a) : (b))
#ifdef min
# undef min
#endif
#define min(a, b) ((a) > (b) ? (b) : (a))
extern int interactive_shell;
int bash_input_fd_changed;
/* This provides a way to map from a file descriptor to the buffer
associated with that file descriptor, rather than just the other
way around. This is needed so that buffers are managed properly
in constructs like 3<&4. buffers[x]->b_fd == x -- that is how the
correspondence is maintained. */
static BUFFERED_STREAM **buffers = (BUFFERED_STREAM **)NULL;
static int nbuffers;
#define ALLOCATE_BUFFERS(n) \
do { if ((n) >= nbuffers) allocate_buffers (n); } while (0)
/* Make sure `buffers' has at least N elements. */
static void
allocate_buffers (n)
int n;
{
register int i, orig_nbuffers;
orig_nbuffers = nbuffers;
nbuffers = n + 20;
buffers = (BUFFERED_STREAM **)xrealloc
(buffers, nbuffers * sizeof (BUFFERED_STREAM *));
/* Zero out the new buffers. */
for (i = orig_nbuffers; i < nbuffers; i++)
buffers[i] = (BUFFERED_STREAM *)NULL;
}
/* Construct and return a BUFFERED_STREAM corresponding to file descriptor
FD, using BUFFER. */
static BUFFERED_STREAM *
make_buffered_stream (fd, buffer, bufsize)
int fd;
char *buffer;
size_t bufsize;
{
BUFFERED_STREAM *bp;
bp = (BUFFERED_STREAM *)xmalloc (sizeof (BUFFERED_STREAM));
ALLOCATE_BUFFERS (fd);
buffers[fd] = bp;
bp->b_fd = fd;
bp->b_buffer = buffer;
bp->b_size = bufsize;
bp->b_used = bp->b_inputp = bp->b_flag = 0;
if (bufsize == 1)
bp->b_flag |= B_UNBUFF;
return (bp);
}
/* Allocate a new BUFFERED_STREAM, copy BP to it, and return the new copy. */
static BUFFERED_STREAM *
copy_buffered_stream (bp)
BUFFERED_STREAM *bp;
{
BUFFERED_STREAM *nbp;
if (!bp)
return ((BUFFERED_STREAM *)NULL);
nbp = (BUFFERED_STREAM *)xmalloc (sizeof (BUFFERED_STREAM));
xbcopy ((char *)bp, (char *)nbp, sizeof (BUFFERED_STREAM));
return (nbp);
}
int
set_bash_input_fd (fd)
int fd;
{
if (bash_input.type == st_bstream)
bash_input.location.buffered_fd = fd;
else if (interactive_shell == 0)
default_buffered_input = fd;
return 0;
}
int
fd_is_bash_input (fd)
int fd;
{
if (bash_input.type == st_bstream && bash_input.location.buffered_fd == fd)
return 1;
else if (interactive_shell == 0 && default_buffered_input == fd)
return 1;
return 0;
}
/* Save the buffered stream corresponding to file descriptor FD (which bash
is using to read input) to a buffered stream associated with NEW_FD. If
NEW_FD is -1, a new file descriptor is allocated with fcntl. The new
file descriptor is returned on success, -1 on error. */
int
save_bash_input (fd, new_fd)
int fd, new_fd;
{
int nfd;
itrace("save_bash_input: %d -> %d", fd, new_fd);
/* Sync the stream so we can re-read from the new file descriptor. We
might be able to avoid this by copying the buffered stream verbatim
to the new file descriptor. */
if (buffers[fd])
sync_buffered_stream (fd);
/* Now take care of duplicating the file descriptor that bash is
using for input, so we can reinitialize it later. */
nfd = (new_fd == -1) ? fcntl (fd, F_DUPFD, 10) : new_fd;
if (nfd == -1)
{
if (fcntl (fd, F_GETFD, 0) == 0)
sys_error (_("cannot allocate new file descriptor for bash input from fd %d"), fd);
return -1;
}
if (buffers[nfd])
{
/* What's this? A stray buffer without an associated open file
descriptor? Free up the buffer and report the error. */
internal_error (_("save_bash_input: buffer already exists for new fd %d"), nfd);
free_buffered_stream (buffers[nfd]);
}
/* Reinitialize bash_input.location. */
if (bash_input.type == st_bstream)
{
bash_input.location.buffered_fd = nfd;
fd_to_buffered_stream (nfd);
close_buffered_fd (fd); /* XXX */
}
else
/* If the current input type is not a buffered stream, but the shell
is not interactive and therefore using a buffered stream to read
input (e.g. with an `eval exec 3>output' inside a script), note
that the input fd has been changed. pop_stream() looks at this
value and adjusts the input fd to the new value of
default_buffered_input accordingly. */
bash_input_fd_changed++;
if (default_buffered_input == fd)
default_buffered_input = nfd;
SET_CLOSE_ON_EXEC (nfd);
return nfd;
}
/* Check that file descriptor FD is not the one that bash is currently
using to read input from a script. FD is about to be duplicated onto,
which means that the kernel will close it for us. If FD is the bash
input file descriptor, we need to seek backwards in the script (if
possible and necessary -- scripts read from stdin are still unbuffered),
allocate a new file descriptor to use for bash input, and re-initialize
the buffered stream. Make sure the file descriptor used to save bash
input is set close-on-exec. Returns 0 on success, -1 on failure. This
works only if fd is > 0 -- if fd == 0 and bash is reading input from
fd 0, save_bash_input is used instead, to cooperate with input
redirection (look at redir.c:add_undo_redirect()). */
int
check_bash_input (fd)
int fd;
{
itrace("check_bash_input: %d", fd);
if (fd_is_bash_input (fd))
{
if (fd > 0)
return ((save_bash_input (fd, -1) == -1) ? -1 : 0);
else if (fd == 0)
return ((sync_buffered_stream (fd) == -1) ? -1 : 0);
}
return 0;
}
/* This is the buffered stream analogue of dup2(fd1, fd2). The
BUFFERED_STREAM corresponding to fd2 is deallocated, if one exists.
BUFFERS[fd1] is copied to BUFFERS[fd2]. This is called by the
redirect code for constructs like 4<&0 and 3</etc/rc.local. */
int
duplicate_buffered_stream (fd1, fd2)
int fd1, fd2;
{
int is_bash_input, m;
if (fd1 == fd2)
return 0;
m = max (fd1, fd2);
ALLOCATE_BUFFERS (m);
/* If FD2 is the file descriptor bash is currently using for shell input,
we need to do some extra work to make sure that the buffered stream
actually exists (it might not if fd1 was not active, and the copy
didn't actually do anything). */
is_bash_input = (bash_input.type == st_bstream) &&
(bash_input.location.buffered_fd == fd2);
if (buffers[fd2])
free_buffered_stream (buffers[fd2]);
buffers[fd2] = copy_buffered_stream (buffers[fd1]);
if (buffers[fd2])
buffers[fd2]->b_fd = fd2;
if (is_bash_input)
{
if (!buffers[fd2])
fd_to_buffered_stream (fd2);
buffers[fd2]->b_flag |= B_WASBASHINPUT;
}
return (fd2);
}
/* Return 1 if a seek on FD will succeed. */
#ifndef __CYGWIN__
# define fd_is_seekable(fd) (lseek ((fd), 0L, SEEK_CUR) >= 0)
#else
# define fd_is_seekable(fd) 0
#endif /* __CYGWIN__ */
/* Take FD, a file descriptor, and create and return a buffered stream
corresponding to it. If something is wrong and the file descriptor
is invalid, return a NULL stream. */
BUFFERED_STREAM *
fd_to_buffered_stream (fd)
int fd;
{
char *buffer;
size_t size;
struct stat sb;
if (fstat (fd, &sb) < 0)
{
close (fd);
return ((BUFFERED_STREAM *)NULL);
}
size = (fd_is_seekable (fd)) ? min (sb.st_size, MAX_INPUT_BUFFER_SIZE) : 1;
if (size == 0)
size = 1;
buffer = (char *)xmalloc (size);
return (make_buffered_stream (fd, buffer, size));
}
/* Return a buffered stream corresponding to FILE, a file name. */
BUFFERED_STREAM *
open_buffered_stream (file)
char *file;
{
int fd;
fd = open (file, O_RDONLY);
return ((fd >= 0) ? fd_to_buffered_stream (fd) : (BUFFERED_STREAM *)NULL);
}
/* Deallocate a buffered stream and free up its resources. Make sure we
zero out the slot in BUFFERS that points to BP. */
void
free_buffered_stream (bp)
BUFFERED_STREAM *bp;
{
int n;
if (!bp)
return;
n = bp->b_fd;
if (bp->b_buffer)
free (bp->b_buffer);
free (bp);
buffers[n] = (BUFFERED_STREAM *)NULL;
}
/* Close the file descriptor associated with BP, a buffered stream, and free
up the stream. Return the status of closing BP's file descriptor. */
int
close_buffered_stream (bp)
BUFFERED_STREAM *bp;
{
int fd;
if (!bp)
return (0);
fd = bp->b_fd;
free_buffered_stream (bp);
return (close (fd));
}
/* Deallocate the buffered stream associated with file descriptor FD, and
close FD. Return the status of the close on FD. */
int
close_buffered_fd (fd)
int fd;
{
if (fd < 0)
{
errno = EBADF;
return -1;
}
if (fd >= nbuffers || !buffers || !buffers[fd])
return (close (fd));
return (close_buffered_stream (buffers[fd]));
}
/* Make the BUFFERED_STREAM associcated with buffers[FD] be BP, and return
the old BUFFERED_STREAM. */
BUFFERED_STREAM *
set_buffered_stream (fd, bp)
int fd;
BUFFERED_STREAM *bp;
{
BUFFERED_STREAM *ret;
ret = buffers[fd];
buffers[fd] = bp;
return ret;
}
/* Read a buffer full of characters from BP, a buffered stream. */
static int
b_fill_buffer (bp)
BUFFERED_STREAM *bp;
{
ssize_t nr;
nr = zread (bp->b_fd, bp->b_buffer, bp->b_size);
if (nr <= 0)
{
bp->b_used = 0;
bp->b_buffer[0] = 0;
if (nr == 0)
bp->b_flag |= B_EOF;
else
bp->b_flag |= B_ERROR;
return (EOF);
}
#if defined (__CYGWIN__)
/* If on cygwin, translate \r\n to \n. */
if (nr >= 2 && bp->b_buffer[nr - 2] == '\r' && bp->b_buffer[nr - 1] == '\n')
{
bp->b_buffer[nr - 2] = '\n';
nr--;
}
#endif
bp->b_used = nr;
bp->b_inputp = 0;
return (bp->b_buffer[bp->b_inputp++] & 0xFF);
}
/* Get a character from buffered stream BP. */
#define bufstream_getc(bp) \
(bp->b_inputp == bp->b_used || !bp->b_used) \
? b_fill_buffer (bp) \
: bp->b_buffer[bp->b_inputp++] & 0xFF
/* Push C back onto buffered stream BP. */
static int
bufstream_ungetc(c, bp)
int c;
BUFFERED_STREAM *bp;
{
if (c == EOF || bp->b_inputp == 0)
return (EOF);
bp->b_buffer[--bp->b_inputp] = c;
return (c);
}
/* Seek backwards on file BFD to synchronize what we've read so far
with the underlying file pointer. */
int
sync_buffered_stream (bfd)
int bfd;
{
BUFFERED_STREAM *bp;
off_t chars_left;
if (buffers == 0 || (bp = buffers[bfd]) == 0)
return (-1);
chars_left = bp->b_used - bp->b_inputp;
if (chars_left)
lseek (bp->b_fd, -chars_left, SEEK_CUR);
bp->b_used = bp->b_inputp = 0;
return (0);
}
int
buffered_getchar ()
{
#if !defined (DJGPP)
return (bufstream_getc (buffers[bash_input.location.buffered_fd]));
#else
/* On DJGPP, ignore \r. */
int ch;
while ((ch = bufstream_getc (buffers[bash_input.location.buffered_fd])) == '\r')
;
return ch;
#endif
}
int
buffered_ungetchar (c)
int c;
{
return (bufstream_ungetc (c, buffers[bash_input.location.buffered_fd]));
}
/* Make input come from file descriptor BFD through a buffered stream. */
void
with_input_from_buffered_stream (bfd, name)
int bfd;
char *name;
{
INPUT_STREAM location;
BUFFERED_STREAM *bp;
location.buffered_fd = bfd;
/* Make sure the buffered stream exists. */
bp = fd_to_buffered_stream (bfd);
init_yy_io (bp == 0 ? return_EOF : buffered_getchar,
buffered_ungetchar, st_bstream, name, location);
}
#if defined (TEST)
void *
xmalloc(s)
int s;
{
return (malloc (s));
}
void *
xrealloc(s, size)
char *s;
int size;
{
if (!s)
return(malloc (size));
else
return(realloc (s, size));
}
void
init_yy_io ()
{
}
process(bp)
BUFFERED_STREAM *bp;
{
int c;
while ((c = bufstream_getc(bp)) != EOF)
putchar(c);
}
BASH_INPUT bash_input;
struct stat dsb; /* can be used from gdb */
/* imitate /bin/cat */
main(argc, argv)
int argc;
char **argv;
{
register int i;
BUFFERED_STREAM *bp;
if (argc == 1) {
bp = fd_to_buffered_stream (0);
process(bp);
exit(0);
}
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-' && argv[i][1] == '\0') {
bp = fd_to_buffered_stream (0);
if (!bp)
continue;
process(bp);
free_buffered_stream (bp);
} else {
bp = open_buffered_stream (argv[i]);
if (!bp)
continue;
process(bp);
close_buffered_stream (bp);
}
}
exit(0);
}
#endif /* TEST */
#endif /* BUFFERED_INPUT */
+15
View File
@@ -970,6 +970,21 @@ add_undo_redirect (fd)
is thrown away by the `exec' builtin. */
add_exec_redirect (dummy_redirect);
/* experimental: if we're saving a redirection to undo for a file descriptor
above SHELL_FD_BASE, add a redirection to be undone if the exec builtin
causes redirections to be discarded. */
if (fd >= SHELL_FD_BASE)
{
rd.dest = new_fd;
new_redirect = make_redirection (fd, r_duplicating_output, rd);
#if 0
closer = copy_redirects (new_redirect);
add_exec_redirect (closer);
#else
add_exec_redirect (new_redirect);
#endif
}
/* File descriptors used only for saving others should always be
marked close-on-exec. Unfortunately, we have to preserve the
close-on-exec state of the file descriptor we are saving, since
+1066
View File
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -4351,7 +4351,7 @@ command_substitute (string, quoted)
char *string;
int quoted;
{
pid_t pid, old_pid, old_pipeline_pgrp;
pid_t pid, old_pid, old_pipeline_pgrp, old_async_pid;
char *istring;
int result, fildes[2], function_value, pflags, rc;
@@ -4399,7 +4399,14 @@ command_substitute (string, quoted)
cleanup_the_pipeline ();
#endif
old_async_pid = last_asynchronous_pid;
#if 0
pid = make_child ((char *)NULL, 0);
#else
pid = make_child ((char *)NULL, subshell_environment&SUBSHELL_ASYNC);
#endif
last_asynchronous_pid = old_async_pid;
if (pid == 0)
/* Reset the signal handlers in the child, but don't free the
trap strings. */
+33 -1
View File
@@ -408,7 +408,39 @@ sysv5uw7*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5UnixWare*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5UnixWare*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-G -dy -z text -h $@'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5OpenUNIX*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5OpenUNIX*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-G -dy -z text -h $@'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
dgux*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+1 -1
View File
@@ -1,2 +1,2 @@
${THIS_SH} ./tilde-tests > /tmp/xx
${THIS_SH} ./tilde.tests > /tmp/xx
diff /tmp/xx tilde.right && rm -f /tmp/xx