From: Chet Ramey Date: Tue, 22 Jan 2019 13:40:19 +0000 (-0500) Subject: commit bash-20190118 snapshot X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb7da4469b097f7804e5f30fe099757248b78359;p=thirdparty%2Fbash.git commit bash-20190118 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index e972bf4ed..386e558cf 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -5061,3 +5061,20 @@ parse.y alias to determine whether or not to add a trailing space instead of testing against a space only. These are the non-shell-metacharacters that can delimit words. Used together with PST_ENDALIAS + + 1/17 + ---- +parse.y + - shell_getc: keep track of whether the last character read from + shell_input_line is an unquoted backslash and don't add a space to + the end of an alias if the alias value ends in an unquoted backslash. + From an austin-group mailing list discussion message from + Harald van Dijk + + 1/20 + ---- +general.c + - check_identifier: make sure CHECK_WORD is non-zero before we check + whether or not the word consists of all digits. This allows function + names to consist solely of digits when not in posix mode. From a + report by Andrey Butirsky diff --git a/bashline.c b/bashline.c index ff79b7048..f5d90a516 100644 --- a/bashline.c +++ b/bashline.c @@ -231,7 +231,7 @@ static int bash_possible_variable_completions __P((int, int)); static int bash_complete_command __P((int, int)); static int bash_possible_command_completions __P((int, int)); -static int completion_glob_pattern __P((const char *)); +static int completion_glob_pattern __P((char *)); static char *glob_complete_word __P((const char *, int)); static int bash_glob_completion_internal __P((int)); static int bash_glob_complete_word __P((int, int)); @@ -1742,7 +1742,7 @@ bash_default_completion (text, start, end, qc, compflags) /* This could be a globbing pattern, so try to expand it using pathname expansion. */ - if (!matches && completion_glob_pattern (text)) + if (!matches && completion_glob_pattern ((char *)text)) { matches = rl_completion_matches (text, glob_complete_word); /* A glob expression that matches more than one filename is problematic. @@ -1851,7 +1851,7 @@ command_word_completion_function (hint_text, state) glob_matches = (char **)NULL; } - globpat = completion_glob_pattern (hint_text); + globpat = completion_glob_pattern ((char *)hint_text); /* If this is an absolute program name, do not check it against aliases, reserved words, functions or builtins. We must check @@ -3716,7 +3716,7 @@ bash_complete_command_internal (what_to_do) static int completion_glob_pattern (string) - const char *string; + char *string; { register int c; char *send; diff --git a/doc/bash.1 b/doc/bash.1 index e6cd08db3..825fb3096 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -7696,7 +7696,7 @@ The \fB\-E\fP option indicates that other supplied options and actions should apply to ``empty'' command completion; that is, completion attempted on a blank line. The \fB\-I\fP option indicates that other supplied options and actions should -apply to completion on the inital non-assignment word on the line, or after +apply to completion on the initial non-assignment word on the line, or after a command delimiter such as \fB;\fP or \fB|\fP, which is usually command name completion. If multiple options are supplied, the \fB\-D\fP option takes precedence @@ -7914,7 +7914,7 @@ The \fB\-E\fP option indicates that other supplied options should apply to ``empty'' command completion; that is, completion attempted on a blank line. The \fB\-I\fP option indicates that other supplied options should -apply to completion on the inital non-assignment word on the line, +apply to completion on the initial non-assignment word on the line, or after a command delimiter such as \fB;\fP or \fB|\fP, which is usually command name completion. .sp 1 diff --git a/doc/bashref.texi b/doc/bashref.texi index d33cd5710..fc0229737 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -2234,7 +2234,7 @@ array in turn, and the expansion is the resultant list. @itemx $@{@var{parameter}%%@var{word}@} The @var{word} is expanded to produce a pattern and matched according to the rules -described below (@pxref{Pattern Matching}). If the pattern matches +described below (@pxref{Pattern Matching}). If the pattern matches a trailing portion of the expanded value of @var{parameter}, then the result of the expansion is the value of @var{parameter} with the shortest matching pattern (the @samp{%} case) diff --git a/general.c b/general.c index 9542963aa..2a6edc1c9 100644 --- a/general.c +++ b/general.c @@ -338,21 +338,21 @@ check_selfref (name, value, flags) } /* Make sure that WORD is a valid shell identifier, i.e. - does not contain a dollar sign, nor is quoted in any way. Nor - does it consist of all digits. If CHECK_WORD is non-zero, + does not contain a dollar sign, nor is quoted in any way. + If CHECK_WORD is non-zero, the word is checked to ensure that it consists of only letters, - digits, and underscores. */ + digits, and underscores, and does not consist of all digits. */ int check_identifier (word, check_word) WORD_DESC *word; int check_word; { - if ((word->flags & (W_HASDOLLAR|W_QUOTED)) || all_digits (word->word)) + if (word->flags & (W_HASDOLLAR|W_QUOTED)) /* XXX - HASDOLLAR? */ { internal_error (_("`%s': not a valid identifier"), word->word); return (0); } - else if (check_word && legal_identifier (word->word) == 0) + else if (check_word && (all_digits (word->word) || legal_identifier (word->word) == 0)) { internal_error (_("`%s': not a valid identifier"), word->word); return (0); diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi index a59bd1446..9b025e471 100644 --- a/lib/readline/doc/rluser.texi +++ b/lib/readline/doc/rluser.texi @@ -2044,7 +2044,7 @@ The @option{-E} option indicates that other supplied options and actions should apply to ``empty'' command completion; that is, completion attempted on a blank line. The @option{-I} option indicates that other supplied options and actions should -apply to completion on the inital non-assignment word on the line, or after a +apply to completion on the initial non-assignment word on the line, or after a command delimiter such as @samp{;} or @samp{|}, which is usually command name completion. If multiple options are supplied, the @option{-D} option takes precedence @@ -2255,7 +2255,7 @@ The @option{-E} option indicates that other supplied options should apply to ``empty'' command completion; that is, completion attempted on a blank line. The @option{-I} option indicates that other supplied options should -apply to completion on the inital non-assignment word on the line, or after a +apply to completion on the initial non-assignment word on the line, or after a command delimiter such as @samp{;} or @samp{|}, which is usually command name completion. diff --git a/parse.y b/parse.y index 07e6e3e44..cb8e50084 100644 --- a/parse.y +++ b/parse.y @@ -2260,6 +2260,8 @@ static struct dstack temp_dstack = { (char *)NULL, 0, 0 }; shell_ungetc when we're at the start of a line. */ static int eol_ungetc_lookahead = 0; +static int unquoted_backslash = 0; + static int shell_getc (remove_quoted_newline) int remove_quoted_newline; @@ -2525,10 +2527,16 @@ shell_getc (remove_quoted_newline) } next_alias_char: +if (shell_input_line_index == 0) + unquoted_backslash = 0; + uc = shell_input_line[shell_input_line_index]; if (uc) +{ +unquoted_backslash = unquoted_backslash == 0 && uc == '\\'; shell_input_line_index++; +} #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) /* If UC is NULL, we have reached the end of the current input string. If @@ -2561,6 +2569,7 @@ next_alias_char: shell_input_line_index > 0 && shellblank (shell_input_line[shell_input_line_index-1]) == 0 && shell_input_line[shell_input_line_index-1] != '\n' && + unquoted_backslash == 0 && shellmeta (shell_input_line[shell_input_line_index-1]) == 0 && (current_delimiter (dstack) != '\'' && current_delimiter (dstack) != '"')) { diff --git a/patchlevel.h b/patchlevel.h index 1cd7c96c7..a988d8526 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 0 +#define PATCHLEVEL 2 #endif /* _PATCHLEVEL_H_ */ diff --git a/tests/alias.right b/tests/alias.right index 398c69e65..29eb90daa 100644 --- a/tests/alias.right +++ b/tests/alias.right @@ -31,3 +31,6 @@ a a b ok 3 ok 4 bar +bad +0 +<|cat> diff --git a/tests/alias4.sub b/tests/alias4.sub index b205fee75..a82f151f4 100644 --- a/tests/alias4.sub +++ b/tests/alias4.sub @@ -75,3 +75,13 @@ alias foo="\ " foo + +alias foo=$'echo bad \t' +foo + +# this should probably just echo a blank line to stdout +alias foo='echo 0' +foo>&2 + +alias a='printf "<%s>\n" \' +a|cat