From: Chet Ramey Date: Wed, 7 Dec 2011 14:11:26 +0000 (-0500) Subject: commit bash-20070823 snapshot X-Git-Tag: bash-4.0-alpha~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb603128ea23bd1fcca8e3c13296afa83c16fe45;p=thirdparty%2Fbash.git commit bash-20070823 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 0b023ace3..038c6ca41 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -14831,3 +14831,17 @@ examples/loadables/Makefile.in examples/loadables/{basename,cut,dirname,finfo,head,ln,logname,mkdir,pathchk,print,printenv,push,realpath,rmdir,sleep,tee,truefalse,tty,uname,unlink,whoami}.c - fix up some includes. Fix from Mike Frysinger + + 8/21 + ---- +histexpand.c + - fix another memory leak in history_find_word. Bug report originally + from Michael Snyder ; test case suggested by Jim + Blandy + + 8/26 + ---- +subst.c + - change to do_assignment_internal to make an assignment to a variable + with the `noassign' internal attribute not a variable assignment + error. diff --git a/CWRU/CWRU.chlog~ b/CWRU/CWRU.chlog~ index 80943e812..a8f2e2b35 100644 --- a/CWRU/CWRU.chlog~ +++ b/CWRU/CWRU.chlog~ @@ -14829,4 +14829,19 @@ examples/loadables/Makefile.in - add @LDFLAGS@ to SHOBJ_LDFLAGS assignment -- experimental. Suggested by Mike Frysinger -examples/loadables/{ +examples/loadables/{basename,cut,dirname,finfo,head,ln,logname,mkdir,pathchk,print,printenv,push,realpath,rmdir,sleep,tee,truefalse,tty,uname,unlink,whoami}.c + - fix up some includes. Fix from Mike Frysinger + + 8/21 + ---- +histexpand.c + - fix another memory leak in history_find_word. Bug report originally + from Michael Snyder ; test case suggested by Jim + Blandy + + 8/26 + ---- +subst.c + - change to do_assignment_internal to make an assignment to a variable + with the `noassign' internal attribute not a variable assignment + error diff --git a/builtins/exec.def b/builtins/exec.def index 4d92a5696..fd92d7edd 100644 --- a/builtins/exec.def +++ b/builtins/exec.def @@ -23,16 +23,17 @@ $PRODUCES exec.c $BUILTIN exec $FUNCTION exec_builtin -$SHORT_DOC exec [-cl] [-a name] [command [arguments ...]] +$SHORT_DOC exec [-cl] [-a name] [command [arguments ...]] [redirection ...] Execute COMMAND, replacing this shell with the specified program. ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified, any redirections take effect in the current shell. If the `-l' option is supplied, the shell places a dash in the zeroth argument to the COMMAND, as login does. If the `-c' option is supplied, COMMAND is executed with an empty environment. The `-a' option causes the shell -to pass NAME as the zeroth argument to COMMAND. If the file cannot be +to pass NAME as the zeroth argument to COMMAND. If the command cannot be executed, a non-interactive shell exits, unless the shell option `execfail' -is set. +is set. If COMMAND is absent, any redirections specified take effect in the +calling shell. $END #include diff --git a/builtins/exec.def~ b/builtins/exec.def~ index dd34ad53a..4a89ed6f7 100644 --- a/builtins/exec.def~ +++ b/builtins/exec.def~ @@ -1,7 +1,7 @@ This file is exec.def, from which is created exec.c. It implements the builtin "exec" in Bash. -Copyright (C) 1987-2003 Free Software Foundation, Inc. +Copyright (C) 1987-2007 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -23,15 +23,17 @@ $PRODUCES exec.c $BUILTIN exec $FUNCTION exec_builtin -$SHORT_DOC exec [-cl] [-a name] file [redirection ...] -Execute FILE, replacing this shell with the specified program. -If FILE is not specified, the redirections take effect in this -shell. If the first argument is `-l', then place a dash in the -zeroth arg passed to FILE, as login does. If the `-c' option -is supplied, FILE is executed with a null environment. The `-a' -option means set argv[0] of the executed process to NAME. -If the file cannot be executed and the shell is not interactive, -then the shell exits, unless the shell option `execfail' is set. +$SHORT_DOC exec [-cl] [-a name] [command [arguments ...]] [redirection ...] +Execute COMMAND, replacing this shell with the specified program. +ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified, +any redirections take effect in the current shell. If the `-l' option +is supplied, the shell places a dash in the zeroth argument to the +COMMAND, as login does. If the `-c' option is supplied, COMMAND is +executed with an empty environment. The `-a' option causes the shell +to pass NAME as the zeroth argument to COMMAND. If the command cannot be +executed, a non-interactive shell exits, unless the shell option `execfail' +is set. If COMMAND is absent, any redirections take effect in the +calling shell. $END #include diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c index c07d769bd..4df87d475 100644 --- a/lib/readline/histexpand.c +++ b/lib/readline/histexpand.c @@ -64,10 +64,11 @@ static int subst_lhs_len; static int subst_rhs_len; static char *get_history_word_specifier PARAMS((char *, char *, int *)); -static char *history_find_word PARAMS((char *, int)); static int history_tokenize_word PARAMS((const char *, int)); static char **history_tokenize_internal PARAMS((const char *, int, int *)); static char *history_substring PARAMS((const char *, int, int)); +static void freewords PARAMS((char **, int)); +static char *history_find_word PARAMS((char *, int)); static char *quote_breaks PARAMS((char *)); @@ -1570,6 +1571,18 @@ history_tokenize (string) return (history_tokenize_internal (string, -1, (int *)NULL)); } +/* Free members of WORDS from START to an empty string */ +static void +freewords (words, start) + char **words; + int start; +{ + register int i; + + for (i = start; words[i]; i++) + free (words[i]); +} + /* Find and return the word which contains the character at index IND in the history line LINE. Used to save the word matched by the last history !?string? search. */ @@ -1584,14 +1597,15 @@ history_find_word (line, ind) words = history_tokenize_internal (line, ind, &wind); if (wind == -1 || words == 0) { + if (words) + freewords (words, 0); FREE (words); return ((char *)NULL); } s = words[wind]; for (i = 0; i < wind; i++) free (words[i]); - for (i = wind + 1; words[i]; i++) - free (words[i]); + freewords (words, wind + 1); free (words); return s; } diff --git a/patchlevel.h b/patchlevel.h index 6f7291afb..eb962a37c 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 17 +#define PATCHLEVEL 25 #endif /* _PATCHLEVEL_H_ */ diff --git a/patchlevel.h~ b/patchlevel.h~ index e1c2c8abd..6f7291afb 100644 --- a/patchlevel.h~ +++ b/patchlevel.h~ @@ -1,6 +1,6 @@ /* patchlevel.h -- current bash patch level */ -/* Copyright (C) 2001-2006 Free Software Foundation, Inc. +/* Copyright (C) 2001-2007 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 9 +#define PATCHLEVEL 17 #endif /* _PATCHLEVEL_H_ */ diff --git a/subst.c b/subst.c index fcf221cb9..7bc61f571 100644 --- a/subst.c +++ b/subst.c @@ -2279,7 +2279,7 @@ do_assignment_internal (word, expand) const WORD_DESC *word; int expand; { - int offset, tlen, appendop, assign_list, aflags; + int offset, tlen, appendop, assign_list, aflags, retval; char *name, *value; SHELL_VAR *entry; #if defined (ARRAY_VARS) @@ -2370,11 +2370,27 @@ do_assignment_internal (word, expand) stupidly_hack_special_variables (name); +#if 1 + /* Return 1 if the assignment seems to have been performed correctly. */ + if (entry == 0 || readonly_p (entry)) + retval = 0; /* assignment failure */ + else if (noassign_p (entry)) + { + last_command_exit_value = EXECUTION_FAILURE; + retval = 1; /* error status, but not assignment failure */ + } + else + retval = 1; + ASSIGN_RETURN (retval); + + if (entry && retval != 0) + VUNSETATTR (entry, att_invisible); +#else if (entry) VUNSETATTR (entry, att_invisible); - /* Return 1 if the assignment seems to have been performed correctly. */ ASSIGN_RETURN (entry ? ((readonly_p (entry) == 0) && noassign_p (entry) == 0) : 0); +#endif } /* Perform the assignment statement in STRING, and expand the @@ -7708,7 +7724,6 @@ exp_jump_to_top_level (v) assigning_in_environment = 0; top_level_cleanup (); /* from sig.c */ - jump_to_top_level (v); } diff --git a/subst.c~ b/subst.c~ index b3250747f..56a6294fd 100644 --- a/subst.c~ +++ b/subst.c~ @@ -163,8 +163,6 @@ int allow_null_glob_expansion; /* Non-zero means to throw an error when globbing fails to match anything. */ int fail_glob_expansion; -int assigining_in_environment; - #if 0 /* Variables to keep track of which words in an expanded word list (the output of expand_word_list_internal) are the result of globbing @@ -2281,7 +2279,7 @@ do_assignment_internal (word, expand) const WORD_DESC *word; int expand; { - int offset, tlen, appendop, assign_list, aflags; + int offset, tlen, appendop, assign_list, aflags, retval; char *name, *value; SHELL_VAR *entry; #if defined (ARRAY_VARS) @@ -2375,8 +2373,21 @@ do_assignment_internal (word, expand) if (entry) VUNSETATTR (entry, att_invisible); +#if 1 /* Return 1 if the assignment seems to have been performed correctly. */ + if (entry == 0 || readonly_p (entry)) + retval = 0; /* assignment failure */ + else if (noassign_p (entry)) + { + last_command_exit_value = EXECUTION_FAILURE; + retval = 1; /* error status, but not assignment failure */ + } + else + retval = 1; + ASSIGN_RETURN (retval); +#else ASSIGN_RETURN (entry ? ((readonly_p (entry) == 0) && noassign_p (entry) == 0) : 0); +#endif } /* Perform the assignment statement in STRING, and expand the @@ -4995,7 +5006,7 @@ parameter_brace_expand_word (name, var_is_special, quoted) temp = (*temp && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) ? quote_string (temp) : quote_escapes (temp); - else if (atype == 1 && temp && *temp == 0 && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) + else if (atype == 1 && temp && QUOTED_NULL (temp) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) rflags |= W_HASQUOTEDNULL; } #endif @@ -7710,7 +7721,6 @@ exp_jump_to_top_level (v) assigning_in_environment = 0; top_level_cleanup (); /* from sig.c */ - jump_to_top_level (v); } diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 3efcf32d6..72ec06a2c 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -1,4 +1,4 @@ -BUILD_DIR=/usr/local/build/chet/bash/bash-current +BUILD_DIR=/usr/local/build/bash/bash-current THIS_SH=$BUILD_DIR/bash PATH=$PATH:$BUILD_DIR diff --git a/tests/errors.right b/tests/errors.right index 5df708b17..346d2e97a 100644 --- a/tests/errors.right +++ b/tests/errors.right @@ -20,7 +20,7 @@ declare: usage: declare [-afFirtx] [-p] [name[=value] ...] ./errors.tests: line 61: declare: `/bin/sh': not a valid identifier ./errors.tests: line 65: declare: cannot use `-f' to make functions ./errors.tests: line 68: exec: -i: invalid option -exec: usage: exec [-cl] [-a name] file [redirection ...] +exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...] ./errors.tests: line 72: export: XPATH: not a function ./errors.tests: line 75: break: only meaningful in a `for', `while', or `until' loop ./errors.tests: line 76: continue: only meaningful in a `for', `while', or `until' loop diff --git a/tests/exec.right b/tests/exec.right index 075912958..8f974ae59 100644 --- a/tests/exec.right +++ b/tests/exec.right @@ -51,6 +51,5 @@ this is ohio-state 0 1 testb -bash: no job control in this shell expand_aliases on after diff --git a/tests/exec.right~ b/tests/exec.right~ index 6e74b22cb..075912958 100644 --- a/tests/exec.right~ +++ b/tests/exec.right~ @@ -51,7 +51,6 @@ this is ohio-state 0 1 testb -bash: cannot set terminal pgrp to 15044: Inappropriate ioctl for device bash: no job control in this shell expand_aliases on after