From: Chet Ramey Date: Fri, 9 Dec 2011 01:06:34 +0000 (-0500) Subject: commit bash-20090312 snapshot X-Git-Tag: bash-4.3-alpha~236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1231ac4798fd77b9ac9a07c8cad7b1ee720781d3;p=thirdparty%2Fbash.git commit bash-20090312 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index db3a35705..7c9ef07d4 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -7705,3 +7705,68 @@ parse.y reported by Mike Frysinger (rest of fix on 3/3) + 3/10 + ---- +{.,lib/readline}/doc/fdl.texi + - updated to FDL version 1.3 + + 3/14 + ---- +execute_cmd.c + - in execute_case_command, if ;& is used with no following pattern + list, make sure we don't reference a NULL pointer. Bug report and + fix from Clark Jian Wang + +parse.y + - make parser_state global, so other files can use it + - command_word_acceptable now returns non-zero if PST_REDIRLIST bit + set in parser_state, so we accept assignment statements and + perform alias expansion. Fix for bug reported by Vincent + Lefevre (2/24/2009) + +parser.h + - add PST_REDIRLIST flag, notes that parser is currently parsing a + redirection list preceding a simple command + +make_cmd.c + - make_simple_command now turns on PST_REDIRLIST in parser_state when + creating a new simple command + - make_simple_command turns off PST_REDIRLIST in parser_state if it + adds a non-redirection to the command it's building + - clean_simple_command turns off PST_REDIRLIST to make sure it's off + +subst.c + - new flag for param_expand: PF_IGNUNBOUND, means to not exit if the + variable is unbound even if `set -u' is enabled + - change param_expand to not call err_unboundvar if the `pflags' + argument has the PF_IGNUNBOUND bit set + - parameter_brace_expand_word now takes an extra `pflags' argument to + pass down to param_expand; changed callers + - changed call to parameter_brace_expand_word in parameter_brace_expand + to add PF_IGNUNBOUND flag so ${@:-foo} doesn't cause the shell to + exit (but ${@} does) when there are no positional parameters. Fixes + Debian bug 519165 from Dan Jacobson + +parse.y + - add code to parse_comsub to allow here-documents within command + substitutions to be delimited by the closing right paren, with the + usual warning about here documents delimited by EOF on execution. + Fixes regression from bash-3.2 noted in Red Hat bugzilla 485664 by + Ralf Corsepius + + 3/15 + ---- +subst.c + - string_list_dollar_at now checks for Q_PATQUOTE, which getpattern() + uses to denote Q_DOUBLE_QUOTES (?). Fixes a=abcd echo "${a#$*}" + when IFS= and args are `a b' as noted by Stephane Chazleas + + - param_expand now checks for Q_PATQUOTE and treats it identically + to Q_DOUBLE_QUOTES when expanding $* + - expand_word_unsplit now sets W_NOSPLIT in the flags of the word it + passes to expand_word_internal if $IFS is NULL + - expand_word_leave_quoted now sets expand_no_split_dollar_start and + the W_NOSPLIT bit in the word flags before calling + expand_word_internal if $IFS is NULL, just like expand_word_unsplit. + It is now virtually identical to expand_word_unsplit. Rest of fix for + problems reported by Stephane Chazleas diff --git a/CWRU/CWRU.chlog~ b/CWRU/CWRU.chlog~ index 3adb43f1e..315c43c7f 100644 --- a/CWRU/CWRU.chlog~ +++ b/CWRU/CWRU.chlog~ @@ -7648,7 +7648,7 @@ builtins/read.def parse.y - break comment checking code into a common COMMENT_BEGIN define so we can use it in multiple places in parse_comsub - - in parse_comsub, don't turn off the LEX_RESWDOK flag if we read a + - in parse_comsub, don't alter the LEX_RESWDOK flag if we read a `#' and we're checking comments, even though `#' isn't a `shell break' character. Fixes bug reported by Mike Frysinger @@ -7693,3 +7693,80 @@ parse.y - move LEX_PASSNEXT code to the top of parse_comsub, so the rest of the function doesn't have to check for the flag at different places + + 3/7 + --- +parse.y + - in parse_comsub, when looking for a reserved word (LEX_RESWDOK + non-zero), and in a case statement, we can see either an esac + or a pattern list. We handle an esac separately. We should + turn off LEX_RESWDOK if we see anything but a newline, since + we'll be reading a pattern list. Other part of fix for bug + reported by Mike Frysinger (rest of fix + on 3/3) + + 3/10 + ---- +{.,lib/readline}/doc/fdl.texi + - updated to FDL version 1.3 + + 3/14 + ---- +execute_cmd.c + - in execute_case_command, if ;& is used with no following pattern + list, make sure we don't reference a NULL pointer. Bug report and + fix from Clark Jian Wang + +parse.y + - make parser_state global, so other files can use it + - command_word_acceptable now returns non-zero if PST_REDIRLIST bit + set in parser_state, so we accept assignment statements and + perform alias expansion. Fix for bug reported by Vincent + Lefevre (2/24/2009) + +parser.h + - add PST_REDIRLIST flag, notes that parser is currently parsing a + redirection list preceding a simple command + +make_cmd.c + - make_simple_command now turns on PST_REDIRLIST in parser_state when + creating a new simple command + - make_simple_command turns off PST_REDIRLIST in parser_state if it + adds a non-redirection to the command it's building + - clean_simple_command turns off PST_REDIRLIST to make sure it's off + +subst.c + - new flag for param_expand: PF_IGNUNBOUND, means to not exit if the + variable is unbound even if `set -u' is enabled + - change param_expand to not call err_unboundvar if the `pflags' + argument has the PF_IGNUNBOUND bit set + - parameter_brace_expand_word now takes an extra `pflags' argument to + pass down to param_expand; changed callers + - changed call to parameter_brace_expand_word in parameter_brace_expand + to add PF_IGNUNBOUND flag so ${@:-foo} doesn't cause the shell to + exit (but ${@} does) when there are no positional parameters. Fixes + Debian bug 519165 from Dan Jacobson + +parse.y + - add code to parse_comsub to allow here-documents within command + substitutions to be delimited by the closing right paren, with the + usual warning about here documents delimited by EOF on execution. + Fixes regression from bash-3.2 noted in Red Hat bugzilla 485664 by + Ralf Corsepius + + 3/15 + ---- +subst.c + - string_list_dollar_at now checks for Q_PATQUOTE, which getpattern() + uses to denote Q_DOUBLE_QUOTES (?). Fixes a=abcd echo "${a#$*}" + when IFS= and args are `a b' as noted by Stephane Chazleas + + - param_expand now checks for Q_PATQUOTE and treats it identically + to Q_DOUBLE_QUOTES when expanding $* + - expand_word_unsplit now sets W_NOSPLIT in the flags of the word it + passes to expand_word_internal + - expand_word_leave_quoted now sets expand_no_split_dollar_start and + the W_NOSPLIT bit in the word flags before calling + expand_word_internal, just like expand_word_unsplit. It is now + virtually identical to expand_word_unsplit. Rest of fix for + problems reported by Stephane Chazleas diff --git a/MANIFEST b/MANIFEST index 27f85fdf1..37276297a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -777,6 +777,7 @@ tests/comsub-eof0.sub f tests/comsub-eof1.sub f tests/comsub-eof2.sub f tests/comsub-eof3.sub f +tests/comsub-eof4.sub f tests/comsub-eof.right f tests/comsub-posix.tests f tests/comsub-posix.right f @@ -797,9 +798,11 @@ tests/dbg-support3.sub f tests/dollar-at-star f tests/dollar-at1.sub f tests/dollar-at2.sub f +tests/dollar-at3.sub f tests/dollar-star1.sub f tests/dollar-star2.sub f tests/dollar-star3.sub f +tests/dollar-star4.sub f tests/dollar.right f tests/dstack.tests f tests/dstack.right f diff --git a/MANIFEST~ b/MANIFEST~ index ea772d580..d83d286c8 100644 --- a/MANIFEST~ +++ b/MANIFEST~ @@ -771,11 +771,13 @@ tests/casemod.tests f tests/casemod.right f tests/comsub.tests f tests/comsub.right f +tests/comsub1.sub f tests/comsub-eof.tests f tests/comsub-eof0.sub f tests/comsub-eof1.sub f tests/comsub-eof2.sub f tests/comsub-eof3.sub f +tests/comsub-eof4.sub f tests/comsub-eof.right f tests/comsub-posix.tests f tests/comsub-posix.right f diff --git a/builtins/alias.def~ b/builtins/alias.def~ new file mode 100644 index 000000000..539f773d5 --- /dev/null +++ b/builtins/alias.def~ @@ -0,0 +1,242 @@ +This file is alias.def, from which is created alias.c +It implements the builtins "alias" and "unalias" in Bash. + +Copyright (C) 1987-2009 Free Software Foundation, Inc. + +This file is part of GNU Bash, the Bourne Again SHell. + +Bash is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Bash is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Bash. If not, see . + +$BUILTIN alias +$FUNCTION alias_builtin +$DEPENDS_ON ALIAS +$PRODUCES alias.c +$SHORT_DOC alias [-p] [name[=value] ... ] +Define or display aliases. + +Without arguments, `alias' prints the list of aliases in the reusable +form `alias NAME=VALUE' on standard output. + +Otherwise, an alias is defined for each NAME whose VALUE is given. +A trailing space in VALUE causes the next word to be checked for +alias substitution when the alias is expanded. + +Options: + -p Print all defined aliases in a reusable format + +Exit Status: +alias returns true unless a NAME is supplied for which no alias has been +defined. +$END + +#include + +#if defined (ALIAS) + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +# include "../bashansi.h" +# include "../bashintl.h" + +# include +# include "../shell.h" +# include "../alias.h" +# include "common.h" +# include "bashgetopt.h" + +/* Flags for print_alias */ +#define AL_REUSABLE 0x01 + +static void print_alias __P((alias_t *, int)); + +extern int posixly_correct; + +/* Hack the alias command in a Korn shell way. */ +int +alias_builtin (list) + WORD_LIST *list; +{ + int any_failed, offset, pflag, dflags; + alias_t **alias_list, *t; + char *name, *value; + +itrace("alias_builtin"); + dflags = posixly_correct ? 0 : AL_REUSABLE; + pflag = 0; + reset_internal_getopt (); + while ((offset = internal_getopt (list, "p")) != -1) + { + switch (offset) + { + case 'p': + pflag = 1; + dflags |= AL_REUSABLE; + break; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + + if (list == 0 || pflag) + { + if (aliases == 0) + return (EXECUTION_SUCCESS); + + alias_list = all_aliases (); + + if (alias_list == 0) + return (EXECUTION_SUCCESS); + + for (offset = 0; alias_list[offset]; offset++) + print_alias (alias_list[offset], dflags); + + free (alias_list); /* XXX - Do not free the strings. */ + + if (list == 0) + return (sh_chkwrite (EXECUTION_SUCCESS)); + } + + any_failed = 0; + while (list) + { + name = list->word->word; + + for (offset = 0; name[offset] && name[offset] != '='; offset++) + ; + + if (offset && name[offset] == '=') + { + name[offset] = '\0'; + value = name + offset + 1; + + if (legal_alias_name (name, 0) == 0) + { + builtin_error (_("`%s': invalid alias name"), name); + any_failed++; + } + else + add_alias (name, value); + } + else + { + t = find_alias (name); + if (t) + print_alias (t, dflags); + else + { + sh_notfound (name); + any_failed++; + } + } + list = list->next; + } + + return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} +#endif /* ALIAS */ + +$BUILTIN unalias +$FUNCTION unalias_builtin +$DEPENDS_ON ALIAS +$SHORT_DOC unalias [-a] name [name ...] +Remove each NAME from the list of defined aliases. + +Options: + -a remove all alias definitions. + +Return success unless a NAME is not an existing alias. +$END + +#if defined (ALIAS) +/* Remove aliases named in LIST from the aliases database. */ +int +unalias_builtin (list) + register WORD_LIST *list; +{ + register alias_t *alias; + int opt, aflag; + + aflag = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "a")) != -1) + { + switch (opt) + { + case 'a': + aflag = 1; + break; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + + if (aflag) + { + delete_all_aliases (); + return (EXECUTION_SUCCESS); + } + + if (list == 0) + { + builtin_usage (); + return (EX_USAGE); + } + + aflag = 0; + while (list) + { + alias = find_alias (list->word->word); + + if (alias) + remove_alias (alias->name); + else + { + sh_notfound (list->word->word); + aflag++; + } + + list = list->next; + } + + return (aflag ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} + +/* Output ALIAS in such a way as to allow it to be read back in. */ +static void +print_alias (alias, flags) + alias_t *alias; + int flags; +{ + char *value; + + value = sh_single_quote (alias->value); + if (flags & AL_REUSABLE) + printf ("alias "); + printf ("%s=%s\n", alias->name, value); + free (value); + + fflush (stdout); +} +#endif /* ALIAS */ diff --git a/ddd1 b/ddd1 new file mode 100644 index 000000000..bf5f5d199 --- /dev/null +++ b/ddd1 @@ -0,0 +1,205 @@ +*** ../bash-4.0-patched/parse.y 2009-03-08 21:24:47.000000000 -0400 +--- parse.y 2009-03-14 20:24:51.000000000 -0400 +*************** +*** 260,263 **** +--- 260,266 ---- + int current_token; + ++ /* The current parser state. */ ++ int parser_state; ++ + /* Variables to manage the task of reading here documents, because we need to + defer the reading until after a complete command has been collected. */ +*************** +*** 284,290 **** + static int arith_for_lineno; + +- /* The current parser state. */ +- static int parser_state; +- + /* The last read token, or NULL. read_token () uses this for context + checking. */ +--- 287,290 ---- +*************** +*** 1123,1127 **** + REDIRECT *r; + +! tc = $1; + rd.dest = 1; + r = make_redirection (2, r_duplicating_output, rd); +--- 1123,1127 ---- + REDIRECT *r; + +! tc = $1->type == cm_simple ? (COMMAND *)$1->value.Simple : $1; + rd.dest = 1; + r = make_redirection (2, r_duplicating_output, rd); +*************** +*** 2397,2401 **** + + #define command_token_position(token) \ +! (((token) == ASSIGNMENT_WORD) || \ + ((token) != SEMI_SEMI && (token) != SEMI_AND && (token) != SEMI_SEMI_AND && reserved_word_acceptable(token))) + +--- 2397,2401 ---- + + #define command_token_position(token) \ +! (((token) == ASSIGNMENT_WORD) || (parser_state&PST_REDIRLIST) || \ + ((token) != SEMI_SEMI && (token) != SEMI_AND && (token) != SEMI_SEMI_AND && reserved_word_acceptable(token))) + +*************** +*** 2968,2972 **** + int retind, retsize, rflags; + +! /* itrace("parse_matched_pair: open = %c close = %c flags = %d", open, close, flags); */ + count = 1; + tflags = 0; +--- 2968,2972 ---- + int retind, retsize, rflags; + +! /*itrace("parse_matched_pair: open = %c close = %c flags = %d", open, close, flags); */ + count = 1; + tflags = 0; +*************** +*** 3263,3266 **** +--- 3263,3283 ---- + prompt_again (); + ++ /* XXX -- possibly allow here doc to be delimited by ending right ++ paren. */ ++ if ((tflags & LEX_INHEREDOC) && ch == close && count == 1) ++ { ++ int tind; ++ /*itrace("parse_comsub: in here doc, ch == close, retind - firstind = %d hdlen = %d retind = %d", retind-lex_firstind, hdlen, retind);*/ ++ tind = lex_firstind; ++ while ((tflags & LEX_STRIPDOC) && ret[tind] == '\t') ++ tind++; ++ if (retind-tind == hdlen && STREQN (ret + tind, heredelim, hdlen)) ++ { ++ tflags &= ~(LEX_STRIPDOC|LEX_INHEREDOC); ++ /*itrace("parse_comsub:%d: found here doc end `%s'", line_number, ret + tind);*/ ++ lex_firstind = -1; ++ } ++ } ++ + /* Don't bother counting parens or doing anything else if in a comment */ + if (tflags & (LEX_INCOMMENT|LEX_INHEREDOC)) +*************** +*** 3271,3275 **** +--- 3288,3295 ---- + + if ((tflags & LEX_INCOMMENT) && ch == '\n') ++ { ++ /*itrace("parse_comsub:%d: lex_incomment -> 0 ch = `%c'", line_number, ch);*/ + tflags &= ~LEX_INCOMMENT; ++ } + + continue; +*************** +*** 3365,3369 **** + RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); + ret[retind++] = peekc; +! /*itrace("parse_comsub:%d: set lex_reswordok = 1, ch = `%c'", line_number, ch); */ + tflags |= LEX_RESWDOK; + lex_rwlen = 0; +--- 3385,3389 ---- + RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); + ret[retind++] = peekc; +! /*itrace("parse_comsub:%d: set lex_reswordok = 1, ch = `%c'", line_number, ch);*/ + tflags |= LEX_RESWDOK; + lex_rwlen = 0; +*************** +*** 3373,3378 **** + { + shell_ungetc (peekc); +- tflags |= LEX_RESWDOK; + /*itrace("parse_comsub:%d: set lex_reswordok = 1, ch = `%c'", line_number, ch);*/ + lex_rwlen = 0; + continue; +--- 3393,3398 ---- + { + shell_ungetc (peekc); + /*itrace("parse_comsub:%d: set lex_reswordok = 1, ch = `%c'", line_number, ch);*/ ++ tflags |= LEX_RESWDOK; + lex_rwlen = 0; + continue; +*************** +*** 3404,3413 **** + { + tflags |= LEX_INCASE; +! /*itrace("parse_comsub:%d: found `case', lex_incase -> 1", line_number);*/ + } + else if (STREQN (ret + retind - 4, "esac", 4)) + { + tflags &= ~LEX_INCASE; +! /*itrace("parse_comsub:%d: found `esac', lex_incase -> 0", line_number);*/ + } + tflags &= ~LEX_RESWDOK; +--- 3424,3433 ---- + { + tflags |= LEX_INCASE; +! /*itrace("parse_comsub:%d: found `case', lex_incase -> 1 lex_reswdok -> 0", line_number);*/ + } + else if (STREQN (ret + retind - 4, "esac", 4)) + { + tflags &= ~LEX_INCASE; +! /*itrace("parse_comsub:%d: found `esac', lex_incase -> 0 lex_reswdok -> 0", line_number);*/ + } + tflags &= ~LEX_RESWDOK; +*************** +*** 3432,3435 **** +--- 3452,3456 ---- + } + ++ /* Might be the start of a here-doc delimiter */ + if MBTEST((tflags & LEX_INCOMMENT) == 0 && (tflags & LEX_CKCASE) && ch == '<') + { +*************** +*** 3488,3492 **** +--- 3509,3516 ---- + } + else if MBTEST(((flags & P_FIRSTCLOSE) == 0) && (tflags & LEX_INCASE) == 0 && ch == open) /* nested begin */ ++ { + count++; ++ /*itrace("parse_comsub:%d: found open: count = %d", line_number, count);*/ ++ } + + /* Add this character. */ +*************** +*** 5232,5236 **** + if (interactive && EOF_Reached) + EOF_Reached = 0; +! last_command_exit_value = EX_USAGE; + return; + } +--- 5256,5260 ---- + if (interactive && EOF_Reached) + EOF_Reached = 0; +! last_command_exit_value = EX_BADUSAGE; + return; + } +*************** +*** 5247,5251 **** + print_offending_line (); + +! last_command_exit_value = EX_USAGE; + return; + } +--- 5271,5275 ---- + print_offending_line (); + +! last_command_exit_value = EX_BADUSAGE; + return; + } +*************** +*** 5278,5282 **** + } + +! last_command_exit_value = EX_USAGE; + } + +--- 5302,5306 ---- + } + +! last_command_exit_value = EX_BADUSAGE; + } + diff --git a/doc/Makefile.in b/doc/Makefile.in index 2bbfc3cee..3e0e68b40 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -94,7 +94,7 @@ GROFF = groff HSUSER = $(RL_LIBDIR)/doc/hsuser.texi RLUSER = $(RL_LIBDIR)/doc/rluser.texi -BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/version.texi +BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi .SUFFIXES: .0 .1 .3 .ms .ps .txt .dvi .html .pdf diff --git a/doc/bashref.dvi b/doc/bashref.dvi index 7d3a454d0..a9e463967 100644 Binary files a/doc/bashref.dvi and b/doc/bashref.dvi differ diff --git a/doc/bashref.html b/doc/bashref.html index caf2791e7..b47efcad2 100644 --- a/doc/bashref.html +++ b/doc/bashref.html @@ -1,6 +1,6 @@ - +