diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 68e9174a..09a40138 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -13701,3 +13701,18 @@ subst.c . 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 , + fix from Eduardo Bustamante + diff --git a/MANIFEST b/MANIFEST index b03f2a6e..f72e0e73 100644 --- a/MANIFEST +++ b/MANIFEST @@ -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 diff --git a/bashline.c b/bashline.c index 129714aa..7884416a 100644 --- a/bashline.c +++ b/bashline.c @@ -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; diff --git a/builtins.h b/builtins.h index 0cfea189..dac95fdb 100644 --- a/builtins.h +++ b/builtins.h @@ -18,6 +18,9 @@ along with Bash. If not, see . */ +#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 */ diff --git a/examples/functions/arrayops.bash b/examples/functions/arrayops.bash new file mode 100644 index 00000000..d34353ae --- /dev/null +++ b/examples/functions/arrayops.bash @@ -0,0 +1,146 @@ +# arrayops.bash --- hide some of the nasty syntax for manipulating bash arrays +# Author: Noah Friedman +# 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 diff --git a/examples/loadables/Makefile.in b/examples/loadables/Makefile.in index a01290c6..528ebc1d 100644 --- a/examples/loadables/Makefile.in +++ b/examples/loadables/Makefile.in @@ -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 diff --git a/execute_cmd.c b/execute_cmd.c index 6a008684..66ecd978 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -1090,6 +1090,8 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, # endif set_pipestatus_from_exit (exec_result); break; + default: + break; } #endif diff --git a/lib/glob/Makefile.in b/lib/glob/Makefile.in index 7ce5d733..da28505b 100644 --- a/lib/glob/Makefile.in +++ b/lib/glob/Makefile.in @@ -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. diff --git a/lib/readline/Makefile.in b/lib/readline/Makefile.in index 1291249d..08441a0d 100644 --- a/lib/readline/Makefile.in +++ b/lib/readline/Makefile.in @@ -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} $@ diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi index b8ce90f9..2754ad27 100644 --- a/lib/readline/doc/rltech.texi +++ b/lib/readline/doc/rltech.texi @@ -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. diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi index 51d47968..fac7b5ef 100644 --- a/lib/readline/doc/version.texi +++ b/lib/readline/doc/version.texi @@ -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 diff --git a/parse.y b/parse.y index fa25dca9..881c5ef7 100644 --- a/parse.y +++ b/parse.y @@ -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); }