commit bash-20170421 snapshot

This commit is contained in:
Chet Ramey
2017-05-01 15:45:48 -04:00
parent 21c9990fbb
commit 787bb204f9
12 changed files with 185 additions and 8 deletions
+15
View File
@@ -13701,3 +13701,18 @@ subst.c
<grishalevit@gmail.com>. This undoes change to @Q from 4/7, so
list_transform change reverted
4/19
----
builtins.h
- added BUILTINS_H include guard
examples/loadables/Makefile.in
- install loadables.h as sample include file, along with Makefile.inc
4/23
----
bashline.c
- maybe_make_readline_line: don't try to do anything if the passed
NEW_LINE is NULL. Report from Jaren Stangret <sirjaren@gmail.com>,
fix from Eduardo Bustamante <dualbus@gmail.com>
+1
View File
@@ -706,6 +706,7 @@ examples/loadables/perl/iperl.c f
#examples/loadables/xtitle.c f
examples/functions/array-stuff f
examples/functions/array-to-string f
examples/functions/arrayops.bash f
examples/functions/autoload f
examples/functions/autoload.v2 f
examples/functions/autoload.v3 f
+1 -1
View File
@@ -2545,7 +2545,7 @@ static void
maybe_make_readline_line (new_line)
char *new_line;
{
if (strcmp (new_line, rl_line_buffer) != 0)
if (new_line && strcmp (new_line, rl_line_buffer) != 0)
{
rl_point = rl_end;
+5
View File
@@ -18,6 +18,9 @@
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BUILTINS_H
#define BUILTINS_H
#include "config.h"
#if defined (HAVE_UNISTD_H)
@@ -60,3 +63,5 @@ extern int num_shell_builtins; /* Number of shell builtins. */
extern struct builtin static_shell_builtins[];
extern struct builtin *shell_builtins;
extern struct builtin *current_builtin;
#endif /* BUILTINS_H */
+146
View File
@@ -0,0 +1,146 @@
# arrayops.bash --- hide some of the nasty syntax for manipulating bash arrays
# Author: Noah Friedman <friedman@splode.com>
# Created: 2016-07-08
# Public domain
# $Id: arrayops.bash,v 1.3 2016/07/28 15:38:55 friedman Exp $
# Commentary:
# These functions try to tame the syntactic nightmare that is bash array
# syntax, which makes perl's almost look reasonable.
#
# For example the apush function below lets you write:
#
# apush arrayvar newval
#
# instead of
#
# ${arrayvar[${#arrayvar[@]}]}=newval
#
# Because seriously, you've got to be kidding me.
# These functions avoid the use of local variables as much as possible
# (especially wherever modification occurs) because those variable names
# might shadow the array name passed in. Dynamic scope!
# Code:
#:docstring apush:
# Usage: apush arrayname val1 {val2 {...}}
#
# Appends VAL1 and any remaining arguments to the end of the array
# ARRAYNAME as new elements.
#:end docstring:
apush()
{
eval "$1=(\"\${$1[@]}\" \"\${@:2}\")"
}
#:docstring apop:
# Usage: apop arrayname {n}
#
# Removes the last element from ARRAYNAME.
# Optional argument N means remove the last N elements.
#:end docstring:
apop()
{
eval "$1=(\"\${$1[@]:0:\${#$1[@]}-${2-1}}\")"
}
#:docstring aunshift:
# Usage: aunshift arrayname val1 {val2 {...}}
#
# Prepends VAL1 and any remaining arguments to the beginning of the array
# ARRAYNAME as new elements. The new elements will appear in the same order
# as given to this function, rather than inserting them one at a time.
#
# For example:
#
# foo=(a b c)
# aunshift foo 1 2 3
# => foo is now (1 2 3 a b c)
# but
#
# foo=(a b c)
# aunshift foo 1
# aunshift foo 2
# aunshift foo 3
# => foo is now (3 2 1 a b c)
#
#:end docstring:
aunshift()
{
eval "$1=(\"\${@:2}\" \"\${$1[@]}\")"
}
#:docstring ashift:
# Usage: ashift arrayname {n}
#
# Removes the first element from ARRAYNAME.
# Optional argument N means remove the first N elements.
#:end docstring:
ashift()
{
eval "$1=(\"\${$1[@]: -\${#$1[@]}+${2-1}}\")"
}
#:docstring aset:
# Usage: aset arrayname idx newval
#
# Assigns ARRAYNAME[IDX]=NEWVAL
#:end docstring:
aset()
{
eval "$1[\$2]=${@:3}"
}
#:docstring aref:
# Usage: aref arrayname idx {idx2 {...}}
#
# Echoes the value of ARRAYNAME at index IDX to stdout.
# If more than one IDX is specified, each one is echoed.
#
# Unfortunately bash functions cannot return arbitrary values in the usual way.
#:end docstring:
aref()
{
eval local "v=(\"\${$1[@]}\")"
local x
for x in ${@:2} ; do echo "${v[$x]}"; done
}
#:docstring aref:
# Usage: alen arrayname
#
# Echoes the length of the number of elements in ARRAYNAME.
#
# It also returns number as a numeric value, but return values are limited
# by a maximum of 255 so don't rely on this unless you know your arrays are
# relatively small.
#:end docstring:
alen()
{
eval echo "\${#$1[@]}"
eval return "\${#$1[@]}"
}
#:docstring anreverse:
# Usage: anreverse arrayname
#
# Reverse the order of the elements in ARRAYNAME.
# The array variable is altered by this operation.
#:end docstring:
anreverse()
{
eval set $1 "\"\${$1[@]}\""
eval unset $1
while [ $# -gt 1 ]; do
eval "$1=(\"$2\" \"\${$1[@]}\")"
set $1 "${@:3}"
done
}
#provide arrayops
# arrayops.bash ends here
+2 -1
View File
@@ -244,6 +244,7 @@ installdirs:
install-dev: installdirs
@$(INSTALL_DATA) Makefile.inc $(DESTDIR)$(loadablesdir)/Makefile.inc
@$(INSTALL_DATA) loadables.h $(DESTDIR)$(loadablesdir)/loadables.h
@( cd $(BUILD_DIR) && ${MAKE} ${MFLAGS} DESTDIR="$(DESTDIR)" install-headers)
install-supported: all installdirs install-dev
@@ -254,7 +255,7 @@ install-supported: all installdirs install-dev
done
uninstall-dev:
-$(RM) $(DESTDIR)$(loadablesdir)/Makefile.inc
-$(RM) $(DESTDIR)$(loadablesdir)/Makefile.inc $(DESTDIR)$(loadablesdir)/loadables.h
-( cd $(BUILD_DIR) && ${MAKE} ${MFLAGS} DESTDIR="$(DESTDIR)" uninstall-headers)
uninstall-supported: uninstall-dev
+2
View File
@@ -1090,6 +1090,8 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
# endif
set_pipestatus_from_exit (exec_result);
break;
default:
break;
}
#endif
+1 -1
View File
@@ -53,7 +53,7 @@ BASHINCDIR = ${topdir}/include
INCLUDES = -I. -I../.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib
CCFLAGS = $(PROFILE_FLAGS) $(DEFS) $(LOCAL_DEFS) ${INCLUDES} $(CPPFLAGS) \
$(LOCAL_CFLAGS) $(CFLAGS)
$(LOCAL_CFLAGS) $(CFLAGS) ${ASAN_CFLAGS}
# Here is a rule for making .o files from .c files that doesn't force
# the type of the machine (like -sun3) into the flags.
+2 -1
View File
@@ -64,7 +64,8 @@ LOCAL_DEFS = @LOCAL_DEFS@
INCLUDES = -I. -I$(BUILD_DIR) -I$(topdir) -I$(topdir)/lib
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(APP_CFLAGS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(APP_CFLAGS) $(CPPFLAGS) ${INCLUDES} \
$(LOCAL_CFLAGS) $(CFLAGS) ${ASAN_CFLAGS}
.c.o:
${RM} $@
+6
View File
@@ -90,6 +90,12 @@ If @code{readline} encounters an @code{EOF} while reading the line, and the
line is empty at that point, then @code{(char *)NULL} is returned.
Otherwise, the line is ended just as if a newline had been typed.
Readline performs some expansion on the @var{prompt} before it is
displayed on the screen. See the description of @code{rl_expand_prompt}
(@pxref{Redisplay}) for additional details, especially if @var{prompt}
will contain characters that do not consume physical screen space when
displayed.
If you want the user to be able to get at the line later, (with
@key{C-p} for example), you must call @code{add_history()} to save the
line away in a @dfn{history} list of such lines.
+3 -3
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2017 Free Software Foundation, Inc.
@set EDITION 7.0
@set VERSION 7.0
@set UPDATED 3 February 2017
@set UPDATED-MONTH February 2017
@set UPDATED 21 April 2017
@set UPDATED-MONTH April 2017
@set LASTCHANGE Fri Feb 3 15:59:51 EST 2017
@set LASTCHANGE Fri Apr 21 15:25:17 EDT 2017
+1 -1
View File
@@ -2565,7 +2565,7 @@ parser_remaining_input ()
{
if (shell_input_line == 0)
return 0;
if (shell_input_line_index < 0 || shell_input_line_index >= shell_input_line_len)
if ((int)shell_input_line_index < 0 || shell_input_line_index >= shell_input_line_len)
return ""; /* XXX */
return (shell_input_line + shell_input_line_index);
}