Update of /cvsroot/winbash/winbash/builtins
In directory usw-pr-cvs1:/tmp/cvs-serv14844/builtins
Modified Files:
bind.def common.c exec.def exit.def read.def reserved.def
setattr.def shift.def source.def ulimit.def
Log Message:
Applied 1.14.3 diffs from GNU bash
Index: bind.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/bind.def,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- bind.def 9 Mar 2002 04:20:36 -0000 1.2
+++ bind.def 9 Mar 2002 16:05:42 -0000 1.3
@@ -162,7 +162,7 @@
{
if (rl_read_init_file (initfile) != 0)
{
- builtin_error ("cannot read %s: %s\n", initfile, strerror (errno));
+ builtin_error ("cannot read %s: %s", initfile, strerror (errno));
BIND_RETURN (EXECUTION_FAILURE);
}
}
@@ -181,6 +181,9 @@
rl_set_keymap (saved_keymap);
bind_exit:
+ if (saved_keymap)
+ rl_set_keymap (saved_keymap);
+
rl_outstream = old_rl_outstream;
return (return_code);
}
Index: common.c
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/common.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- common.c 9 Mar 2002 04:20:36 -0000 1.2
+++ common.c 9 Mar 2002 16:05:42 -0000 1.3
@@ -48,7 +48,8 @@
extern int no_symbolic_links;
extern int indirection_level, startup_state;
extern int hashing_disabled;
-/* extern int variable_context; */
+/* extern int last_command_exit_value;
+ extern int variable_context; */
extern char *this_command_name, *shell_name;
extern COMMAND *global_command;
extern HASH_TABLE *hashed_filenames;
@@ -620,7 +621,9 @@
goto out;
case DISCARD:
- run_unwind_frame ("pe_dispose");
+ dispose_command (command);
+ run_unwind_frame ("pe_dispose");
+ thr_me->last_command_exit_value = 1;
continue;
default:
Index: exec.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/exec.def,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- exec.def 9 Mar 2002 04:20:36 -0000 1.2
+++ exec.def 9 Mar 2002 16:05:42 -0000 1.3
@@ -47,7 +47,7 @@
#if !defined (errno)
extern int errno;
#endif /* !errno */
-
+//extern int interactive, subshell_environment;
extern REDIRECT *redirection_undo_list;
int
@@ -128,6 +128,7 @@
restore_original_signals ();
#if defined (JOB_CONTROL)
+ if (thr_me->subshell_environment == 0)
end_job_control ();
#endif /* JOB_CONTROL */
@@ -151,8 +152,12 @@
if (command)
free (command);
- if (!thr_me->interactive && !find_variable ("no_exit_on_failed_exec"))
- exit (exit_value);
+ if (thr_me->subshell_environment ||
+ (!thr_me->interactive && !find_variable ("no_exit_on_failed_exec")))
+ exit (exit_value);
+
+ initialize_traps ();
+ reinitialize_signals ();
#if defined (JOB_CONTROL)
restart_job_control ();
Index: exit.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/exit.def,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- exit.def 9 Mar 2002 04:20:36 -0000 1.2
+++ exit.def 9 Mar 2002 16:05:42 -0000 1.3
@@ -1,5 +1,5 @@
This file is exit.def, from which is created exit.c.
-It implements the builtins "bye" and "exit", and "logout" in Bash.
+It implements the builtins "exit", and "logout" in Bash.
Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
@@ -37,6 +37,7 @@
#include "builtext.h" /* for jobs_builtin */
static int exit_or_logout ();
+static int sourced_logout = 0;
int
exit_builtin (list)
@@ -64,7 +65,7 @@
{
if (!thr_me->login_shell && thr_me->interactive)
{
- builtin_error ("Not login shell: use `exit' or `bye'");
+ builtin_error ("Not login shell: use `exit'");
return (EXECUTION_FAILURE);
}
else
@@ -116,7 +117,7 @@
exit_value = thr_me->last_command_exit_value;
/* Run our `~/.bash_logout' file if it exists, and this is a login shell. */
- if (thr_me->login_shell)
+ if (thr_me->login_shell && sourced_logout++ == 0)
maybe_execute_file ("~/.bash_logout", 1);
thr_me->last_command_exit_value = exit_value;
Index: read.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/read.def,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- read.def 9 Mar 2002 04:20:36 -0000 1.2
+++ read.def 9 Mar 2002 16:05:42 -0000 1.3
@@ -38,6 +38,8 @@
#include "common.h"
#include <errno.h>
+#define issep(c) (strchr (ifs_chars, (c)) != (char *)0)
+
static int stream_close ();
extern int interrupt_immediately;
@@ -57,11 +59,12 @@
{
register char *varname;
int size, c, i, raw_mode, pass_next, saw_escape, retval;
- char *input_string, *orig_input_string, *ifs_chars;
+ char *input_string, *orig_input_string, *ifs_chars, *t;
#if !defined(__NT_VC__)
FILE *input_stream;
int fildes;
#endif
+ SHELL_VAR *var;
i = 0; /* Index into the string that we are reading. */
raw_mode = 0; /* Not reading raw input be default. */
@@ -90,6 +93,9 @@
/* We need unbuffered input from stdin. So we make a new stream with
the same file descriptor as stdin, then unbuffer it. */
+ var = find_variable ("IFS");
+ ifs_chars = var ? value_cell (var) : " \t\n";
+
ifs_chars = get_string_value ("IFS");
input_string = xmalloc (size = 128);
@@ -175,16 +181,13 @@
if (c == EOF)
{
retval = EXECUTION_FAILURE;
- input_string[0] = '\0';
+ /* input_string[0] = '\0'; */
}
else
retval = EXECUTION_SUCCESS;
if (!list)
{
- SHELL_VAR *var;
- char *t;
-
if (saw_escape)
{
t = dequote_string (input_string);
@@ -198,20 +201,28 @@
}
else
{
- SHELL_VAR *var;
- char *t;
/* This code implements the Posix.2 spec for splitting the words
read and assigning them to variables. If $IFS is unset, we
use the default value of " \t\n". */
- if (!ifs_chars)
- ifs_chars = "";
-
orig_input_string = input_string;
- while (list->next)
+
+ /* Remove IFS white space at the beginning of the input string. If
+ $IFS is null, no field splitting is performed. */
+ for (t = input_string; *ifs_chars && spctabnl (*t) && issep (*t); t++)
+ ;
+ input_string = t;
+
+ for (; list->next; list = list->next)
{
char *e, *t1;
varname = list->word->word;
+ if (legal_identifier (varname) == 0)
+ {
+ builtin_error ("%s: not a legal variable name", varname);
+ free (orig_input_string);
+ return (EXECUTION_FAILURE);
+ }
/* If there are more variables than words read from the input,
the remaining variables are set to the empty string. */
@@ -243,10 +254,14 @@
if (t)
free (t);
-
- list = list->next;
}
+ if (legal_identifier (list->word->word) == 0)
+ {
+ builtin_error ("%s: not a legal variable name", list->word->word);
+ free (orig_input_string);
+ return (EXECUTION_FAILURE);
+ }
if (saw_escape)
{
t = dequote_string (input_string);
Index: reserved.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/reserved.def,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- reserved.def 9 Mar 2002 04:20:36 -0000 1.2
+++ reserved.def 9 Mar 2002 16:05:42 -0000 1.3
@@ -28,6 +28,21 @@
the COMMANDS are executed.
$END
+$BUILTIN select
+$SHORT_DOC select NAME [in WORDS ... ;] do COMMANDS; done
+The WORDS are expanded, generating a list of words. The
+set of expanded words is printed on the standard error, each
+preceded by a number. If `in WORDS' is not present, `in "$@"'
+is assumed. The PS3 prompt is then displayed and a line read
+from the standard input. If the line consists of the number
+corresponding to one of the displayed words, then NAME is set
+to that word. If the line is empty, WORDS and the prompt are
+redisplayed. If EOF is read, the command completes. Any other
+value read causes NAME to be set to null. The line read is saved
+in the variable REPLY. COMMANDS are executed after each selection
+until a break or return command is executed.
+$END
+
$BUILTIN case
$SHORT_DOC case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac
Selectively execute COMMANDS based upon WORD matching PATTERN. The
@@ -79,9 +94,9 @@
job specification with a `&' places the job in the background.
$END
-$BUILTIN Variables
+$BUILTIN variables
$DOCNAME variable_help
-$SHORT_DOC Some variable names and meanings
+$SHORT_DOC variables - Some variable names and meanings
BASH_VERSION The version numbers of this Bash.
CDPATH A colon separated list of directories to search
when the argument to `cd' is not found in the current
@@ -136,7 +151,4 @@
or set to any other value than those above means to save
all lines on the history list.
#endif /* HISTORY */
-#if defined (JOB_CONTROL)
-notify Notify of job termination immediately.
-#endif
$END
Index: setattr.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/setattr.def,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- setattr.def 9 Mar 2002 04:20:36 -0000 1.2
+++ setattr.def 9 Mar 2002 16:05:42 -0000 1.3
@@ -108,6 +108,10 @@
if (attribute & att_exported)
array_needs_making = 1;
+ /* Cannot undo readonly status. */
+ if (undo && (attribute & att_readonly))
+ attribute &= ~att_readonly;
+
while (list)
{
#ifndef __NT_VC__
Index: shift.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/shift.def,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- shift.def 9 Mar 2002 04:20:36 -0000 1.2
+++ shift.def 9 Mar 2002 16:05:42 -0000 1.3
@@ -44,10 +44,11 @@
shift_builtin (list)
WORD_LIST *list;
{
- int times = get_numeric_arg (list);
- int number, r;
+ int times, number;
WORD_LIST *args;
+ times = get_numeric_arg (list);
+
if (!times)
return (EXECUTION_SUCCESS);
@@ -61,12 +62,10 @@
number = list_length (args);
dispose_words (args);
- r = EXECUTION_SUCCESS;
-
if (times > number)
{
- times = number;
- r = EXECUTION_FAILURE;
+ builtin_error ("shift count must be <= $#");
+ return (EXECUTION_FAILURE);
}
while (times-- > 0)
@@ -91,5 +90,6 @@
else
dollar_vars[9] = (char *)NULL;
}
- return (r);
+
+ return (EXECUTION_SUCCESS);
}
Index: source.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/source.def,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- source.def 9 Mar 2002 04:20:36 -0000 1.2
+++ source.def 9 Mar 2002 16:05:42 -0000 1.3
@@ -178,5 +178,10 @@
if (return_val)
result = return_catch_value;
}
+ else
+ {
+ builtin_error ("filename argument required");
+ result = EXECUTION_FAILURE;
+ }
return (result);
}
Index: ulimit.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/ulimit.def,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ulimit.def 9 Mar 2002 04:20:36 -0000 1.2
+++ ulimit.def 9 Mar 2002 16:05:42 -0000 1.3
@@ -24,7 +24,7 @@
$BUILTIN ulimit
$FUNCTION ulimit_builtin
$DEPENDS_ON !MINIX
-$SHORT_DOC ulimit [-SHacdmstfpnuv [limit]]
+$SHORT_DOC ulimit [-SHacdfmstpnuv [limit]]
Ulimit provides control over the resources available to processes
started by the shell, on systems that allow such control. If an
option is given, it is interpreted as follows:
@@ -79,6 +79,14 @@
# undef HAVE_RESOURCE
#endif
+#if !defined (RLIMTYPE)
+# define RLIMTYPE long
+# define string_to_rlimtype string_to_long
+# define print_rlimtype(n, nl) printf ("%ld%s", n, nl ? "\n" : "")
+#endif
+
+static void print_long ();
+
/* **************************************************************** */
/* */
/* Ulimit builtin and Hacks. */
@@ -114,12 +122,12 @@
#define LIMIT_HARD 0x01
#define LIMIT_SOFT 0x02
-static long shell_ulimit ();
-static long pipesize ();
-static long open_files ();
+static RLIMTYPE shell_ulimit ();
+static RLIMTYPE pipesize ();
+static RLIMTYPE open_files ();
#if defined (HAVE_RESOURCE)
-static long getmaxvm ();
+static RLIMTYPE getmaxvm ();
#endif /* HAVE_RESOURCE */
static void print_specific_limits ();
@@ -135,7 +143,7 @@
static int
canraise (cmd, current, new)
int cmd;
- long current, new;
+ RLIMTYPE current, new;
{
# if defined (HAVE_SETDTABLESIZE)
if (cmd == u_NUM_OPEN_FILES)
@@ -157,10 +165,11 @@
register char *s;
int c, setting, cmd, mode, verbose_print, opt_eof;
int all_limits, specific_limits;
- long current_limit, real_limit, limit = -1L;
long block_factor;
+ RLIMTYPE current_limit, real_limit, limit;
c = mode = verbose_print = opt_eof = 0;
+ limit = (RLIMTYPE)-1;
do
{
@@ -290,7 +299,7 @@
if (STREQ (s, "unlimited"))
limit = RLIM_INFINITY;
else if (all_digits (s))
- limit = string_to_long (s);
+ limit = string_to_rlimtype (s);
else
{
builtin_error ("bad non-numeric arg `%s'", s);
@@ -329,7 +338,7 @@
}
#endif /* !HAVE_RESOURCE */
- if (shell_ulimit (cmd, real_limit, 1, mode) == -1L)
+ if (shell_ulimit (cmd, real_limit, 1, mode) == (RLIMTYPE)-1)
{
builtin_error ("cannot raise limit: %s", strerror (errno));
return (EXECUTION_FAILURE);
@@ -342,7 +351,7 @@
if (current_limit < 0)
builtin_error ("cannot get limit: %s", strerror (errno));
else if (current_limit != RLIM_INFINITY)
- printf ("%ld\n", (current_limit / block_factor));
+ print_rlimtype ((current_limit / block_factor), 1);
else
printf ("unlimited\n");
}
@@ -365,10 +374,10 @@
This includes most USG systems.
Chet Ramey supplied the BSD resource limit code. */
-static long
+static RLIMTYPE
shell_ulimit (which, newlim, setting, mode)
int which, setting, mode;
- long newlim;
+ RLIMTYPE newlim;
{
#if defined (HAVE_RESOURCE)
struct rlimit limit;
@@ -388,7 +397,7 @@
/* ulimit () returns a number that is in 512 byte blocks, thus we
must multiply it by 512 to get back to bytes. This is false
only under HP/UX 6.x. */
- long result;
+ RLIMTYPE result;
result = ulimit (1, 0L);
@@ -423,7 +432,7 @@
cmd = RLIMIT_RSS;
# else /* !RLIMIT_RSS */
errno = EINVAL;
- return (-1L);
+ return ((RLIMTYPE)-1);
# endif /* !RLIMIT_RSS */
goto do_ulimit;
@@ -439,7 +448,7 @@
do_ulimit:
if (getrlimit (cmd, &limit) != 0)
- return (-1L);
+ return ((RLIMTYPE)-1);
if (!setting)
{
@@ -475,7 +484,7 @@
if (setting)
{
errno = EINVAL;
- return (-1L);
+ return ((RLIMTYPE)-1);
}
return (pipesize ());
@@ -490,7 +499,7 @@
return (setdtablesize (newlim));
# else
errno = EINVAL;
- return (-1L);
+ return ((RLIMTYPE)-1);
# endif /* HAVE_SETDTABLESIZE */
#endif /* !HAVE_RESOURCE || !RLIMIT_NOFILE */
}
@@ -501,7 +510,7 @@
if (setting)
{
errno = EINVAL;
- return (-1L);
+ return ((RLIMTYPE)-1);
}
else
{
@@ -509,7 +518,7 @@
return (getmaxvm (mode));
#else /* !HAVE_RESOURCE */
errno = EINVAL;
- return (-1L);
+ return ((RLIMTYPE)-1);
#endif /* !HAVE_RESOURCE */
}
@@ -519,17 +528,17 @@
goto do_ulimit;
#else /* !HAVE_RESOURCE || !RLIMIT_NPROC */
errno = EINVAL;
- return (-1L);
+ return ((RLIMTYPE)-1);
#endif /* !HAVE_RESOURCE || !RLIMIT_NPROC */
default:
errno = EINVAL;
- return (-1L);
+ return ((RLIMTYPE)-1);
}
}
#if defined (HAVE_RESOURCE)
-static long
+static RLIMTYPE
getmaxvm (mode)
int mode;
{
@@ -537,19 +546,19 @@
#if defined (RLIMIT_VMEM)
if (getrlimit (RLIMIT_VMEM, &rl) < 0)
- return (-1L);
+ return ((RLIMTYPE)-1);
else
return (((mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max) / 1024L);
#else /* !RLIMIT_VMEM */
- unsigned long maxdata, maxstack;
+ RLIMTYPE maxdata, maxstack;
if (getrlimit (RLIMIT_DATA, &rl) < 0)
- return (-1L);
+ return ((RLIMTYPE)-1);
else
maxdata = (mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max;
if (getrlimit (RLIMIT_STACK, &rl) < 0)
- return (-1L);
+ return ((RLIMTYPE)-1);
else
maxstack = (mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max;
@@ -559,12 +568,12 @@
}
#endif /* HAVE_RESOURCE */
-static long
+static RLIMTYPE
open_files (mode)
int mode;
{
#if !defined (RLIMIT_NOFILE)
- return ((long)getdtablesize ());
+ return ((RLIMTYPE)getdtablesize ());
#else
struct rlimit rl;
@@ -576,19 +585,19 @@
#endif
}
-static long
+static RLIMTYPE
pipesize ()
{
#if defined (PIPE_BUF)
/* This is defined on Posix systems. */
- return ((long) PIPE_BUF);
+ return ((RLIMTYPE) PIPE_BUF);
#else
# if defined (PIPESIZE)
/* This is defined by running a program from the Makefile. */
- return ((long) PIPESIZE);
+ return ((RLIMTYPE) PIPESIZE);
# else
errno = EINVAL;
- return (-1L);
+ return ((RLIMTYPE)-1);
# endif /* PIPESIZE */
#endif /* PIPE_BUF */
}
@@ -632,7 +641,7 @@
int i, mode;
{
struct rlimit rl;
- long limit;
+ RLIMTYPE limit;
getrlimit (limits[i].parameter, &rl);
if (mode & LIMIT_HARD)
@@ -643,7 +652,7 @@
if (limit == RLIM_INFINITY)
printf ("unlimited\n");
else
- printf ("%ld\n", limit / limits[i].block_factor);
+ print_rlimtype ((limit / limits[i].block_factor), 1);
}
static void
@@ -666,25 +675,36 @@
int cmd, mode;
{
if (mode == 0)
- mode |= LIMIT_SOFT;
+ mode = LIMIT_SOFT;
#if defined (HAVE_RESOURCE)
print_specific_bsd_limits (cmd, mode);
#else /* !HAVE_RESOURCE */
if (cmd & u_FILE_SIZE)
- printf ("%-25s%ld\n",
- "file size (blocks)", ulimit (1, 0L) / ULIMIT_DIVISOR);
+ {
+ printf ("%-25s", "file size (blocks)");
+ print_rlimtype ((ulimit (1, 0L) / ULIMIT_DIVISOR), 1);
+ }
#endif /* !HAVE_RESOURCE */
if (cmd & u_PIPE_SIZE)
- printf ("%-25s%ld\n", "pipe size (512 bytes)", (pipesize () / 512));
+ {
+ printf ("%-25s", "pipe size (512 bytes)");
+ print_rlimtype ((pipesize () / 512), 1);
+ }
if (cmd & u_NUM_OPEN_FILES)
- printf ("%-25s%ld\n", "open files", open_files (mode));
+ {
+ printf ("%-25s", "open files");
+ print_rlimtype (open_files (mode), 1);
+ }
#if defined (HAVE_RESOURCE)
if (cmd & u_MAX_VIRTUAL_MEM)
- printf ("%-25s%ld\n", "virtual memory (kbytes)", getmaxvm (mode));
+ {
+ printf ("%-25s", "virtual memory (kbytes)");
+ print_rlimtype (getmaxvm (mode), 1);
+ }
#endif /* HAVE_RESOURCE */
}
|