Update of /cvsroot/winbash/winbash
In directory usw-pr-cvs1:/tmp/cvs-serv14844
Modified Files:
.patchlevel bashline.c braces.c error.c execute_cmd.c expr.c
general.c general.h input.h jobs.c jobs.h machines.h
newversion.c parse.y shell.c siglist.h subst.c test.c trap.c
trap.h variables.c
Log Message:
Applied 1.14.3 diffs from GNU bash
Index: .patchlevel
===================================================================
RCS file: /cvsroot/winbash/winbash/.patchlevel,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- .patchlevel 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ .patchlevel 9 Mar 2002 16:05:41 -0000 1.2
@@ -1 +1 @@
-2
+3
Index: bashline.c
===================================================================
RCS file: /cvsroot/winbash/winbash/bashline.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- bashline.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ bashline.c 9 Mar 2002 16:05:41 -0000 1.2
@@ -23,6 +23,7 @@
#include <stdio.h>
#include "bashansi.h"
+#include <readline/rlconf.h>
#include <readline/readline.h>
#include <readline/history.h>
#include "shell.h"
@@ -116,6 +117,7 @@
#if defined (VI_MODE)
static void vi_edit_and_execute_command ();
+extern char *rl_vi_comment_begin;
#endif
static Function *old_rl_startup_hook = (Function *) NULL;
@@ -181,6 +183,10 @@
rl_unbind_key_in_map (CTRL('J'), emacs_meta_keymap);
rl_unbind_key_in_map (CTRL('M'), emacs_meta_keymap);
+#if defined (VI_MODE)
+ rl_unbind_key_in_map (CTRL('E'), vi_movement_keymap);
+#endif
+
#if defined (BRACE_COMPLETION)
rl_add_defun ("complete-into-braces", bash_brace_completion, -1);
rl_bind_key_in_map ('{', bash_brace_completion, emacs_meta_keymap);
@@ -264,6 +270,7 @@
{
tilde_initialize ();
rl_attempted_completion_function = attempt_shell_completion;
+ rl_completion_entry_function = (Function *)NULL;
rl_directory_completion_hook = bash_directory_completion_hook;
rl_ignore_some_completions_function = (Function *)filename_completion_ignore;
}
@@ -388,7 +395,11 @@
static void
initialize_hostname_list ()
{
- //char *temp = get_string_value ("hostname_completion_file");
+// char *temp;
+
+// temp = get_string_value ("HOSTFILE");
+// if (!temp)
+// temp = get_string_value ("hostname_completion_file");
//if (!temp)
// temp = ETCHOSTS;
@@ -396,6 +407,7 @@
//snarf_hosts_from_file (temp);
doEnumHosts(NULL);
sort_hostname_list ();
+
if (hostname_list)
hostname_list_initialized++;
}
@@ -1156,7 +1168,7 @@
int state;
char *text;
{
- char **matches = (char **)NULL;
+ static char **matches = (char **)NULL;
static char *orig_start, *filename_text = (char *)NULL;
static int cmd_index, start_len;
Index: braces.c
===================================================================
RCS file: /cvsroot/winbash/winbash/braces.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- braces.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ braces.c 9 Mar 2002 16:05:41 -0000 1.2
@@ -226,7 +226,7 @@
/* A backslash escapes the next character. This allows backslash to
escape the quote character in a double-quoted string. */
- if (c == '\\' && (quoted == '"' || quoted == '`'))
+ if (c == '\\' && (quoted == 0 || quoted == '"' || quoted == '`'))
{
pass_next = 1;
continue;
@@ -290,7 +290,7 @@
return (copy_array (arr2));
if (!arr2)
- return (arr1);
+ return (copy_array (arr1));
len1 = array_len (arr1);
len2 = array_len (arr2);
Index: error.c
===================================================================
RCS file: /cvsroot/winbash/winbash/error.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- error.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ error.c 9 Mar 2002 16:05:41 -0000 1.2
@@ -18,6 +18,7 @@
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
+#include <sys/types.h>
#include <fcntl.h>
#if defined (HAVE_VFPRINTF)
Index: execute_cmd.c
===================================================================
RCS file: /cvsroot/winbash/winbash/execute_cmd.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- execute_cmd.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ execute_cmd.c 9 Mar 2002 16:05:41 -0000 1.2
@@ -1117,8 +1117,11 @@
/* If we were explicitly placed in a subshell with (), we need
to do the `shell cleanup' things, such as running traps[0]. */
- if (user_subshell)
- run_exit_trap ();
+ if (user_subshell && signal_is_trapped (0))
+ {
+ thr_me->last_command_exit_value = return_code;
+ return_code = run_exit_trap ();
+ }
#if defined (_MT)
return return_code;
@@ -1169,7 +1172,7 @@
loop_level++;
identifier = for_command->name->word;
- list = releaser = expand_words (for_command->map_list);
+ list = releaser = expand_words_no_vars (for_command->map_list);
begin_unwind_frame ("for");
add_unwind_protect (dispose_words, releaser);
@@ -1253,6 +1256,8 @@
register WORD_LIST *l;
register int i;
+ if (list == 0)
+ return (0);
i = ind;
l = list;
while (l && --i)
@@ -1288,11 +1293,17 @@
int ind, row, elem_len, pos, cols, rows;
int first_column_indices_len, other_indices_len;
+ if (list == 0)
+ {
+ putc ('\n', stderr);
+ return;
+ }
+
cols = COLS / max_elem_len;
if (cols == 0)
cols = 1;
- rows = list_len / cols + (list_len % cols != 0);
- cols = list_len / rows + (list_len % rows != 0);
+ rows = list_len ? list_len / cols + (list_len % cols != 0) : 1;
+ cols = list_len ? list_len / rows + (list_len % rows != 0) : 1;
if (rows == 1)
{
@@ -1412,7 +1423,14 @@
/* command and arithmetic substitution, parameter and variable expansion,
word splitting, pathname expansion, and quote removal. */
- list = releaser = expand_words (select_command->map_list);
+ list = releaser = expand_words_no_vars (select_command->map_list);
+ list_len = list_length (list);
+ if (list == 0 || list_len == 0)
+ {
+ if (list)
+ dispose_words (list);
+ return (EXECUTION_SUCCESS);
+ }
begin_unwind_frame ("select");
add_unwind_protect (dispose_words, releaser);
@@ -1429,7 +1447,6 @@
if (select_command->flags & CMD_IGNORE_RETURN)
select_command->action->flags |= CMD_IGNORE_RETURN;
- list_len = list_length (list);
ps3_prompt = get_string_value ("PS3");
if (!ps3_prompt)
ps3_prompt = "#? ";
@@ -3586,15 +3603,17 @@
char *name;
int flags;
{
- char *path_list = (char *) NULL;
+ char *path_list;
SHELL_VAR *var;
/* Search for the value of PATH in both the temporary environment, and
in the regular list of variables. */
if (var = find_variable_internal ("PATH", 1))
path_list = value_cell (var);
+ else
+ path_list = (char *)NULL;
- if (!path_list)
+ if (path_list == 0 || *path_list == '\0')
return (savestring (name));
return (find_user_command_in_path (name, path_list, flags));
Index: expr.c
===================================================================
RCS file: /cvsroot/winbash/winbash/expr.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- expr.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ expr.c 9 Mar 2002 16:05:41 -0000 1.2
@@ -72,8 +72,11 @@
Here is a macro which accepts newlines, tabs and spaces as whitespace. */
#define cr_whitespace(c) (whitespace(c) || ((c) == '\n'))
+extern char *this_command_name;
+
static char *expression = (char *) NULL; /* The current expression */
static char *tp = (char *) NULL; /* token lexical position */
+static char *lasttp;
static int curtok = 0; /* the current token */
static int lasttok = 0; /* the previous token */
static int assigntok = 0; /* the OP in OP= */
@@ -655,7 +658,7 @@
if (c)
cp++;
- tp = cp - 1;
+ lasttp = tp = cp - 1;
if (c == '\0')
{
@@ -758,8 +761,16 @@
evalerror (msg)
char *msg;
{
- builtin_error ("%s: %s (remainder of expression is \"%s\")",
- expression, msg, (tp && *tp) ? tp : "");
+ char *name, *t;
+
+ name = this_command_name;
+ if (name == 0)
+ name = get_name_for_error ();
+ for (t = expression; whitespace (*t); t++)
+ ;
+ fprintf (stderr, "%s: %s%s: %s (remainder of expression is \"%s\")",
+ name, t,
+ msg, (lasttp && *lasttp) ? lasttp : "");
LONGJMP (evalbuf, 1);
}
Index: general.c
===================================================================
RCS file: /cvsroot/winbash/winbash/general.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- general.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ general.c 9 Mar 2002 16:05:41 -0000 1.2
@@ -215,6 +215,53 @@
return (neg ? -ret : ret);
}
+#if defined (RLIMTYPE)
+RLIMTYPE
+string_to_rlimtype (s)
+ char *s;
+{
+ RLIMTYPE ret = 0;
+ int neg = 0;
+
+ while (s && *s && whitespace (*s))
+ s++;
+ if (*s == '-' || *s == '+')
+ {
+ neg = *s == '-';
+ s++;
+ }
+ for ( ; s && *s && digit (*s); s++)
+ ret = (ret * 10) + digit_value (*s);
+ return (neg ? -ret : ret);
+}
+
+void
+print_rlimtype (n, addnl)
+ RLIMTYPE n;
+ int addnl;
+{
+ char s[sizeof (RLIMTYPE) * 3 + 1];
+ int len = sizeof (RLIMTYPE) * 3 + 1;
+
+ if (n == 0)
+ {
+ printf ("0%s", addnl ? "\n" : "");
+ return;
+ }
+
+ if (n < 0)
+ {
+ putchar ('-');
+ n = -n;
+ }
+
+ s[--len] = '\0';
+ for ( ; n != 0; n /= 10)
+ s[--len] = n % 10 + '0';
+ printf ("%s%s", s + len, addnl ? "\n" : "");
+}
+#endif /* RLIMTYPE */
+
/* Return 1 if this token is a legal shell `identifier'; that is, it consists
solely of letters, digits, and underscores, and does not begin with a
digit. */
Index: general.h
===================================================================
RCS file: /cvsroot/winbash/winbash/general.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- general.h 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ general.h 9 Mar 2002 16:05:41 -0000 1.2
@@ -63,6 +63,10 @@
#define digit_value(c) ((c) - '0')
#endif
+/* Definitions used in subst.c and by the `read' builtin for field
+ splitting. */
+#define spctabnl(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
+
#if !defined (__STDC__) && !defined (strchr)
extern char *strchr (), *strrchr ();
#endif /* !strchr */
@@ -111,7 +115,7 @@
#define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
/* More convenience definitions that possibly save system or libc calls. */
-#define STRLEN(s) ((s)[0] ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0)
+#define STRLEN(s) (((s) && (s)[0]) ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0)
#define FREE(s) do { if (s) free (s); } while (0)
#define MEMBER(c, s) (((c) && !(s)[1] && c == s[0]) || (member(c, s)))
@@ -206,6 +210,11 @@
#if !defined (strerror)
extern char *strerror __P((int));
+#endif
+
+#if defined (RLIMTYPE)
+extern RLIMTYPE string_to_rlimtype __P((char *));
+extern void print_rlimtype __P((RLIMTYPE, int));
#endif
#if !defined (HAVE_STRCASECMP)
Index: input.h
===================================================================
RCS file: /cvsroot/winbash/winbash/input.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- input.h 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ input.h 9 Mar 2002 16:05:41 -0000 1.2
@@ -33,11 +33,13 @@
#endif /* _FUNCTION_DEF */
/* Some stream `types'. */
+#define st_none 0
#define st_stream 1
#define st_string 2
+#define st_stdin 3
#if defined (BUFFERED_INPUT)
-#define st_bstream 3
+#define st_bstream 4
/* Possible values for b_flag. */
#define B_EOF 0x1
Index: jobs.c
===================================================================
RCS file: /cvsroot/winbash/winbash/jobs.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- jobs.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ jobs.c 9 Mar 2002 16:05:41 -0000 1.2
@@ -117,7 +117,7 @@
extern int interactive, interactive_shell, asynchronous_notification;
extern int subshell_environment;
extern int posixly_correct, no_symbolic_links, shell_level;
-extern int interrupt_immediately, last_command_exit_value;
+extern int interrupt_immediately;//, last_command_exit_value;
extern int loop_level, breaking;
extern Function *this_shell_builtin;
extern char *shell_name, *this_command_name;
@@ -320,6 +320,16 @@
}
}
+void
+cleanup_the_pipeline ()
+{
+ if (the_pipeline)
+ {
+ discard_pipeline (the_pipeline);
+ the_pipeline = (PROCESS *)NULL;
+ }
+}
+
/* Start building a pipeline. */
void
start_pipeline ()
@@ -1383,7 +1393,7 @@
if (interrupt_immediately ||
(this_shell_builtin && this_shell_builtin == wait_builtin))
{
- last_command_exit_value = EXECUTION_FAILURE;
+ thr_me->last_command_exit_value = EXECUTION_FAILURE;
restore_sigint_handler ();
interrupt_state++;
QUIT;
@@ -1435,7 +1445,7 @@
if (!job_control)
old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
- termination_state = last_command_exit_value;
+ termination_state = thr_me->last_command_exit_value;
/* If we say wait_for (), then we have a record of this child somewhere.
If this child and all of its peers are not running, then don't
@@ -1486,34 +1496,31 @@
}
}
+ /* XXX - the linux people say to check for JOBSTATE (job) == JSTOPPED */
if (child->running || ((job != NO_JOB) && (JOBSTATE (job) == JRUNNING)))
{
-#if defined (WAITPID_BROKEN) /* SCOv4 */
- sigset_t suspend_set;
- sigemptyset (&suspend_set);
- sigsuspend (&suspend_set);
-#else /* !WAITPID_BROKEN */
-# if defined (MUST_UNBLOCK_CHILD) /* SCO */
+#if defined (_POSIX_VERSION)
struct sigaction act, oact;
- sigset_t nullset, chldset;
- sigemptyset (&nullset);
- sigemptyset (&chldset);
- sigprocmask (SIG_SETMASK, &nullset, &chldset);
act.sa_handler = SIG_DFL;
sigemptyset (&act.sa_mask);
- sigemptyset (&oact.sa_mask);
act.sa_flags = 0;
+
sigaction (SIGCHLD, &act, &oact);
-# endif
- waiting_for_job = 1;
- waitchld (0);
- waiting_for_job = 0;
-# if defined (MUST_UNBLOCK_CHILD)
+#else
+ SigHandler *ihandler;
+
+ ihandler = set_signal_handler (SIGCHLD, SIG_DFL);
+#endif /* !_POSIX_VERSION */
+
+ flush_child (0);
+
+#if defined (_POSIX_VERSION)
sigaction (SIGCHLD, &oact, (struct sigaction *)NULL);
- sigprocmask (SIG_SETMASK, &chldset, (sigset_t *)NULL);
-# endif
-#endif /* !WAITPID_BROKEN */
+#else
+ set_signal_handler (SIGCHLD, ihandler);
+#endif /* !_POSIX_VERSION */
+
goto wait_loop;
}
@@ -1573,6 +1580,19 @@
}
}
+ /* If job control is enabled, the job was started with job
+ control, the job was the foreground job, and it was killed
+ by SIGINT, then print a newline to compensate for the kernel
+ printing the ^C without a trailing newline. */
+ if (job_control && (jobs[job]->flags & J_JOBCONTROL) &&
+ (jobs[job]->flags & J_FOREGROUND) &&
+ WIFSIGNALED (child->status) &&
+ WTERMSIG (child->status) == SIGINT)
+ {
+ putchar ('\n');
+ fflush (stdout);
+ }
+
notify_and_cleanup ();
}
else
@@ -2023,6 +2043,7 @@
{
WAIT status;
PROCESS *child;
+ int any_tstped = 0;
pid_t pid;
int call_set_current = 0, last_stopped_job = NO_JOB;
int children_exited = 0, flag;
@@ -2122,7 +2143,7 @@
/* If SIGINT is trapped, set the exit status so
that the trap handler can see it. */
if (signal_is_trapped (SIGINT))
- last_command_exit_value = process_exit_status
+ thr_me->last_command_exit_value = process_exit_status
(jobs[job]->pipe->status);
/* If the signal is trapped, let the trap handler
@@ -2156,7 +2177,7 @@
children_exited++;
}
}
- while ((s || sigchld) && pid > (pid_t)0);
+ while (sig && pid > (pid_t)0);
/* If a job was running and became stopped, then set the current
job. Otherwise, don't change a thing. */
@@ -2179,7 +2200,7 @@
trap_command = savestring (trap_list[SIGCHLD]);
begin_unwind_frame ("SIGCHLD trap");
- unwind_protect_int (last_command_exit_value);
+ unwind_protect_int (thr_me->last_command_exit_value);
unwind_protect_int (last_made_pid);
unwind_protect_int (interrupt_immediately);
unwind_protect_int (freeze_jobs_list);
Index: jobs.h
===================================================================
RCS file: /cvsroot/winbash/winbash/jobs.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- jobs.h 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ jobs.h 9 Mar 2002 16:05:42 -0000 1.2
@@ -282,9 +282,9 @@
#endif /* !_POSIX_VERSION */
/* System calls. */
-#if !defined (Solaris) && !defined (USGr4_2) && !defined (__BSD_4_4__)
+#if !defined (SunOS5) && !defined (USGr4_2) && !defined (__BSD_4_4__)
extern pid_t fork (), getpid (), getpgrp ();
-#endif /* !Solaris && !USGr4_2 */
+#endif /* !SunOS5 && !USGr4_2 && !__BSD_4_4__ */
/* Stuff from the jobs.c file. */
extern pid_t original_pgrp, shell_pgrp, pipeline_pgrp;
@@ -295,6 +295,7 @@
extern void making_children __P((void));
extern void stop_making_children __P((void));
+extern void cleanup_the_pipeline __P((void));
extern void start_pipeline __P((void));
extern int stop_pipeline __P((int, COMMAND *));
extern void delete_job __P((int));
Index: machines.h
===================================================================
RCS file: /cvsroot/winbash/winbash/machines.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- machines.h 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ machines.h 9 Mar 2002 16:05:42 -0000 1.2
@@ -31,11 +31,11 @@
various machine specific entries. */
/* If this file is being processed with Gcc, then the user has Gcc. */
-#if defined (__GNUC__) && !defined (NeXT)
+#if defined (__GNUC__) && !defined (NeXT) && !defined (__FreeBSD__)
# if !defined (HAVE_GCC)
# define HAVE_GCC
# endif /* HAVE_GCC */
-#endif /* __GNUC__ && !NeXT */
+#endif /* __GNUC__ && !NeXT && !__FreeBSD__ */
/* Assume that all machines have the getwd () system call. We unset it
for USG systems. */
@@ -85,7 +85,8 @@
#if defined (sparc) && defined (__NetBSD__)
# define M_MACHINE "sun4"
# define M_OS "NetBSD"
-# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY
+# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY \
+ -DRLIMTYPE=quad_t
# define SYSDEP_LDFLAGS -static
# define HAVE_SYS_SIGLIST
# define HAVE_SETLINEBUF
@@ -205,7 +206,8 @@
# else /* !MIPSEL */
# define M_MACHINE "vax"
# endif /* !MIPSEL */
-# define SYSDEP_CFLAGS -DBSD_GETPGRP -DTERMIOS_MISSING -DTERMIOS_LDISC
+# define SYSDEP_CFLAGS -DBSD_GETPGRP -DTERMIOS_MISSING -DTERMIOS_LDISC \
+ -DINT_GROUPS_ARRAY
# define M_OS "Ultrix"
# define HAVE_DIRENT
# define VOID_SIGHANDLER
@@ -584,6 +586,7 @@
# define HAVE_RESOURCE
# endif
# define HAVE_STRCASECMP
+# define GCC_STANDARD
# undef HAVE_GETWD
# undef HAVE_GETCWD
# undef USE_GNU_MALLOC
@@ -676,7 +679,11 @@
# endif /* __STDC__ */
# define SYSDEP_CFLAGS ISC_SYSDEPS ISC_POSIX ISC_EXTRA
# undef HAVE_GETWD
-# undef HAVE_GETCWD
+# if !defined (ISC_4)
+# undef HAVE_GETCWD
+# else
+# undef HAVE_RESOURCE
+# endif /* ISC_4 */
# endif /* isc386 */
/* Xenix386 machine (with help from Ronald Khoo <ro...@ro...>). */
@@ -716,11 +723,11 @@
# define done386
# define M_MACHINE "i386"
# define M_OS "SCO"
-# define SCO_CFLAGS -DUSG -DUSGr3 -DNO_DEV_TTY_JOB_CONTROL -DPGRP_PIPE
+# define SCO_CFLAGS -DUSG -DUSGr3 -DPGRP_PIPE
# if defined (SCOv4)
# define SYSDEP_CFLAGS SCO_CFLAGS
# else /* !SCOv4 */
-# define SYSDEP_CFLAGS SCO_CFLAGS -DBROKEN_SIGSUSPEND -DOPENDIR_NOT_ROBUST
+# define SYSDEP_CFLAGS SCO_CFLAGS -DOPENDIR_NOT_ROBUST
# endif /* !SCOv4 */
# define HAVE_VFPRINTF
# define VOID_SIGHANDLER
@@ -772,7 +779,8 @@
# define done386
# define M_MACHINE "i386"
# define M_OS "NetBSD"
-# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY
+# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY \
+ -DRLIMTYPE=quad_t
# define HAVE_SYS_SIGLIST
# define HAVE_SETLINEBUF
# define HAVE_GETGROUPS
@@ -788,7 +796,11 @@
# define done386
# define M_MACHINE "i386"
# define M_OS "FreeBSD"
-# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY
+# if __FreeBSD__ > 1
+# define SYSDEP_CFLAGS -D__BSD_4_4__ -DRLIMTYPE=quad_t
+# else
+# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY
+# endif
# define HAVE_SYS_SIGLIST
# define HAVE_SETLINEBUF
# define HAVE_GETGROUPS
@@ -797,6 +809,7 @@
# define VOID_SIGHANDLER
# define HAVE_DIRENT
# define HAVE_STRCASECMP
+# define GCC_STANDARD
# endif /* !done386 && __FreeBSD__ */
/* Jolitz 386BSD running on a 386 or 486. */
@@ -993,6 +1006,7 @@
# define HAVE_RESOURCE
# endif
# define HAVE_STRCASECMP
+# define GCC_STANDARD
# undef HAVE_GETWD
# undef HAVE_GETCWD
# undef HAVE_DIRENT_H
@@ -1010,7 +1024,8 @@
# define M_MACHINE MACHINE
# define M_OS "NetBSD"
/* os/netbsd.h */
-# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY
+# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY \
+ -DRLIMTYPE=quad_t
# define HAVE_SYS_SIGLIST
# define HAVE_SETLINEBUF
# define HAVE_GETGROUPS
@@ -1018,6 +1033,7 @@
# define HAVE_STRERROR
# define VOID_SIGHANDLER
# define HAVE_DIRENT
+# define HAVE_STRCASECMP
#endif /* m68k && __NetBSD__ */
/* ************************ */
@@ -1096,7 +1112,7 @@
# else /* !HPUX_USG */
/* All of the other operating systems need HPUX to be defined. */
-# define HPUX_EXTRA -DHPUX -DHAVE_GETHOSTNAME -DUSG
+# define HPUX_EXTRA -DHPUX -Dhpux -DHAVE_GETHOSTNAME -DUSG
/* HPUX 6.2 .. 6.5 require -lBSD for getwd (), and -lPW for alloca (). */
# if defined (HPUX_6)
@@ -1122,10 +1138,13 @@
# define M_OS "hpux_8"
# if !defined (__GNUC__)
# undef HAVE_ALLOCA
+# define HPUX_ANSI +O3 -Aa -D_HPUX_SOURCE
+# else
+# define HPUX_ANSI
# endif
# undef HAVE_GETWD
# undef USE_GNU_MALLOC
-# define HPUX_CFLAGS -DNO_SBRK_DECL -DHAVE_SOCKETS
+# define HPUX_CFLAGS -DNO_SBRK_DECL -DHAVE_SOCKETS HPUX_ANSI
# endif /* HPUX_8 */
/* HP-UX 9.0 reportedly fixes the alloca problems present in the 8.0
@@ -1134,11 +1153,14 @@
# define M_OS "hpux_9"
# if !defined (__GNUC__)
# undef HAVE_ALLOCA
+# define HPUX_ANSI +O3 -Ae
+# else
+# define HPUX_ANSI
# endif
# undef HAVE_GETWD
# undef USE_GNU_MALLOC
# undef HAVE_RESOURCE
-# define HPUX_CFLAGS -DNO_SBRK_DECL -DHAVE_SOCKETS -DHAVE_GETHOSTNAME
+# define HPUX_CFLAGS -DNO_SBRK_DECL -DHAVE_SOCKETS -DHAVE_GETHOSTNAME HPUX_ANSI
# endif /* HPUX_9 */
# endif /* !HPUX_USG */
@@ -1568,10 +1590,25 @@
/* ******************************************** */
/* */
-/* System V Release 4 on the Commodore Amiga */
+/* Commodore Amiga */
/* */
/* ******************************************** */
-#if defined (amiga)
+#if defined (amiga) && defined (__NetBSD__)
+# define M_MACHINE "amiga"
+# define M_OS "NetBSD"
+# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY \
+ -DRLIMTYPE=quad_t
+# define HAVE_SYS_SIGLIST
+# define HAVE_SETLINEBUF
+# define HAVE_GETGROUPS
+# define HAVE_VFPRINTF
+# define HAVE_STRERROR
+# define VOID_SIGHANDLER
+# define HAVE_DIRENT
+# define HAVE_STRCASECMP
+#endif /* amiga && __NetBSD__ */
+
+#if defined (amiga) && !defined (M_MACHINE)
# define M_MACHINE "amiga"
# define M_OS "USG"
# define SYSDEP_CFLAGS -DUSGr4
@@ -1883,6 +1920,7 @@
/* */
/* ************************ */
#if defined (cray)
+# include <sys/param.h>
# if defined (Cray1) || defined (Cray2)
# define M_MACHINE "Cray"
# define CRAY_STACK
@@ -1894,7 +1932,7 @@
# if defined (CrayYMP) && !defined (M_MACHINE)
# define M_MACHINE "CrayYMP"
# if RELEASE_LEVEL >= 7000
-# define CRAY_STACK -DCRAY_STACKSEG_END=GETB67
+# define CRAY_STACK -DCRAY_STACKSEG_END=_getb67
# else
# define CRAY_STACK -DCRAY_STACKSEG_END=getb67
# endif /* RELEASE_LEVEL < 7000 */
@@ -1904,7 +1942,8 @@
# define CRAY_STACK
# endif
# define M_OS "Unicos"
-# define SYSDEP_CFLAGS -DUSG -DPGRP_PIPE -DOPENDIR_NOT_ROBUST CRAY_STACK
+# define SYSDEP_CFLAGS -DUSG -DPGRP_PIPE -DOPENDIR_NOT_ROBUST \
+ -DHAVE_BCOPY CRAY_STACK
# define HAVE_VFPRINTF
# define HAVE_MULTIPLE_GROUPS
# define VOID_SIGHANDLER
@@ -2093,8 +2132,6 @@
AFS - The Andrew File System is being used
AFS_CREATE_BUG - AFS has a bug with file creation if O_CREAT is
specified
- BROKEN_SIGSUSPEND - sigsuspend(2) does not work to wake up processes
- on SIGCHLD
BSD_GETPGRP - getpgrp(2) takes a pid argument, a la 4.3 BSD
HAVE_BCOPY - bcopy(3) exists and works as in BSD
HAVE_GETDTABLESIZE - getdtablesize(2) exists and works correctly
@@ -2111,7 +2148,6 @@
of integers
MEMMOVE_MISSING - the system does not have memmove(3)
MKFIFO_MISSING - named pipes do not work or mkfifo(3) is missing
- NO_DEV_TTY_JOB_CONTROL - system can't do job control on /dev/tty
NO_SBRK_DECL - don't declare sbrk as extern char *sbrk() in
lib/malloc/malloc.c
OPENDIR_NOT_ROBUST - opendir(3) allows you to open non-directory files
@@ -2176,6 +2212,10 @@
if it cannot grok the -l<lib> flag, or both. */
/* # define LD_HAS_NO_DASH_L */
+/* Define GCC_STANDARD if the standard `cc' is gcc and you don't want
+ to use the compiler named `gcc' for some reason. */
+/* # define GCC_STANDARD */
+
# if defined (LD_HAS_NO_DASH_L)
# undef SEARCH_LIB_NEEDS_SPACE
# endif /* LD_HAS_NO_DASH_L */
Index: newversion.c
===================================================================
RCS file: /cvsroot/winbash/winbash/newversion.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- newversion.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ newversion.c 9 Mar 2002 16:05:42 -0000 1.2
@@ -21,7 +21,7 @@
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <sys/types.h>
-#include <sys/stat.h>
+#include "posixstat.h"
#include <stdio.h>
char *progname;
Index: parse.y
===================================================================
RCS file: /cvsroot/winbash/winbash/parse.y,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- parse.y 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ parse.y 9 Mar 2002 16:05:42 -0000 1.2
@@ -821,16 +821,22 @@
give_terminal_to (shell_pgrp);
#endif /* JOB_CONTROL */
- old_sigint = (SigHandler *)set_signal_handler (SIGINT, sigint_sighandler);
- interrupt_immediately++;
+ if (signal_is_ignored (SIGINT) == 0)
+ {
+ old_sigint = (SigHandler *)set_signal_handler (SIGINT, sigint_sighandler);
+ interrupt_immediately++;
+ }
if (!current_readline_prompt)
current_readline_line = readline ("");
else
current_readline_line = readline (current_readline_prompt);
- interrupt_immediately--;
- set_signal_handler (SIGINT, old_sigint);
+ if (signal_is_ignored (SIGINT) == 0)
+ {
+ interrupt_immediately--;
+ set_signal_handler (SIGINT, old_sigint);
+ }
/* Reset the prompt to whatever is in the decoded value of
prompt_string_pointer. */
@@ -873,9 +879,12 @@
{
INPUT_STREAM location;
- location.string = current_readline_line;
- init_yy_io (yy_readline_get, yy_readline_unget,
- st_string, "readline stdin", location);
+ if (bash_input.type != st_stdin && stream_on_stack (st_stdin) == 0)
+ {
+ location.string = current_readline_line;
+ init_yy_io (yy_readline_get, yy_readline_unget,
+ st_stdin, "readline stdin", location);
+ }
}
#else /* !READLINE */
@@ -1051,6 +1060,20 @@
free (saver);
}
}
+
+/* Return 1 if a stream of type TYPE is saved on the stack. */
+int
+stream_on_stack (type)
+ int type;
+{
+ register STREAM_SAVER *s;
+
+ for (s = stream_list; s; s = s->next)
+ if (s->bash_input.type == type)
+ return 1;
+ return 0;
+}
+
/*
* This is used to inhibit alias expansion and reserved word recognition
@@ -1264,9 +1287,9 @@
/* `+2' in case the final character in the buffer is a newline. */
if (indx + 2 > buffer_size)
if (!buffer_size)
- line_buffer = xmalloc (buffer_size = 400);
+ line_buffer = xmalloc (buffer_size = 128);
else
- line_buffer = xrealloc (line_buffer, buffer_size += 400);
+ line_buffer = xrealloc (line_buffer, buffer_size += 128);
/* IF REMOVE_QUOTED_NEWLINES is non-zero, we are reading a
here document with an unquoted delimiter. In this case,
@@ -1397,9 +1420,9 @@
#endif /* !JOB_CONTROL */
#if defined (READLINE)
- if (thr_me->interactive && thr_me->no_line_editing)
+ if (thr_me->interactive && bash_input.type != st_string && thr_me->no_line_editing)
#else
- if (thr_me->interactive)
+ if (thr_me->interactive && bash_input.type != st_string)
#endif
print_prompt ();
@@ -1529,7 +1552,7 @@
return (EOF);
}
- return (c);
+ return ((unsigned char)c);
}
/* Put C back into the input for the shell. */
@@ -2615,12 +2638,25 @@
octal_string[3] = '\0';
n = read_octal (octal_string);
+ temp = xmalloc (3);
- temp = savestring ("\\");
- if (n != -1)
+ if (n == CTLESC || n == CTLNUL)
+ {
+ string += 3;
+ temp[0] = CTLESC;
+ temp[1] = n;
+ temp[2] = '\0';
+ }
+ else if (n == -1)
+ {
+ temp[0] = '\\';
+ temp[1] = '\0';
+ }
+ else
{
string += 3;
temp[0] = n;
+ temp[1] = '\0';
}
c = 0;
@@ -2767,7 +2803,7 @@
/* Perform variable and parameter expansion and command substitution on
the prompt string. */
- list = expand_string (result, 1);
+ list = expand_string_unsplit (result, 1);
free (result);
result = string_list (list);
dispose_words (list);
Index: shell.c
===================================================================
RCS file: /cvsroot/winbash/winbash/shell.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- shell.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ shell.c 9 Mar 2002 16:05:42 -0000 1.2
@@ -78,7 +78,7 @@
extern char *dist_version;
extern int patch_level, build_version;
-extern int last_command_exit_value;
+//extern int last_command_exit_value;
extern int return_catch_flag;
extern jmp_buf return_catch;
extern int need_here_doc, current_command_line_count, line_number;
@@ -815,7 +815,8 @@
exit_shell:
/* Do trap[0] if defined. */
- run_exit_trap ();
+ if (signal_is_trapped (0))
+ thr_me->last_command_exit_value = run_exit_trap ();
#if defined (PROCESS_SUBSTITUTION)
unlink_fifo_list ();
@@ -874,7 +875,8 @@
{
/* We don't execute .bashrc for login shells. */
no_rc++;
- maybe_execute_file (SYS_PROFILE, 1);
+ if (no_profile == 0)
+ maybe_execute_file (SYS_PROFILE, 1);
}
if (thr_me->login_shell && !no_profile)
@@ -918,7 +920,7 @@
/* Try a TMB suggestion. If running a script, then execute the
file mentioned in the ENV variable. */
- if (!privileged_mode && sourced_env++ == 0 &&
+ if (!privileged_mode && sourced_env++ == 0 && act_like_sh == 0 &&
(posixly_correct || !thr_me->interactive_shell))
{
char *env_file = (char *)NULL;
@@ -1079,8 +1081,9 @@
/* Some kind of throw to top_level has occured. */
case FORCE_EOF:
case EXITPROG:
+ return last_command_exit_value = 127;
case DISCARD:
- return 0;
+ return last_command_exit_value = 1;
default:
programming_error ("Bad jump %d", code);
}
@@ -1106,7 +1109,7 @@
unlink_fifo_list ();
#endif /* PROCESS_SUBSTITUTION */
- if (thr_me->interactive_shell)
+ if (thr_me->interactive_shell && signal_is_ignored (SIGINT) == 0)
set_signal_handler (SIGINT, sigint_sighandler);
if (code != NOT_JUMPED)
@@ -1129,6 +1132,7 @@
dispose_command (current_command);
current_command = (COMMAND *)NULL;
}
+ thr_me->last_command_exit_value = 1;
break;
default:
@@ -1229,7 +1233,7 @@
/* 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 (thr_me->interactive)
+ if (thr_me->interactive && bash_input.type != st_string)
{
char *command_to_execute;
@@ -1437,6 +1441,13 @@
#endif
}
+void
+reinitialize_signals ()
+{
+ initialize_terminating_signals ();
+ initialize_job_signals ();
+}
+
/* A structure describing a signal that terminates the shell if not
caught. The orig_handler member is present so children can reset
these signals back to their original handlers. */
@@ -1555,7 +1566,7 @@
#endif /* HISTORY */
#if defined (JOB_CONTROL)
- if (thr_me->interactive && thr_me->login_shell && sig == SIGHUP)
+ if (thr_me->interactive && sig == SIGHUP)
hangup_all_jobs ();
end_job_control ();
#endif /* JOB_CONTROL */
Index: siglist.h
===================================================================
RCS file: /cvsroot/winbash/winbash/siglist.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- siglist.h 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ siglist.h 9 Mar 2002 16:05:42 -0000 1.2
@@ -33,8 +33,8 @@
extern char *sys_siglist[];
#endif /* !Solaris && !Linux && !__BSD_4_4__ && !Minix && !NetBSD && !FreeBSD */
-#if !defined (strsignal) && !defined (Solaris)
+#if !defined (strsignal) && !defined (Solaris) && !defined (NetBSD)
# define strsignal(sig) (char *)sys_siglist[sig]
-#endif /* !strsignal */
+#endif /* !strsignal && !Solaris && !NetBSD */
#endif /* _SIGLIST_H */
Index: subst.c
===================================================================
RCS file: /cvsroot/winbash/winbash/subst.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- subst.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ subst.c 9 Mar 2002 16:05:42 -0000 1.2
@@ -1966,6 +1966,7 @@
#if defined (JOB_CONTROL)
old_pipeline_pgrp = pipeline_pgrp;
pipeline_pgrp = shell_pgrp;
+ cleanup_the_pipeline ();
pid = make_child ((char *) NULL, 1);
if (pid == 0)
{
@@ -1988,8 +1989,6 @@
}
#endif /* !JOB_CONTROL */
- set_sigint_handler ();
-
if (pid < 0)
{
internal_error ("cannot make a child for process substitution: %s",
@@ -2017,6 +2016,8 @@
return (pathname);
}
+ set_sigint_handler ();
+
#if defined (JOB_CONTROL)
set_job_control (0);
#endif /* JOB_CONTROL */
@@ -2111,6 +2112,7 @@
pid_t old_pipeline_pgrp = pipeline_pgrp;
pipeline_pgrp = shell_pgrp;
+ cleanup_the_pipeline ();
pid = make_child ((char *) NULL, 0);
if (pid == 0)
/* Reset the signal handlers in the child, but don't free the
@@ -2149,6 +2151,7 @@
if (pid == 0)
{
+ set_sigint_handler (); /* XXX */
# if defined (JOB_CONTROL)
set_job_control (0);
# endif
@@ -2183,6 +2186,9 @@
remove_quoted_escapes (string);
+ /* Command substitution does not inherit the -e flag. */
+ exit_immediately_on_error = 0;
+
/* Give command substitution a place to jump back to on failure,
so we don't go back up to main (). */
result = SETJMP (top_level);
@@ -2454,11 +2460,16 @@
else
temp = savestring (value);
- l = expand_string_leave_quoted (temp, quoted);
+ l = *temp ? expand_string_internal (temp, 0) : (WORD_LIST *)NULL;
free (temp);
- temp = string_list (l);
- dispose_words (l);
+ if (l)
+ {
+ temp = string_list (l);
+ dispose_words (l);
+ }
+ else
+ temp = (char *)NULL;
if (c == '-' || c == '+')
return (temp);
@@ -3080,7 +3091,7 @@
}
else if (c != '+')
temp = parameter_brace_expand_rhs
- (name, value, c, 0); /* XXX was quoted, not 0 */
+ (name, value, c, quoted);
free (value);
}
break;
@@ -3534,10 +3545,11 @@
temp_list = list_string (istring, " ", 1);
else
{
- temp_list = make_word_list
- (make_word (istring), (WORD_LIST *) NULL);
- temp_list->word->quoted =
- (quoted || (quoted_state == WHOLLY_QUOTED));
+ WORD_DESC *tword;
+ tword = make_word (istring);
+ temp_list = make_word_list (tword, (WORD_LIST *)NULL);
+ tword->quoted = quoted || (quoted_state == WHOLLY_QUOTED);
+ tword->assignment = word->assignment;
}
}
@@ -3597,15 +3609,11 @@
temp = string_extract_double_quoted (string, &tindex);
sindex = tindex;
- temp1 = string_quote_removal (temp, 1); /* XXX is this needed? */
-
- FREE (temp);
-
- if (temp1)
+ if (temp)
{
- strcpy (r, temp1);
+ strcpy (r, temp);
r += strlen (r);
- free (temp1);
+ free (temp);
}
break;
@@ -3967,7 +3975,10 @@
This does all of the substitutions: brace expansion, tilde expansion,
parameter expansion, command substitution, arithmetic expansion,
- process substitution, word splitting, and pathname expansion. */
+ process substitution, word splitting, and pathname expansion.
+ Words with the `quoted' or `assignment' bits set, or for which no
+ expansion is done, do not undergo word splitting. Words with the
+ `assignment' but set do not undergo pathname expansion. */
static WORD_LIST *
expand_words_internal (list, do_vars)
WORD_LIST *list;
@@ -4103,7 +4114,9 @@
LONGJMP (top_level, FORCE_EOF);
}
- if (expanded_something)
+ /* Don't split assignment words, even when they do not precede a
+ command name. */
+ if (expanded_something && tlist->word->assignment == 0)
{
t = word_list_split (expanded);
dispose_words (expanded);
@@ -4169,7 +4182,7 @@
/* If the word isn't quoted and there is an unquoted pattern
matching character in the word, then glob it. */
- if (!tlist->word->quoted &&
+ if (!tlist->word->quoted && !tlist->word->assignment &&
unquoted_glob_pattern_p (tlist->word->word))
{
temp_list = shell_glob_filename (tlist->word->word);
Index: test.c
===================================================================
RCS file: /cvsroot/winbash/winbash/test.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- test.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ test.c 9 Mar 2002 16:05:42 -0000 1.2
@@ -469,8 +469,10 @@
{
advance (1);
value = expr ();
- if (argv[pos][0] != ')' || argv[pos][1])
- test_syntax_error ("')' expected, found %s\n", argv[pos]);
+ if (argv[pos] == 0)
+ test_syntax_error ("`)' expected\n");
+ else if (argv[pos][0] != ')' || argv[pos][1])
+ test_syntax_error ("`)' expected, found %s\n", argv[pos]);
advance (0);
return (TRUE == (value));
}
Index: trap.c
===================================================================
RCS file: /cvsroot/winbash/winbash/trap.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- trap.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ trap.c 9 Mar 2002 16:05:42 -0000 1.2
@@ -42,6 +42,9 @@
#define SIG_HARD_IGNORE 0x2 /* Signal was ignored on shell entry. */
#define SIG_SPECIAL 0x4 /* Treat this signal specially. */
#define SIG_NO_TRAP 0x8 /* Signal cannot be trapped. */
+#define SIG_INPROGRESS 0x10 /* Signal handler currently executing. */
+#define SIG_CHANGED 0x20 /* Trap value changed in trap handler. */
+#define SIG_IGNORED 0x40 /* The signal is currently being ignored. */
/* An array of such flags, one for each signal, describing what the
shell will do with a signal. */
@@ -117,13 +120,13 @@
/* Return the print name of this signal. */
char *
-signal_name (signal)
- int signal;
+signal_name (sig)
+ int sig;
{
- if (signal >= NSIG)
+ if (sig >= NSIG || sig < 0)
return ("bad signal number");
else
- return (signal_names[signal]);
+ return (signal_names[sig]);
}
/* Turn a string into a signal number, or a number into
@@ -174,7 +177,7 @@
/* Preserve $? when running trap. */
old_exit_value = thr_me->last_command_exit_value;
- for (sig = 0; sig < NSIG; sig++)
+ for (sig = 1; sig < NSIG; sig++)
{
/* XXX this could be made into a counter by using
while (pending_traps[sig]--) instead of the if statement. */
@@ -288,17 +291,15 @@
if (sigmodes[SIGINT] & SIG_HARD_IGNORE)
return ((SigHandler *)SIG_IGN);
- if (sigmodes[SIGINT] & SIG_TRAPPED)
- {
- if (trap_list[SIGINT] == (char *)IGNORE_SIG)
- return ((SigHandler *)SIG_IGN);
- else
- return ((SigHandler *)set_signal_handler (SIGINT, trap_handler));
- }
+ else if (sigmodes[SIGINT] & SIG_IGNORED)
+ return ((SigHandler *)set_signal_handler (SIGINT, SIG_IGN));
+
+ else if (sigmodes[SIGINT] & SIG_TRAPPED)
+ return ((SigHandler *)set_signal_handler (SIGINT, trap_handler));
/* The signal is not trapped, so set the handler to the shell's special
interrupt handler. */
- if (thr_me->interactive) /* XXX - was interactive_shell */
+ else if (thr_me->interactive) /* XXX - was interactive_shell */
return (set_signal_handler (SIGINT, sigint_sighandler));
else
return (set_signal_handler (SIGINT, termination_unwind_protect));
@@ -348,26 +349,39 @@
change_signal (sig, savestring (string));
}
-/* If SIG has a string assigned to it, get rid of it. Then give it
- VALUE. */
static void
-change_signal (sig, value)
+free_trap_command (sig)
int sig;
- char *value;
{
if ((sigmodes[sig] & SIG_TRAPPED) && trap_list[sig] &&
(trap_list[sig] != (char *)IGNORE_SIG) &&
(trap_list[sig] != (char *)DEFAULT_SIG) &&
(trap_list[sig] != (char *)IMPOSSIBLE_TRAP_HANDLER))
free (trap_list[sig]);
-
+}
+
+/* If SIG has a string assigned to it, get rid of it. Then give it
+ VALUE. */
+static void
+change_signal (sig, value)
+ int sig;
+ char *value;
+{
+ free_trap_command (sig);
trap_list[sig] = value;
+
sigmodes[sig] |= SIG_TRAPPED;
+ if (value == (char *)IGNORE_SIG)
+ sigmodes[sig] |= SIG_IGNORED;
+ else
+ sigmodes[sig] &= ~SIG_IGNORED;
+ if (sigmodes[sig] & SIG_INPROGRESS)
+ sigmodes[sig] |= SIG_CHANGED;
}
#define GET_ORIGINAL_SIGNAL(sig) \
- if (original_signals[sig] == IMPOSSIBLE_TRAP_HANDLER) \
- get_original_signal (sig)
+ if (sig && sig < NSIG && original_signals[sig] == IMPOSSIBLE_TRAP_HANDLER) \
+ get_original_signal (sig)
static void
get_original_signal (sig)
@@ -394,6 +408,14 @@
restore_default_signal (sig)
int sig;
{
+ if (sig == 0)
+ {
+ free_trap_command (sig);
+ trap_list[sig] = (char *)NULL;
+ sigmodes[sig] &= ~SIG_TRAPPED;
+ return;
+ }
+
GET_ORIGINAL_SIGNAL (sig);
/* A signal ignored on entry to the shell cannot be trapped or reset, but
@@ -444,24 +466,26 @@
/* Handle the calling of "trap 0". The only sticky situation is when
the command to be executed includes an "exit". This is why we have
to provide our own place for top_level to jump to. */
-void
+int
run_exit_trap ()
{
/* Run the trap only if signal 0 is trapped and not ignored. */
- if ((sigmodes[0] & SIG_TRAPPED) && (trap_list[0] != (char *)IGNORE_SIG))
+ if ((sigmodes[0] & SIG_TRAPPED) &&
+ (trap_list[0] != (char *)IGNORE_SIG) &&
+ (sigmodes[0] & SIG_INPROGRESS) == 0)
{
- char *trap_command = savestring (trap_list[0]);
- int code, old_exit_value;
-
- old_exit_value = thr_me->last_command_exit_value;
- change_signal (0, (char *)NULL);
+ char *trap_command;
+ int code;
+
+ trap_command= savestring (trap_list[0]);
+ sigmodes[0] &= ~SIG_TRAPPED;
+ sigmodes[0] |= SIG_INPROGRESS;
code = SETJMP(top_level);
if (code == 0)
parse_and_execute (trap_command, "trap", 0);
-
- thr_me->last_command_exit_value = old_exit_value;
}
+ return (thr_me->last_command_exit_value);
}
/* Set the handler signal SIG to the original and free any trap
@@ -512,7 +536,7 @@
{
register int i;
- for (i = 0; i < NSIG; i++)
+ for (i = 1; i < NSIG; i++)
{
if (sigmodes[i] & SIG_SPECIAL)
reset_signal (i);
@@ -535,7 +559,7 @@
register int i;
reset_terminating_signals (); /* in shell.c */
- for (i = 0; i < NSIG; i++)
+ for (i = 1; i < NSIG; i++)
{
if (sigmodes[i] & SIG_SPECIAL)
restore_signal (i);
@@ -561,21 +585,26 @@
we are not currently running in the interrupt trap handler. */
if ((sigmodes[SIGINT] & SIG_TRAPPED) &&
(trap_list[SIGINT] != (char *)IGNORE_SIG) &&
- (trap_list[SIGINT] != (char *)IMPOSSIBLE_TRAP_HANDLER))
+ (trap_list[SIGINT] != (char *)IMPOSSIBLE_TRAP_HANDLER) &&
+ ((sigmodes[SIGINT] & SIG_INPROGRESS) == 0))
{
- command = savestring (trap_list[SIGINT]);
-
- old_exit_value = thr_me->last_command_exit_value;
saved_command = trap_list[SIGINT];
+ sigmodes[SIGINT] |= SIG_INPROGRESS;
+ sigmodes[SIGINT] &= ~SIG_CHANGED;
- trap_list[SIGINT] = (char *)IMPOSSIBLE_TRAP_HANDLER;
+ command = savestring (saved_command);
+ old_exit_value = thr_me->last_command_exit_value;
parse_and_execute (command, "interrupt trap", 0);
-
- if (trap_list[SIGINT] == (char *)IMPOSSIBLE_TRAP_HANDLER)
- trap_list[SIGINT] = saved_command;
-
thr_me->last_command_exit_value = old_exit_value;
+
+ sigmodes[SIGINT] &= ~SIG_INPROGRESS;
+
+ if (sigmodes[SIGINT] & SIG_CHANGED)
+ {
+ free (saved_command);
+ sigmodes[SIGINT] &= ~SIG_CHANGED;
+ }
}
}
@@ -619,6 +648,13 @@
int sig;
{
return (sigmodes[sig] & SIG_SPECIAL);
+}
+
+int
+signal_is_ignored (sig)
+ int sig;
+{
+ return (sigmodes[sig] & SIG_IGNORED);
}
void
Index: trap.h
===================================================================
RCS file: /cvsroot/winbash/winbash/trap.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- trap.h 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ trap.h 9 Mar 2002 16:05:42 -0000 1.2
@@ -48,7 +48,7 @@
extern void set_signal __P((int, char *));
extern void restore_default_signal __P((int));
extern void ignore_signal __P((int));
-extern void run_exit_trap __P((void));
+extern int run_exit_trap __P((void));
extern void free_trap_strings __P((void));
extern void reset_signal_handlers __P((void));
extern void restore_original_signals __P((void));
@@ -60,5 +60,6 @@
extern int maybe_call_trap_handler __P((int));
extern int signal_is_trapped __P((int));
extern int signal_is_special __P((int));
+extern int signal_is_ignored __P((int));
#endif /* __TRAP_H__ */
Index: variables.c
===================================================================
RCS file: /cvsroot/winbash/winbash/variables.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- variables.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ variables.c 9 Mar 2002 16:05:42 -0000 1.2
@@ -107,7 +107,7 @@
/* Make VAR be auto-exported. VAR is a pointer to a SHELL_VAR. */
#define set_auto_export(var) \
-{ var->attributes |= att_exported; array_needs_making = 1; }
+ do { var->attributes |= att_exported; array_needs_making = 1; } while (0)
#if defined (HISTORY)
# include "bashhist.h"
@@ -355,7 +355,7 @@
/* Get the full pathname to THIS shell, and set the BASH variable
to it. */
{
- char *tname = find_user_command (shell_name);
+ char *tname;
if ((thr_me->login_shell == 1) && ((*shell_name != '/') || !(isletter (*shell_name) && shell_name[1] == ':')))
{
@@ -365,16 +365,38 @@
name = savestring (current_user.shell);
}
+ else if (*shell_name == '/')
+ name = savestring (shell_name);
else
{
- if (!tname)
- name = make_absolute (shell_name, get_string_value ("PWD"));
+ int s;
+
+ tname = find_user_command (shell_name);
+ if (tname == 0)
+ {
+ /* Try the current directory. If there is not an executable
+ there, just punt and use the login shell. */
+ s = file_status (shell_name);
+ if (s & FS_EXECABLE)
+ {
+ tname = make_absolute (shell_name, get_string_value ("PWD"));
+ if (*shell_name == '.')
+ {
+ name = canonicalize_pathname (tname);
+ free (tname);
+ }
+ else
+ name = tname;
+ }
+ else
+ name = savestring (current_user.shell);
+ }
else
{
name = full_pathname (tname);
free (tname);
}
- }
+ }
/* Make the exported environment variable SHELL be the user's login
shell. Note that the `tset' command looks at this variable
|