/* error.c -- Functions for handling errors. */
-/* Copyright (C) 1993-2008 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
extern int executing_line_number __P((void));
+extern int last_command_exit_value;
extern char *shell_name;
#if defined (JOB_CONTROL)
extern pid_t shell_pgrp;
va_end (args);
if (exit_immediately_on_error)
- exit_shell (1);
+ {
+ if (last_command_exit_value == 0)
+ last_command_exit_value = 1;
+ exit_shell (last_command_exit_value);
+ }
}
void
va_end (args);
if (exit_immediately_on_error)
- exit_shell (2);
+ exit_shell (last_command_exit_value = 2);
}
#ifdef DEBUG
+/* This assumes ASCII and is suitable only for debugging */
+char *
+strescape (str)
+ const char *str;
+{
+ char *r, *result;
+ unsigned char *s;
+
+ r = result = (char *)xmalloc (strlen (str) * 2 + 1);
+
+ for (s = (unsigned char *)str; s && *s; s++)
+ {
+ if (*s < ' ')
+ {
+ *r++ = '^';
+ *r++ = *s+64;
+ }
+ else if (*s == 127)
+ {
+ *r++ = '^';
+ *r++ = '?';
+ }
+ else
+ *r++ = *s;
+ }
+
+ *r = '\0';
+ return result;
+}
+
void
#if defined (PREFER_STDARG)
itrace (const char *format, ...)