commit bash-20150320 snapshot

This commit is contained in:
Chet Ramey
2015-03-25 10:08:06 -04:00
parent 0568080fce
commit 06c3a57511
35 changed files with 460 additions and 80 deletions
+1 -1
View File
@@ -232,7 +232,7 @@ print_alias (alias, flags)
value = sh_single_quote (alias->value);
if (flags & AL_REUSABLE)
printf ("alias ");
printf ("alias %s", (alias->name && alias->name[0] == '-') ? "-- " : "");
printf ("%s=%s\n", alias->name, value);
free (value);
+5 -3
View File
@@ -506,13 +506,13 @@ declare_internal (list, local_var)
if (flags_on & att_assoc)
{
var = make_new_assoc_variable (name);
if (offset == 0 && no_invisible_vars == 0)
if (var && offset == 0 && no_invisible_vars == 0)
VSETATTR (var, att_invisible);
}
else if ((flags_on & att_array) || making_array_special)
{
var = make_new_array_variable (name);
if (offset == 0 && no_invisible_vars == 0)
if (var && offset == 0 && no_invisible_vars == 0)
VSETATTR (var, att_invisible);
}
else
@@ -522,9 +522,11 @@ declare_internal (list, local_var)
else
{
var = mkglobal ? bind_global_variable (name, (char *)NULL, 0) : bind_variable (name, (char *)NULL, 0);
if (no_invisible_vars == 0)
if (var && no_invisible_vars == 0)
VSETATTR (var, att_invisible);
}
if (var == 0)
NEXT_VARIABLE ();
}
/* Can't take an existing array variable and make it a nameref */
else if ((array_p (var) || assoc_p (var)) && (flags_on & att_nameref))
+9 -7
View File
@@ -2,7 +2,7 @@ This file is mapfile.def, from which is created mapfile.c.
It implements the builtin "mapfile" in Bash.
Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc.
Copyright (C) 2008-2012 Free Software Foundation, Inc.
Copyright (C) 2008-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -23,7 +23,7 @@ $PRODUCES mapfile.c
$BUILTIN mapfile
$FUNCTION mapfile_builtin
$SHORT_DOC mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
$SHORT_DOC mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
Read lines from the standard input into an indexed array variable.
Read lines from the standard input into the indexed array variable ARRAY, or
@@ -31,10 +31,11 @@ from file descriptor FD if the -u option is supplied. The variable MAPFILE
is the default ARRAY.
Options:
-d delim Use DELIM to terminate lines, instead of newline
-n count Copy at most COUNT lines. If COUNT is 0, all lines are copied
-O origin Begin assigning to ARRAY at index ORIGIN. The default index is 0
-s count Discard the first COUNT lines read
-t Remove a trailing newline from each line read
-t Remove a trailing DELIM from each line read (default newline)
-u fd Read lines from file descriptor FD instead of the standard input
-C callback Evaluate CALLBACK each time QUANTUM lines are read
-c quantum Specify the number of lines read between each call to
@@ -132,13 +133,14 @@ run_callback (callback, curindex, curline)
}
static void
do_chop(line)
char * line;
do_chop(line, delim)
char *line;
unsigned char delim;
{
int length;
length = strlen (line);
if (length && line[length-1] == '\n')
if (length && line[length-1] == delim)
line[length-1] = '\0';
}
@@ -208,7 +210,7 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
{
/* Remove trailing newlines? */
if (flags & MAPF_CHOP)
do_chop (line);
do_chop (line, delim);
/* Has a callback been registered and if so is it time to call it? */
if (callback && line_count && (line_count % callback_quantum) == 0)
+12 -7
View File
@@ -653,6 +653,13 @@ set_builtin (list)
{
switch (flag_name)
{
case 'i': /* don't allow set -i */
s[0] = list_opttype;
s[1] = 'i';
s[2] = '\0';
sh_invalidopt (s);
builtin_usage ();
return (EX_USAGE);
case '?':
builtin_usage ();
return (list_optopt == '?' ? EXECUTION_SUCCESS : EX_USAGE);
@@ -887,17 +894,15 @@ unset_builtin (list)
#if defined (ARRAY_VARS)
if (var && unset_array)
{
if (array_p (var) == 0 && assoc_p (var) == 0)
/* Let unbind_array_element decide what to do with non-array vars */
tem = unbind_array_element (var, t);
if (tem == -2 && array_p (var) == 0 && assoc_p (var) == 0)
{
builtin_error (_("%s: not an array variable"), var->name);
NEXT_VARIABLE ();
}
else
{
tem = unbind_array_element (var, t);
if (tem == -1)
any_failed++;
}
else if (tem < 0)
any_failed++;
}
else
#endif /* ARRAY_VARS */