doc/bashref.texi, lib/readline/doc/{history,rlman,rluser,rluserman}.texi
- Slight changes to conform to the latest FSF documentation standards.
Patch from Karl Berry <karl@freefriends.org>
+
+ 12/20
+ -----
+execute_cmd.c
+ - after calling clear_unwind_protect_list, make sure we reset
+ parse_and_execute_level to 0, since there's nothing left to
+ restore it if top_level_cleanup tests it. Fixes bug reported
+ by Len Lattanzi <llattanzi@apple.com>
+
+ 12/31
+ -----
+lib/sh/getcwd.c
+ - new function, _path_checkino, checks whether the inode corresponding
+ to the path constructed from the first two arguments is the same as
+ the inode number passed as the third argument
+ - if BROKEN_DIRENT_D_INO is defined, meaning the d_ino/d_fileno
+ member of struct dirent doesn't contain valid values, use
+ _path_checkino instead of directly comparing against d_fileno.
+ Fixes Interix problem reported by Michael Haubenwallner
+ <haubi@gentoo.org>
the argument to the -u option (default 0). Fix for bug reported
by b_bashbug@thebellsplace.com
-doc/bashref.texi, lib/readline/doc/{history,rlman,rluser}.texi
+doc/bashref.texi, lib/readline/doc/{history,rlman,rluser,rluserman}.texi
- Slight changes to conform to the latest FSF documentation standards.
Patch from Karl Berry <karl@freefriends.org>
+
+ 12/20
+ -----
+execute_cmd.c
+ - after calling clear_unwind_protect_list, make sure we reset
+ parse_and_execute_level to 0, since there's nothing left to
+ restore it if top_level_cleanup tests it. Fixes bug reported
+ by Len Lattanzi <llattanzi@apple.com>
shell_variables = shell_variables->down;
clear_unwind_protect_list (0);
+ /* XXX -- are there other things we should be resetting here? */
+ parse_and_execute_level = 0; /* nothing left to restore it */
/* We're no longer inside a shell function. */
variable_context = return_catch_flag = 0;
# define NULL 0
#endif
+/* If the d_fileno member of a struct dirent doesn't return anything useful,
+ we need to check inode number equivalence the hard way. Return 1 if
+ the inode corresponding to PATH/DIR is identical to THISINO. */
+#if defined (BROKEN_DIRENT_D_INO)
+static int
+_path_checkino (dotp, name, thisino)
+ char *dotp;
+ char *name;
+ ino_t thisino;
+{
+ char *fullpath;
+ int r, e;
+ struct stat st;
+
+ e = errno;
+ fullpath = sh_makepath (dotp, name, MP_RMDOT);
+ if (stat (fullpath, &st) < 0)
+ {
+ errno = e;
+ return 0;
+ }
+ free (fullpath);
+ errno = e;
+ return (st.st_ino == thisino);
+}
+#endif
+
/* Get the pathname of the current working directory,
and put it in SIZE bytes of BUF. Returns NULL if the
directory couldn't be determined or SIZE was too small.
(d->d_name[1] == '\0' ||
(d->d_name[1] == '.' && d->d_name[2] == '\0')))
continue;
+#if !defined (BROKEN_DIRENT_D_INO)
if (mount_point || d->d_fileno == thisino)
+#else
+ if (mount_point || _path_checkino (dotp, d->d_name, thisino))
+#endif
{
char *name;
# define NULL 0
#endif
+/* If the d_fileno member of a struct dirent doesn't return anything useful,
+ we need to check inode number equivalence the hard way. */
+#if defined (BROKEN_DIRENT_D_INO)
+static int
+_path_checkino (dotp, name, thisino)
+ char *dotp;
+ char *name;
+ ino_t thisino;
+{
+ char *fullpath;
+ int r, e;
+ struct stat st;
+
+ e = errno;
+ fullpath = sh_makepath (dotp, name, MP_RMDOT);
+ if (stat (fullpath, &st) < 0)
+ {
+ errno = e;
+ return 0;
+ }
+ free (fullpath);
+ errno = e;
+ return (st.st_ino == thisino);
+}
+#endif
+
/* Get the pathname of the current working directory,
and put it in SIZE bytes of BUF. Returns NULL if the
directory couldn't be determined or SIZE was too small.
(d->d_name[1] == '\0' ||
(d->d_name[1] == '.' && d->d_name[2] == '\0')))
continue;
+#if !defined (BROKEN_DIRENT_D_INO)
if (mount_point || d->d_fileno == thisino)
+#else
+ if (mount_point || _path_checkino (dotp, d->d_name, thisino))
+#endif
{
char *name;
{
size_t len = pathbuf + pathsize - pathp;
+ if (buf == NULL && size <= 0)
+ size = len;
+
+ if ((size_t) size < len)
+ {
+ errno = ERANGE;
+ goto lose2;
+ }
if (buf == NULL)
{
- if (len < (size_t) size)
- len = size;
- buf = (char *) malloc (len);
+ buf = (char *) malloc (size);
if (buf == NULL)
goto lose2;
}
- else if ((size_t) size < len)
- {
- errno = ERANGE;
- goto lose2;
- }
+
(void) memcpy((PTR_T) buf, (PTR_T) pathp, len);
}
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 25
+#define PATCHLEVEL 33
#endif /* _PATCHLEVEL_H_ */
fflush (stdout);
fpurge (stdout);
}
+ else if (redirector == 2 && fileno (stderr) == redirector)
+ {
+ fflush (stderr);
+ fpurge (stderr);
+ }
if ((fd != redirector) && (dup2 (fd, redirector) < 0))
return (errno);
/* redir.c -- Functions to perform input and output redirection. */
-/* Copyright (C) 1997-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2007 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#include "bashansi.h"
#include "bashintl.h"
-
#include "memalloc.h"
+
+#define NEED_FPURGE_DECL
+
#include "shell.h"
#include "flags.h"
#include "execute_cmd.h"
# include "input.h"
#endif
+#define SHELL_FD_BASE 10
+
int expanding_redir;
extern int posixly_correct;
if (all_digits (filename+8) && legal_number (filename+8, &lfd) && lfd == (int)lfd)
{
fd = lfd;
- fd = fcntl (fd, F_DUPFD, 10);
+ fd = fcntl (fd, F_DUPFD, SHELL_FD_BASE);
}
else
fd = AMBIGUOUS_REDIRECT;
#if !defined (HAVE_DEV_STDIN)
case RF_DEVSTDIN:
- fd = fcntl (0, F_DUPFD, 10);
+ fd = fcntl (0, F_DUPFD, SHELL_FD_BASE);
break;
case RF_DEVSTDOUT:
- fd = fcntl (1, F_DUPFD, 10);
+ fd = fcntl (1, F_DUPFD, SHELL_FD_BASE);
break;
case RF_DEVSTDERR:
- fd = fcntl (2, F_DUPFD, 10);
+ fd = fcntl (2, F_DUPFD, SHELL_FD_BASE);
break;
#endif
check_bash_input (redirector);
#endif
+ /* Make sure there is no pending output before we change the state
+ of the underlying file descriptor, since the builtins use stdio
+ for output. */
+ if (redirector == 1 && fileno (stdout) == redirector)
+ {
+ fflush (stdout);
+ fpurge (stdout);
+ }
+
if ((fd != redirector) && (dup2 (fd, redirector) < 0))
return (errno);
else
add_undo_close_redirect (redirector);
}
-
#if defined (BUFFERED_INPUT)
check_bash_input (redirector);
#endif
return (0);
}
-#define SHELL_FD_BASE 10
-
/* Remember the file descriptor associated with the slot FD,
on REDIRECTION_UNDO_LIST. Note that the list will be reversed
before it is executed. Any redirections that need to be undone
/* 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 && ri != r_close_this)
+ causes redirections to be discarded. There needs to be a difference
+ between fds that are used to save other fds and then are the target of
+ user redirctions and fds that are just the target of user redirections.
+ We use the close-on-exec flag to tell the difference; fds > SHELL_FD_BASE
+ that have the close-on-exec flag set are assumed to be fds used internally
+ to save others. */
+ if (fd >= SHELL_FD_BASE && ri != r_close_this && clexec_flag)
{
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
+ new_redirect->flags |= RX_INTERNAL;
+
add_exec_redirect (new_redirect);
-#endif
}
/* File descriptors used only for saving others should always be
-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