commit bash-20130629 snapshot

This commit is contained in:
Chet Ramey
2013-07-16 15:48:43 -04:00
parent 47df4b885a
commit c111d99274
39 changed files with 52785 additions and 1757 deletions
+72
View File
@@ -4951,3 +4951,75 @@ examples/loadables/Makefile.in
lib/sh/pathphys.c
- sh_realpath: correct inverted two arguments to call to sh_makepath.
Report and fix from Julien Thomas <jthomas@exosec.fr>
6/7
---
execute_cmd.c
- executing_line_number: the else clauses that are conditional on
various options being defined can simply be if clauses -- they are
mutually exclusive and all have `return' in the body. Fixes bug
reported by Flavio Medeiros <flaviomotamedeiros@gmail.com>
6/25
----
lib/readline/readline.c
- readline_internal_setup: only sent the meta-key enable string to the
terminal if we've been told to use one and the terminal has been
successfully initialized (RL_ISSTATE (RL_STATE_TERMPREPPED) != 0).
Suggested by Dan Mick <dan.mick@inktank.com>
lib/readline/signals.c
- _rl_signal_handler: call any defined signal hook after calling
rl_resize_terminal when handling a SIGWINCH. We already have called
the original SIGWINCH handler but will not be resending the signal
to ourselves
6/27
----
lib/readline/doc/history.3, doc/bash.1
- fix description of the `$' modifier to note that it expands to the
last *word*, which is not always the last argument. Report from
ariyetz@gmail.com via gnu.org RT
6/29
----
lib/glob/smatch.c
- glob_asciiranges: initialize to value of GLOBASCII_DEFAULT instead
of 0 (0 if not defined)
configure.ac,config.h.in
- --enable-glob-asciiranges-default: new option, controls the value of
GLOBASCII_DEFAULT; use it to turn globasciiranges shopt option on
by default
doc/bashref.texi
- document new --enable-glob-asciiranges-default configure option
variables.c
- assign_in_env: implement += value appending semantics for assignments
preceding command names
7/4
---
expr.c
- set lasttok = NUM in all of the functions that result in a number,
even if it's a boolean, to avoid errors with constructs like
1 * x = 1, which should be an asignment error. Fixes problem
pointed out by Dan Douglas <ormaaj@gmail.com>
parse.y
- decode_prompt_string: don't bother to call strcpy if
polite_directory_format returns its argument unchanged. It's not
necessary and Mac OS X 10.9 aborts because of a supposed overlapping
string copy. Bug and fix from simon@hitzemann.org
subst.c
- parameter_brace_find_indir: new function, code from
parameter_brace_expand_indir that looks up the indirectly-referenced
variable, but does not expand it
- parameter_brace_expand_indir: call parameter_brace_find_indir to
look up indirected variable reference
- get_var_and_type: call parameter_brace_find_indir if it looks like we
are trying to manipulate an indirect variable reference like
${!b%%foo}. This makes a difference if !b references an array
variable. Bug report from Dan Douglas <ormaaj@gmail.com>
+5014
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -773,6 +773,7 @@ tests/alias1.sub f
tests/alias.right f
tests/appendop.tests f
tests/appendop1.sub f
tests/appendop2.sub f
tests/appendop.right f
tests/arith-for.tests f
tests/arith-for.right f
+1249
View File
File diff suppressed because it is too large Load Diff
+19 -1
View File
@@ -1,5 +1,5 @@
@%:@! /bin/sh
@%:@ From configure.ac for Bash 4.3, version 4.058.
@%:@ From configure.ac for Bash 4.3, version 4.059.
@%:@ Guess values for system-dependent variables and create Makefiles.
@%:@ Generated by GNU Autoconf 2.69 for bash 4.3-beta.
@%:@
@@ -809,6 +809,7 @@ enable_disabled_builtins
enable_dparen_arithmetic
enable_extended_glob
enable_extended_glob_default
enable_glob_asciiranges_default
enable_help_builtin
enable_history
enable_job_control
@@ -1497,6 +1498,9 @@ Optional Features:
--enable-extended-glob-default
force extended pattern matching to be enabled by
default
--enable-glob-asciiranges-default
force bracket range expressions in pattern matching
to use the C locale by default
--enable-help-builtin include the help builtin
--enable-history turn on command history
--enable-job-control enable job control features
@@ -2996,6 +3000,7 @@ opt_casemod_attrs=yes
opt_casemod_expansions=yes
opt_extglob_default=no
opt_dircomplete_expand_default=no
opt_globascii_default=no
opt_static_link=no
opt_profiling=no
@@ -3016,6 +3021,7 @@ if test $opt_minimal_config = yes; then
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no
opt_globascii_default=no
fi
@%:@ Check whether --enable-alias was given.
@@ -3108,6 +3114,11 @@ if test "${enable_extended_glob_default+set}" = set; then :
enableval=$enable_extended_glob_default; opt_extglob_default=$enableval
fi
@%:@ Check whether --enable-glob-asciiranges-default was given.
if test "${enable_glob_asciiranges_default+set}" = set; then :
enableval=$enable_glob_asciiranges_default; opt_globascii_default=$enableval
fi
@%:@ Check whether --enable-help-builtin was given.
if test "${enable_help_builtin+set}" = set; then :
enableval=$enable_help_builtin; opt_help=$enableval
@@ -3322,6 +3333,13 @@ fi
if test $opt_dircomplete_expand_default = yes; then
$as_echo "@%:@define DIRCOMPLETE_EXPAND_DEFAULT 1" >>confdefs.h
fi
if test $opt_globascii_default = yes; then
$as_echo "@%:@define GLOBASCII_DEFAULT 1" >>confdefs.h
else
$as_echo "@%:@define GLOBASCII_DEFAULT 0" >>confdefs.h
fi
if test $opt_memscramble = yes; then
+1706 -1699
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -170,6 +170,9 @@
/* Define to make the `direxpand' shopt option enabled by default. */
#undef DIRCOMPLETE_EXPAND_DEFAULT
/* Define to make the `globasciiranges' shopt option enabled by default. */
#undef GLOBASCII_DEFAULT
/* Define AFS if you are using Transarc's AFS. */
#undef AFS
+1151
View File
File diff suppressed because it is too large Load Diff
Vendored
+19 -1
View File
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac for Bash 4.3, version 4.058.
# From configure.ac for Bash 4.3, version 4.059.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for bash 4.3-beta.
#
@@ -809,6 +809,7 @@ enable_disabled_builtins
enable_dparen_arithmetic
enable_extended_glob
enable_extended_glob_default
enable_glob_asciiranges_default
enable_help_builtin
enable_history
enable_job_control
@@ -1497,6 +1498,9 @@ Optional Features:
--enable-extended-glob-default
force extended pattern matching to be enabled by
default
--enable-glob-asciiranges-default
force bracket range expressions in pattern matching
to use the C locale by default
--enable-help-builtin include the help builtin
--enable-history turn on command history
--enable-job-control enable job control features
@@ -2996,6 +3000,7 @@ opt_casemod_attrs=yes
opt_casemod_expansions=yes
opt_extglob_default=no
opt_dircomplete_expand_default=no
opt_globascii_default=no
opt_static_link=no
opt_profiling=no
@@ -3016,6 +3021,7 @@ if test $opt_minimal_config = yes; then
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no
opt_globascii_default=no
fi
# Check whether --enable-alias was given.
@@ -3108,6 +3114,11 @@ if test "${enable_extended_glob_default+set}" = set; then :
enableval=$enable_extended_glob_default; opt_extglob_default=$enableval
fi
# Check whether --enable-glob-asciiranges-default was given.
if test "${enable_glob_asciiranges_default+set}" = set; then :
enableval=$enable_glob_asciiranges_default; opt_globascii_default=$enableval
fi
# Check whether --enable-help-builtin was given.
if test "${enable_help_builtin+set}" = set; then :
enableval=$enable_help_builtin; opt_help=$enableval
@@ -3322,6 +3333,13 @@ fi
if test $opt_dircomplete_expand_default = yes; then
$as_echo "#define DIRCOMPLETE_EXPAND_DEFAULT 1" >>confdefs.h
fi
if test $opt_globascii_default = yes; then
$as_echo "#define GLOBASCII_DEFAULT 1" >>confdefs.h
else
$as_echo "#define GLOBASCII_DEFAULT 0" >>confdefs.h
fi
if test $opt_memscramble = yes; then
+9 -1
View File
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Bash 4.3, version 4.058])dnl
AC_REVISION([for Bash 4.3, version 4.059])dnl
define(bashvers, 4.3)
define(relstatus, beta)
@@ -191,6 +191,7 @@ opt_casemod_attrs=yes
opt_casemod_expansions=yes
opt_extglob_default=no
opt_dircomplete_expand_default=no
opt_globascii_default=no
dnl options that affect how bash is compiled and linked
opt_static_link=no
@@ -211,6 +212,7 @@ if test $opt_minimal_config = yes; then
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no
opt_globascii_default=no
fi
AC_ARG_ENABLE(alias, AC_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval)
@@ -231,6 +233,7 @@ AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [a
AC_ARG_ENABLE(dparen-arithmetic, AC_HELP_STRING([--enable-dparen-arithmetic], [include ((...)) command]), opt_dparen_arith=$enableval)
AC_ARG_ENABLE(extended-glob, AC_HELP_STRING([--enable-extended-glob], [include ksh-style extended pattern matching]), opt_extended_glob=$enableval)
AC_ARG_ENABLE(extended-glob-default, AC_HELP_STRING([--enable-extended-glob-default], [force extended pattern matching to be enabled by default]), opt_extglob_default=$enableval)
AC_ARG_ENABLE(glob-asciiranges-default, AC_HELP_STRING([--enable-glob-asciiranges-default], [force bracket range expressions in pattern matching to use the C locale by default]), opt_globascii_default=$enableval)
AC_ARG_ENABLE(help-builtin, AC_HELP_STRING([--enable-help-builtin], [include the help builtin]), opt_help=$enableval)
AC_ARG_ENABLE(history, AC_HELP_STRING([--enable-history], [turn on command history]), opt_history=$enableval)
AC_ARG_ENABLE(job-control, AC_HELP_STRING([--enable-job-control], [enable job control features]), opt_job_control=$enableval)
@@ -348,6 +351,11 @@ fi
if test $opt_dircomplete_expand_default = yes; then
AC_DEFINE(DIRCOMPLETE_EXPAND_DEFAULT)
fi
if test $opt_globascii_default = yes; then
AC_DEFINE(GLOBASCII_DEFAULT, 1)
else
AC_DEFINE(GLOBASCII_DEFAULT, 0)
fi
if test $opt_memscramble = yes; then
AC_DEFINE(MEMSCRAMBLE)
+1209
View File
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Thu Mar 21 10:09:25 EDT 2013
.\" Last Change: Thu Jun 27 10:36:53 EDT 2013
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2013 March 21" "GNU Bash 4.3"
.TH BASH 1 "2013 June 27" "GNU Bash 4.3"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -5737,7 +5737,7 @@ the first call) of each line in turn.
Any numeric argument supplied to these successive calls determines
the direction to move through the history. A negative argument switches
the direction through the history (back or forward).
The history expansion facilities are used to extract the last argument,
The history expansion facilities are used to extract the last word,
as if the "!$" history expansion had been specified.
.TP
.B shell\-expand\-line (M\-C\-e)
@@ -6673,7 +6673,8 @@ The \fIn\fRth word.
The first argument. That is, word 1.
.TP
.B $
The last argument.
The last word. This is usually the last argument, but will expand to the
zeroth word if there is only one word in the line.
.TP
.B %
The word matched by the most recent `?\fIstring\fR?' search.
@@ -9391,7 +9392,7 @@ above for a description of
This option is enabled by default.
.TP 8
.B globasciiranges
If set, range expressions used in pattern matching (see
If set, range expressions used in pattern matching bracket expressions (see
.SM
.B Pattern Matching
above) behave as if in the traditional C locale when performing
+10304
View File
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -5046,7 +5046,8 @@ the ignored words are the only possible completions.
This option is enabled by default.
@item globasciiranges
If set, range expressions used in pattern matching (@pxref{Pattern Matching})
If set, range expressions used in pattern matching bracket expressions
(@pxref{Pattern Matching})
behave as if in the traditional C locale when performing
comparisons. That is, the current locale's collating sequence
is not taken into account, so
@@ -8076,6 +8077,12 @@ above under @ref{Pattern Matching}.
Set the default value of the @var{extglob} shell option described
above under @ref{The Shopt Builtin} to be enabled.
@item --enable-glob-asciirange-default
Set the default value of the @var{globasciiranges} shell option described
above under @ref{The Shopt Builtin} to be enabled.
This controls the behavior of character ranges when used in pattern matching
bracket expressions.
@item --enable-help-builtin
Include the @code{help} builtin, which displays help on shell builtins and
variables (@pxref{Bash Builtins}).
+8718
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -2,9 +2,9 @@
Copyright (C) 1988-2013 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Thu Mar 21 10:09:44 EDT 2013
@set LASTCHANGE Sat Jun 29 17:48:07 EDT 2013
@set EDITION 4.3
@set VERSION 4.3
@set UPDATED 21 March 2013
@set UPDATED-MONTH March 2013
@set UPDATED 29 June 2013
@set UPDATED-MONTH June 2013
+10
View File
@@ -0,0 +1,10 @@
@ignore
Copyright (C) 1988-2013 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Thu Mar 21 10:09:44 EDT 2013
@set EDITION 4.3
@set VERSION 4.3
@set UPDATED 21 March 2013
@set UPDATED-MONTH March 2013
+2 -2
View File
@@ -353,11 +353,11 @@ executing_line_number ()
return currently_executing_command->value.Cond->line;
#endif
#if defined (DPAREN_ARITHMETIC)
else if (currently_executing_command->type == cm_arith)
if (currently_executing_command->type == cm_arith)
return currently_executing_command->value.Arith->line;
#endif
#if defined (ARITH_FOR_COMMAND)
else if (currently_executing_command->type == cm_arith_for)
if (currently_executing_command->type == cm_arith_for)
return currently_executing_command->value.ArithFor->line;
#endif
+13
View File
@@ -681,6 +681,7 @@ expbor ()
readtok ();
val2 = expbxor ();
val1 = val1 | val2;
lasttok = NUM;
}
return (val1);
@@ -699,6 +700,7 @@ expbxor ()
readtok ();
val2 = expband ();
val1 = val1 ^ val2;
lasttok = NUM;
}
return (val1);
@@ -717,6 +719,7 @@ expband ()
readtok ();
val2 = exp5 ();
val1 = val1 & val2;
lasttok = NUM;
}
return (val1);
@@ -739,6 +742,7 @@ exp5 ()
val1 = (val1 == val2);
else if (op == NEQ)
val1 = (val1 != val2);
lasttok = NUM;
}
return (val1);
}
@@ -767,6 +771,7 @@ exp4 ()
val1 = val1 < val2;
else /* (op == GT) */
val1 = val1 > val2;
lasttok = NUM;
}
return (val1);
}
@@ -790,6 +795,7 @@ expshift ()
val1 = val1 << val2;
else
val1 = val1 >> val2;
lasttok = NUM;
}
return (val1);
@@ -813,6 +819,7 @@ exp3 ()
val1 += val2;
else if (op == MINUS)
val1 -= val2;
lasttok = NUM;
}
return (val1);
}
@@ -864,6 +871,7 @@ exp2 ()
#else
val1 = (op == DIV) ? val1 / val2 : val1 % val2;
#endif
lasttok = NUM;
}
return (val1);
}
@@ -895,6 +903,7 @@ exppower ()
{
readtok ();
val2 = exppower (); /* exponentiation is right-associative */
lasttok = NUM;
if (val2 == 0)
return (1);
if (val2 < 0)
@@ -913,21 +922,25 @@ exp1 ()
{
readtok ();
val = !exp1 ();
lasttok = NUM;
}
else if (curtok == BNOT)
{
readtok ();
val = ~exp1 ();
lasttok = NUM;
}
else if (curtok == MINUS)
{
readtok ();
val = - exp1 ();
lasttok = NUM;
}
else if (curtok == PLUS)
{
readtok ();
val = exp1 ();
lasttok = NUM;
}
else
val = exp0 ();
+1558
View File
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -43,7 +43,11 @@
#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
#define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
int glob_asciirange = 0;
#ifndef GLOBASCII_DEFAULT
# define GLOBASCII_DEFAULT 0
#endif
int glob_asciirange = GLOBASCII_DEFAULT;
/* We use strcoll(3) for range comparisons in bracket expressions,
even though it can have unwanted side effects in locales
+411
View File
@@ -0,0 +1,411 @@
/* strmatch.c -- ksh-like extended pattern matching for the shell and filename
globbing. */
/* Copyright (C) 1991-2011 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 <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h> /* for debugging */
#include "strmatch.h"
#include <chartypes.h>
#include "bashansi.h"
#include "shmbutil.h"
#include "xmalloc.h"
/* First, compile `sm_loop.c' for single-byte characters. */
#define CHAR unsigned char
#define U_CHAR unsigned char
#define XCHAR char
#define INT int
#define L(CS) CS
#define INVALID -1
#undef STREQ
#undef STREQN
#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
#define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
int glob_asciirange = 0;
/* We use strcoll(3) for range comparisons in bracket expressions,
even though it can have unwanted side effects in locales
other than POSIX or US. For instance, in the de locale, [A-Z] matches
all characters. If GLOB_ASCIIRANGE is non-zero, and we're not forcing
the use of strcoll (e.g., for explicit collating symbols), we use
straight ordering as if in the C locale. */
#if defined (HAVE_STRCOLL)
/* Helper function for collating symbol equivalence. */
static int
rangecmp (c1, c2, forcecoll)
int c1, c2;
int forcecoll;
{
static char s1[2] = { ' ', '\0' };
static char s2[2] = { ' ', '\0' };
int ret;
/* Eight bits only. Period. */
c1 &= 0xFF;
c2 &= 0xFF;
if (c1 == c2)
return (0);
if (forcecoll == 0 && glob_asciirange)
return (c1 - c2);
s1[0] = c1;
s2[0] = c2;
if ((ret = strcoll (s1, s2)) != 0)
return ret;
return (c1 - c2);
}
#else /* !HAVE_STRCOLL */
# define rangecmp(c1, c2, f) ((int)(c1) - (int)(c2))
#endif /* !HAVE_STRCOLL */
#if defined (HAVE_STRCOLL)
static int
collequiv (c1, c2)
int c1, c2;
{
return (rangecmp (c1, c2, 1) == 0);
}
#else
# define collequiv(c1, c2) ((c1) == (c2))
#endif
#define _COLLSYM _collsym
#define __COLLSYM __collsym
#define POSIXCOLL posix_collsyms
#include "collsyms.h"
static int
collsym (s, len)
CHAR *s;
int len;
{
register struct _collsym *csp;
char *x;
x = (char *)s;
for (csp = posix_collsyms; csp->name; csp++)
{
if (STREQN(csp->name, x, len) && csp->name[len] == '\0')
return (csp->code);
}
if (len == 1)
return s[0];
return INVALID;
}
/* unibyte character classification */
#if !defined (isascii) && !defined (HAVE_ISASCII)
# define isascii(c) ((unsigned int)(c) <= 0177)
#endif
enum char_class
{
CC_NO_CLASS = 0,
CC_ASCII, CC_ALNUM, CC_ALPHA, CC_BLANK, CC_CNTRL, CC_DIGIT, CC_GRAPH,
CC_LOWER, CC_PRINT, CC_PUNCT, CC_SPACE, CC_UPPER, CC_WORD, CC_XDIGIT
};
static char const *const cclass_name[] =
{
"",
"ascii", "alnum", "alpha", "blank", "cntrl", "digit", "graph",
"lower", "print", "punct", "space", "upper", "word", "xdigit"
};
#define N_CHAR_CLASS (sizeof(cclass_name) / sizeof (cclass_name[0]))
static int
is_cclass (c, name)
int c;
const char *name;
{
enum char_class char_class = CC_NO_CLASS;
int i, result;
for (i = 1; i < N_CHAR_CLASS; i++)
{
if (STREQ (name, cclass_name[i]))
{
char_class = (enum char_class)i;
break;
}
}
if (char_class == 0)
return -1;
switch (char_class)
{
case CC_ASCII:
result = isascii (c);
break;
case CC_ALNUM:
result = ISALNUM (c);
break;
case CC_ALPHA:
result = ISALPHA (c);
break;
case CC_BLANK:
result = ISBLANK (c);
break;
case CC_CNTRL:
result = ISCNTRL (c);
break;
case CC_DIGIT:
result = ISDIGIT (c);
break;
case CC_GRAPH:
result = ISGRAPH (c);
break;
case CC_LOWER:
result = ISLOWER (c);
break;
case CC_PRINT:
result = ISPRINT (c);
break;
case CC_PUNCT:
result = ISPUNCT (c);
break;
case CC_SPACE:
result = ISSPACE (c);
break;
case CC_UPPER:
result = ISUPPER (c);
break;
case CC_WORD:
result = (ISALNUM (c) || c == '_');
break;
case CC_XDIGIT:
result = ISXDIGIT (c);
break;
default:
result = -1;
break;
}
return result;
}
/* Now include `sm_loop.c' for single-byte characters. */
/* The result of FOLD is an `unsigned char' */
# define FOLD(c) ((flags & FNM_CASEFOLD) \
? TOLOWER ((unsigned char)c) \
: ((unsigned char)c))
#define FCT internal_strmatch
#define GMATCH gmatch
#define COLLSYM collsym
#define PARSE_COLLSYM parse_collsym
#define BRACKMATCH brackmatch
#define PATSCAN glob_patscan
#define STRCOMPARE strcompare
#define EXTMATCH extmatch
#define STRCHR(S, C) strchr((S), (C))
#define STRCOLL(S1, S2) strcoll((S1), (S2))
#define STRLEN(S) strlen(S)
#define STRCMP(S1, S2) strcmp((S1), (S2))
#define RANGECMP(C1, C2, F) rangecmp((C1), (C2), (F))
#define COLLEQUIV(C1, C2) collequiv((C1), (C2))
#define CTYPE_T enum char_class
#define IS_CCLASS(C, S) is_cclass((C), (S))
#include "sm_loop.c"
#if HANDLE_MULTIBYTE
# define CHAR wchar_t
# define U_CHAR wint_t
# define XCHAR wchar_t
# define INT wint_t
# define L(CS) L##CS
# define INVALID WEOF
# undef STREQ
# undef STREQN
# define STREQ(s1, s2) ((wcscmp (s1, s2) == 0))
# define STREQN(a, b, n) ((a)[0] == (b)[0] && wcsncmp(a, b, n) == 0)
extern char *mbsmbchar __P((const char *));
static int
rangecmp_wc (c1, c2, forcecoll)
wint_t c1, c2;
int forcecoll;
{
static wchar_t s1[2] = { L' ', L'\0' };
static wchar_t s2[2] = { L' ', L'\0' };
if (c1 == c2)
return 0;
if (forcecoll == 0 && glob_asciirange && c1 <= UCHAR_MAX && c2 <= UCHAR_MAX)
return ((int)(c1 - c2));
s1[0] = c1;
s2[0] = c2;
return (wcscoll (s1, s2));
}
static int
collequiv_wc (c, equiv)
wint_t c, equiv;
{
return (c == equiv);
}
/* Helper function for collating symbol. */
# define _COLLSYM _collwcsym
# define __COLLSYM __collwcsym
# define POSIXCOLL posix_collwcsyms
# include "collsyms.h"
static wint_t
collwcsym (s, len)
wchar_t *s;
int len;
{
register struct _collwcsym *csp;
for (csp = posix_collwcsyms; csp->name; csp++)
{
if (STREQN(csp->name, s, len) && csp->name[len] == L'\0')
return (csp->code);
}
if (len == 1)
return s[0];
return INVALID;
}
static int
is_wcclass (wc, name)
wint_t wc;
wchar_t *name;
{
char *mbs;
mbstate_t state;
size_t mbslength;
wctype_t desc;
int want_word;
if ((wctype ("ascii") == (wctype_t)0) && (wcscmp (name, L"ascii") == 0))
{
int c;
if ((c = wctob (wc)) == EOF)
return 0;
else
return (c <= 0x7F);
}
want_word = (wcscmp (name, L"word") == 0);
if (want_word)
name = L"alnum";
memset (&state, '\0', sizeof (mbstate_t));
mbs = (char *) malloc (wcslen(name) * MB_CUR_MAX + 1);
mbslength = wcsrtombs (mbs, (const wchar_t **)&name, (wcslen(name) * MB_CUR_MAX + 1), &state);
if (mbslength == (size_t)-1 || mbslength == (size_t)-2)
{
free (mbs);
return -1;
}
desc = wctype (mbs);
free (mbs);
if (desc == (wctype_t)0)
return -1;
if (want_word)
return (iswctype (wc, desc) || wc == L'_');
else
return (iswctype (wc, desc));
}
/* Now include `sm_loop.c' for multibyte characters. */
#define FOLD(c) ((flags & FNM_CASEFOLD) && iswupper (c) ? towlower (c) : (c))
#define FCT internal_wstrmatch
#define GMATCH gmatch_wc
#define COLLSYM collwcsym
#define PARSE_COLLSYM parse_collwcsym
#define BRACKMATCH brackmatch_wc
#define PATSCAN glob_patscan_wc
#define STRCOMPARE wscompare
#define EXTMATCH extmatch_wc
#define STRCHR(S, C) wcschr((S), (C))
#define STRCOLL(S1, S2) wcscoll((S1), (S2))
#define STRLEN(S) wcslen(S)
#define STRCMP(S1, S2) wcscmp((S1), (S2))
#define RANGECMP(C1, C2, F) rangecmp_wc((C1), (C2), (F))
#define COLLEQUIV(C1, C2) collequiv_wc((C1), (C2))
#define CTYPE_T enum char_class
#define IS_CCLASS(C, S) is_wcclass((C), (S))
#include "sm_loop.c"
#endif /* HAVE_MULTIBYTE */
int
xstrmatch (pattern, string, flags)
char *pattern;
char *string;
int flags;
{
#if HANDLE_MULTIBYTE
int ret;
size_t n;
wchar_t *wpattern, *wstring;
size_t plen, slen, mplen, mslen;
if (mbsmbchar (string) == 0 && mbsmbchar (pattern) == 0)
return (internal_strmatch ((unsigned char *)pattern, (unsigned char *)string, flags));
if (MB_CUR_MAX == 1)
return (internal_strmatch ((unsigned char *)pattern, (unsigned char *)string, flags));
n = xdupmbstowcs (&wpattern, NULL, pattern);
if (n == (size_t)-1 || n == (size_t)-2)
return (internal_strmatch ((unsigned char *)pattern, (unsigned char *)string, flags));
n = xdupmbstowcs (&wstring, NULL, string);
if (n == (size_t)-1 || n == (size_t)-2)
{
free (wpattern);
return (internal_strmatch ((unsigned char *)pattern, (unsigned char *)string, flags));
}
ret = internal_wstrmatch (wpattern, wstring, flags);
free (wpattern);
free (wstring);
return ret;
#else
return (internal_strmatch ((unsigned char *)pattern, (unsigned char *)string, flags));
#endif /* !HANDLE_MULTIBYTE */
}
+4 -3
View File
@@ -6,9 +6,9 @@
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
.\" Last Change: Thu Aug 12 22:24:41 EDT 2010
.\" Last Change: Thu Thu Jun 27 10:34:44 EDT 2013
.\"
.TH HISTORY 3 "2010 August 12" "GNU History 6.2"
.TH HISTORY 3 "2013 June 27" "GNU History 6.2"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@@ -161,7 +161,8 @@ The \fIn\fRth word.
The first argument. That is, word 1.
.TP
.B $
The last argument.
The last word. This is usually the last argument, but will expand to the
zeroth word if there is only one word in the line.
.TP
.B %
The word matched by the most recent `?\fIstring\fR?' search.
+5 -3
View File
@@ -397,8 +397,8 @@ readline_internal_setup ()
_rl_out_stream = rl_outstream;
/* Enable the meta key only for the duration of readline(), if this
terminal has one. */
if (_rl_enable_meta)
terminal has one and the terminal has been initialized */
if (_rl_enable_meta & RL_ISSTATE (RL_STATE_TERMPREPPED))
_rl_enable_meta_key ();
if (rl_startup_hook)
@@ -469,7 +469,9 @@ readline_internal_teardown (eof)
if (rl_undo_list)
rl_free_undo_list ();
/* Disable the meta key, if this terminal has one. */
/* Disable the meta key, if this terminal has one and we were told to use it.
The check whether or not we sent the enable string is in
_rl_disable_meta_key(); the flag is set in _rl_enable_meta_key */
_rl_disable_meta_key ();
/* Restore normal cursor, if available. */
+10 -1
View File
@@ -141,10 +141,19 @@ _rl_signal_handler (sig)
#if defined (SIGWINCH)
if (sig == SIGWINCH)
rl_resize_terminal ();
{
rl_resize_terminal ();
/* XXX - experimental for now */
/* Call a signal hook because though we called the original signal handler
in rl_sigwinch_handler below, we will not resend the signal to
ourselves. */
if (rl_signal_event_hook)
(*rl_signal_event_hook) ();
}
else
#endif
_rl_handle_signal (sig);
SIGHANDLER_RETURN;
}
+7 -3
View File
@@ -5356,9 +5356,13 @@ decode_prompt_string (string)
#undef ROOT_PATH
#undef DOUBLE_SLASH_ROOT
else
/* polite_directory_format is guaranteed to return a string
no longer than PATH_MAX - 1 characters. */
strcpy (t_string, polite_directory_format (t_string));
{
/* polite_directory_format is guaranteed to return a string
no longer than PATH_MAX - 1 characters. */
temp = polite_directory_format (t_string);
if (temp != t_string)
strcpy (t_string, temp);
}
temp = trim_pathname (t_string, PATH_MAX - 1);
/* If we're going to be expanding the prompt string later,
+6152
View File
File diff suppressed because it is too large Load Diff
+55 -24
View File
@@ -277,6 +277,7 @@ static int chk_atstar __P((char *, int, int *, int *));
static int chk_arithsub __P((const char *, int));
static WORD_DESC *parameter_brace_expand_word __P((char *, int, int, int, arrayind_t *));
static char *parameter_brace_find_indir __P((char *, int, int, int));
static WORD_DESC *parameter_brace_expand_indir __P((char *, int, int, int *, int *));
static WORD_DESC *parameter_brace_expand_rhs __P((char *, char *, int, int, int *, int *));
static void parameter_brace_expand_error __P((char *, char *));
@@ -5807,6 +5808,38 @@ expand_arrayref:
return ret;
}
static char *
parameter_brace_find_indir (name, var_is_special, quoted, find_nameref)
char *name;
int var_is_special, quoted, find_nameref;
{
char *temp, *t;
WORD_DESC *w;
SHELL_VAR *v;
if (find_nameref && var_is_special == 0 && (v = find_variable_last_nameref (name)) &&
nameref_p (v) && (t = nameref_cell (v)) && *t)
return (savestring (t));
/* If var_is_special == 0, and name is not an array reference, this does
more expansion than necessary. It should really look up the variable's
value and not try to expand it. */
w = parameter_brace_expand_word (name, var_is_special, quoted, PF_IGNUNBOUND, 0);
t = w->word;
/* Have to dequote here if necessary */
if (t)
{
temp = (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
? dequote_string (t)
: dequote_escapes (t);
free (t);
t = temp;
}
dispose_word_desc (w);
return t;
}
/* Expand an indirect reference to a variable: ${!NAME} expands to the
value of the variable whose name is the value of NAME. */
static WORD_DESC *
@@ -5835,21 +5868,7 @@ parameter_brace_expand_indir (name, var_is_special, quoted, quoted_dollar_atp, c
}
}
/* If var_is_special == 0, and name is not an array reference, this does
more expansion than necessary. It should really look up the variable's
value and not try to expand it. */
w = parameter_brace_expand_word (name, var_is_special, quoted, PF_IGNUNBOUND, 0);
t = w->word;
/* Have to dequote here if necessary */
if (t)
{
temp = (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
? dequote_string (t)
: dequote_escapes (t);
free (t);
t = temp;
}
dispose_word_desc (w);
t = parameter_brace_find_indir (name, var_is_special, quoted, 0);
chk_atstar (t, quoted, quoted_dollar_atp, contains_dollar_at);
if (t == 0)
@@ -6303,23 +6322,32 @@ get_var_and_type (varname, value, ind, quoted, flags, varp, valp)
SHELL_VAR **varp;
char **valp;
{
int vtype;
char *temp;
int vtype, want_indir;
char *temp, *vname;
WORD_DESC *wd;
#if defined (ARRAY_VARS)
SHELL_VAR *v;
#endif
arrayind_t lind;
want_indir = *varname == '!' &&
(legal_variable_starter ((unsigned char)varname[1]) || DIGIT (varname[1])
|| VALID_INDIR_PARAM (varname[1]));
if (want_indir)
vname = parameter_brace_find_indir (varname+1, SPECIAL_VAR (varname, 1), quoted, 1);
else
vname = varname;
/* This sets vtype to VT_VARIABLE or VT_POSPARMS */
vtype = (varname[0] == '@' || varname[0] == '*') && varname[1] == '\0';
if (vtype == VT_POSPARMS && varname[0] == '*')
vtype = (vname[0] == '@' || vname[0] == '*') && vname[1] == '\0';
if (vtype == VT_POSPARMS && vname[0] == '*')
vtype |= VT_STARSUB;
*varp = (SHELL_VAR *)NULL;
#if defined (ARRAY_VARS)
if (valid_array_reference (varname))
if (valid_array_reference (vname))
{
v = array_variable_part (varname, &temp, (int *)0);
v = array_variable_part (vname, &temp, (int *)0);
/* If we want to signal array_value to use an already-computed index,
set LIND to that index */
lind = (ind != INTMAX_MIN && (flags & AV_USEIND)) ? ind : 0;
@@ -6342,7 +6370,7 @@ get_var_and_type (varname, value, ind, quoted, flags, varp, valp)
else
{
vtype = VT_ARRAYMEMBER;
*valp = array_value (varname, Q_DOUBLE_QUOTES, flags, (int *)NULL, &lind);
*valp = array_value (vname, Q_DOUBLE_QUOTES, flags, (int *)NULL, &lind);
}
*varp = v;
}
@@ -6359,10 +6387,10 @@ get_var_and_type (varname, value, ind, quoted, flags, varp, valp)
{
vtype = VT_ARRAYMEMBER;
*varp = v;
*valp = array_value (varname, Q_DOUBLE_QUOTES, flags, (int *)NULL, &lind);
*valp = array_value (vname, Q_DOUBLE_QUOTES, flags, (int *)NULL, &lind);
}
}
else if ((v = find_variable (varname)) && (invisible_p (v) == 0) && (assoc_p (v) || array_p (v)))
else if ((v = find_variable (vname)) && (invisible_p (v) == 0) && (assoc_p (v) || array_p (v)))
{
vtype = VT_ARRAYMEMBER;
*varp = v;
@@ -6382,6 +6410,9 @@ get_var_and_type (varname, value, ind, quoted, flags, varp, valp)
*valp = value;
}
if (want_indir)
free (vname);
return vtype;
}
+9639
View File
File diff suppressed because it is too large Load Diff
+8 -3
View File
@@ -8,13 +8,14 @@ DIR=$PARENT/$FROOT
TARF=${FROOT}.tar
SRC=/usr/homes/chet/src/bash/src
fflag= sflag=
while getopts "fs" opt
fflag= sflag= dflag=
while getopts "dfs" opt
do
case $opt in
f) fflag=1 ;;
s) sflag=1 ;;
*) echo "mk-takehome: usage: mk-takehome [-fs]" 2>&1
d) dflag=1 ;;
*) echo "mk-takehome: usage: mk-takehome [-dfs]" 2>&1
exit 2;;
esac
done
@@ -55,3 +56,7 @@ REMHOST=z4
if [ -n "$sflag" ]; then
scp ${TARF}.gz ${REMHOST}:
fi
if [ -n "$dflag" ]; then
cp ${TARF}.gz $HOME/Dropbox/
fi
+1 -1
View File
@@ -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
+9
View File
@@ -0,0 +1,9 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
export THIS_SH PATH
rm -f /tmp/xx
/bin/sh "$@"
+7 -2
View File
@@ -1,7 +1,7 @@
14
1 2 3 4 5 6
1 2 3 4 51 6
5
145
14
7
42
@@ -15,9 +15,14 @@
4
9
16
./appendop.tests: line 83: x: readonly variable
./appendop.tests: line 84: x: readonly variable
declare -A foo='([one]="bar" [two]="baz" [three]="quux" )'
declare -A foo='([one]="bar" [two]="baz" [0]="zero" [three]="quux" )'
declare -A foo='([four]="four" [one]="bar" [two]="baz" [0]="zero" [three]="quux" )'
declare -ai iarr='([0]="3" [1]="2" [2]="3")'
declare -ai iarr='([0]="3" [1]="2" [2]="3" [3]="4" [4]="5" [5]="6")'
25 25
7 7
14
145
145 145
+3 -1
View File
@@ -12,7 +12,8 @@ x[4]+=1
echo ${x[@]}
# trickier cases
# post-bash-4.2: bash understands += in environment assignments preceding
# command names
a+=5 printenv a
echo $a
@@ -83,3 +84,4 @@ echo $x
x+=5
${THIS_SH} ./appendop1.sub
${THIS_SH} ./appendop2.sub
+86
View File
@@ -0,0 +1,86 @@
# basic cases
a=1
a+=4
echo $a
x=(1 2 3)
x+=(4 5 6)
echo ${x[@]}
x[4]+=1
echo ${x[@]}
# trickier cases
# post-bash-4.2: bash understands += in environment assignments preceding
# command names
a+=5 printenv a
echo $a
# if the integer flag is set, ksh93 appears to do arithmetic += and evaluate
# old value as an arithmetic expression
a=
typeset -i a
a+=7
echo $a
b=4+1
typeset -i b
b+=37
echo $b
unset x
x=(1 2 3 4 5)
typeset -i x
x[4]+=7
echo ${x[@]}
unset x
typeset -i x
x=([0]=7+11)
echo ${x[@]}
unset x
x=(1 2 3 4 5)
typeset -i x
#x[4]=7+11
x=(1 2 3 4 [4]=7+11 )
echo ${x[@]}
x=( 1 2 [2]+=7 4 5 )
echo ${x[@]}
x+=( [3]+=9 [5]=9 )
echo ${x[@]}
unset a
a=1
export a+=4
printenv a
printenv a+
unset x
typeset -i x=4+5
echo $x
unset x
typeset x+=4
echo $x
typeset -i x+=5
echo $x
readonly x+=7
echo $x
x+=5
${THIS_SH} ./appendop1.sub
+18
View File
@@ -0,0 +1,18 @@
POSIXLY_CORRECT=1
x=2
x+=5 eval printf '"$x "'
echo "$x"
unset x
typeset -i x=2
x+=5 eval printf '"$x "'
echo "$x"
a=1
a+=4
echo $a
# idiotically, ksh93 makes these two cases differ (?)
a+=5 printenv a
a+=5 eval printf '"$a "'
echo $a
+1
View File
@@ -361,6 +361,7 @@ run_pending_traps ()
}
else
{
/* XXX - should we use save_parser_state/restore_parser_state? */
token_state = save_token_state ();
save_subst_varlist = subst_assign_varlist;
subst_assign_varlist = 0;
+13 -2
View File
@@ -2874,13 +2874,14 @@ assign_in_env (word, flags)
WORD_DESC *word;
int flags;
{
int offset;
int offset, aflags;
char *name, *temp, *value;
SHELL_VAR *var;
const char *string;
string = word->word;
aflags = 0;
offset = assignment (string, 0);
name = savestring (string);
value = (char *)NULL;
@@ -2891,7 +2892,10 @@ assign_in_env (word, flags)
/* ignore the `+' when assigning temporary environment */
if (name[offset - 1] == '+')
name[offset - 1] = '\0';
{
name[offset - 1] = '\0';
aflags |= ASS_APPEND;
}
var = find_variable (name);
if (var && (readonly_p (var) || noassign_p (var)))
@@ -2904,6 +2908,13 @@ assign_in_env (word, flags)
temp = name + offset + 1;
value = expand_assignment_string_to_string (temp, 0);
if (var && (aflags & ASS_APPEND))
{
temp = make_variable_value (var, value, aflags);
FREE (value);
value = temp;
}
}
if (temporary_env == 0)
+5277
View File
File diff suppressed because it is too large Load Diff