diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 444c0331..6c2cb420 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -12853,3 +12853,106 @@ input.c arrayfunc.[ch],subst.c - array_expand_index: added new FLAGS argument, reserved for future use, changed callers + + + 12/24 + ----- +variables.c + - can_optimize_assignment,optimized_assignment: see if we can detect + whether or not we're trying to append a string to a string variable, + and optimize that using realloc/strcpy. Based on a log-ago + suggestion from Aharon Robbins + + 12/27 + ----- +builtins/help.def + - help_builtin: don't pass return value from ngettext() directly to + printf + + 12/28 + ----- +sig.c + - set_signal_handler: set SA_RESTART for SIGWINCH, so window size + changes don't interrupt open/read/write. Suggested by + Andriy Prystupa back in 10/2016 + + 12/30 + ----- +execute_cmd.c + - coproc_pidchk: if MULTIPLE_COPROCS, call cpl_search to find coproc + associated with pid, don't remove it from the list with cpl_delete. + Just mark as dead and wait for coproc_reap/cpl_reap to take care + of disposing it + - execute_coproc: NEW FEATURE: run the coproc name through word + expansion before creating the coproc; this allows unique coprocs + to be created in loops. Originally requested way back in 2012 by + Erik Brandsberg + +command.h + - subshell_com: now has a line number member: line + +make_cmd.c + - make_subshell_command: assign current line number (line number of the + ending right paren) to `line' member + +copy_cmd.c + - copy_subshell_command: copy the `line' member + +execute_command.c + - execute_command_internal: when executing a user subshell (`(command)'), + set the line number and line number for the ERR trap from the line + number saved in the subshell command struct. Fix from + Eduardo A. Bustamante López + - execute_arith_command: set line number for ERR trap from line number + saved in the arith command struct. Fix from + Eduardo A. Bustamante López + - execute_cond_command: set line number for ERR trap from line number + saved in the cond command struct. Fix from + Eduardo A. Bustamante López + +variables.c + - bind_variable_internal: move can_optimize_assignment call to the + right place + + 12/31 + ----- +variables.c + - find_variable_nameref: treat a circular variable reference as + referring to a variable of that name in the global scope (for now), + if one exists. PROVISIONAL change: inspired by suggestion back in + 6/2016 by Grisha Levit + + 1/2/2017 + -------- +{expr,general,hashcmd}.c + - include flags.h for flag values + +make_cmd.c + - include shell.h instead of the files it includes + +flags.h + - new extern declarations for want_pending_command, read_from_stdin + +subst.h + - add extern declaration for expanding_redir, assigning_in_environment + +trap.h + - add extern declaration for running_trap + +execute_cmd.h + - added extern declarations for variables declared in execute_cmd.c, + changed files that declare lots of extern variables + +shell.h + - added extern declarations for variables declared in shell.c, + changed files that declare lots of extern variables + +parser.h + - added extern declarations for variables declared in parse.y, + changed files that declare lots of extern variables + +[lots of changes to reduce the number of extern declarations in C and DEF files] + +parse.y + - xparse_dolparen: need ALIAS or DPAREN_ARITHMETIC to be defined to + use STRING_SAVER diff --git a/MANIFEST b/MANIFEST index 668d433b..2fd33306 100644 --- a/MANIFEST +++ b/MANIFEST @@ -852,6 +852,7 @@ tests/array19.sub f tests/array20.sub f tests/array21.sub f tests/array22.sub f +tests/array23.sub f tests/array-at-star f tests/array2.right f tests/assoc.tests f diff --git a/Makefile.in b/Makefile.in index 82684a9d..8cd28832 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -# Makefile for bash-4.4, version 4.18 +# Makefile for bash-4.4, version 4.20 # # Copyright (C) 1996-2015 Free Software Foundation, Inc. @@ -979,19 +979,19 @@ error.o: command.h general.h xmalloc.h externs.h input.h bashhist.h error.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h error.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h error.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -error.o: make_cmd.h subst.h sig.h pathnames.h externs.h +error.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h error.o: input.h execute_cmd.h eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h eval.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h eval.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h eval.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h +eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h eval.o: input.h execute_cmd.h execute_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h execute_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h execute_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h execute_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -execute_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h +execute_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h execute_cmd.o: ${BASHINCDIR}/memalloc.h ${GRAM_H} flags.h builtins.h jobs.h quit.h siglist.h execute_cmd.o: execute_cmd.h findcmd.h redir.h trap.h test.h pathexp.h execute_cmd.o: $(DEFSRC)/common.h ${DEFDIR}/builtext.h ${GLOB_LIBSRC}/strmatch.h @@ -1001,31 +1001,31 @@ expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h expr.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h expr.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h expr.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h +expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h flags.h execute_cmd.h expr.o: ${BASHINCDIR}/chartypes.h findcmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h findcmd.o: ${BASHINCDIR}/stdc.h error.h general.h xmalloc.h variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h findcmd.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h -findcmd.o: flags.h hashlib.h pathexp.h hashcmd.h +findcmd.o: flags.h hashlib.h pathexp.h hashcmd.h execute_cmd.h findcmd.o: ${BASHINCDIR}/chartypes.h flags.o: config.h flags.h flags.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h flags.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h -flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h +flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h execute_cmd.h flags.o: make_cmd.h subst.h sig.h pathnames.h externs.h bashhist.h general.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h general.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h general.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h general.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -general.o: make_cmd.h subst.h sig.h pathnames.h externs.h +general.o: make_cmd.h subst.h sig.h pathnames.h externs.h flags.h parser.h general.o: ${BASHINCDIR}/maxpath.h ${BASHINCDIR}/posixtime.h general.o: ${BASHINCDIR}/chartypes.h hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h hashcmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h hashcmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashcmd.h hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h pathnames.h hashlib.h -hashcmd.o: quit.h sig.h +hashcmd.o: quit.h sig.h flags.h hashlib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h hashlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h hashlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h @@ -1033,7 +1033,7 @@ hashlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h hashlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h input.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h input.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h input.h error.h externs.h -input.o: quit.h +input.o: quit.h shell.h list.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h list.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h list.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h @@ -1056,11 +1056,12 @@ make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h flags.h m make_cmd.o: variables.h arrayfunc.h conftypes.h array.h hashlib.h subst.h input.h externs.h make_cmd.o: jobs.h quit.h sig.h siglist.h syntax.h dispose_cmd.h parser.h make_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h ${BASHINCDIR}/ocache.h +make_cmd.o: shell.h execute_cmd.h y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h y.tab.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h y.tab.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h y.tab.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h +y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h execute_cmd.o y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h pathexp.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h @@ -1087,7 +1088,7 @@ shell.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR} shell.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h shell.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h +shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h bashline.h shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h @@ -1095,7 +1096,7 @@ sig.o: config.h bashtypes.h sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h sig.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h sig.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h +sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h sig.o: ${DEFDIR}/builtext.h siglist.o: config.h bashtypes.h siglist.h trap.h @@ -1125,8 +1126,8 @@ test.o: ${DEFSRC}/common.h trap.o: config.h bashtypes.h trap.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h trap.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h -trap.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h +trap.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h parser.h +trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h trap.o: signames.h $(DEFSRC)/common.h trap.o: ${DEFDIR}/builtext.h jobs.h unwind_prot.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h @@ -1135,7 +1136,7 @@ variables.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINC variables.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h variables.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h variables.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h +variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h variables.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h variables.o: findcmd.h bashhist.h hashcmd.h pathexp.h variables.o: pcomplete.h ${BASHINCDIR}/chartypes.h @@ -1150,14 +1151,14 @@ jobs.o: config.h bashtypes.h trap.h ${BASHINCDIR}/filecntl.h input.h ${BASHINCDI jobs.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h jobs.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h jobs.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h -jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h +jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h parser.h jobs.o: execute_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h jobs.o: jobs.h flags.h $(DEFSRC)/common.h $(DEFDIR)/builtext.h jobs.o: ${BASHINCDIR}/posixwait.h ${BASHINCDIR}/unionwait.h jobs.o: ${BASHINCDIR}/posixtime.h nojobs.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashjmp.h ${BASHINCDIR}/posixjmp.h nojobs.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h jobs.h quit.h siglist.h externs.h -nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h +nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h parser.h nojobs.o: $(DEFDIR)/builtext.h # shell features that may be compiled in @@ -1173,6 +1174,7 @@ arrayfunc.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h comman arrayfunc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h arrayfunc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h arrayfunc.o: make_cmd.h subst.h sig.h pathnames.h externs.h pathexp.h +arrayfunc.o: execute_cmd.h arrayfunc.o: $(DEFSRC)/common.h arrayfunc.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h assoc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h @@ -1215,14 +1217,14 @@ bashhist.o: ${BASHINCDIR}/filecntl.h bashhist.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h bashhist.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h bashhist.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h +bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h bashhist.o: flags.h input.h parser.h pathexp.h $(DEFSRC)/common.h bashline.h bashhist.o: $(GLOB_LIBSRC)/strmatch.h bashline.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashline.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h bashline.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h bashline.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h +bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h bashline.o: builtins.h bashhist.h bashline.h execute_cmd.h findcmd.h pathexp.h bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h @@ -1308,12 +1310,12 @@ builtins/common.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h builtins/common.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h builtins/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h builtins/common.o: execute_cmd.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h pathnames.h -builtins/common.o: ${DEFDIR}/builtext.h +builtins/common.o: ${DEFDIR}/builtext.h parser.h builtins/common.o: ${BASHINCDIR}/chartypes.h builtins/evalfile.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins/evalfile.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h builtins/evalfile.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h -builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h +builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h builtins/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h builtins/evalfile.o: bashhist.h $(DEFSRC)/common.h builtins/evalstring.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h @@ -1343,12 +1345,12 @@ builtins/bind.o: $(DEFSRC)/bashgetopt.h pathnames.h builtins/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/break.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/break.o: pathnames.h +builtins/break.o: pathnames.h execute_cmd.h builtins/builtin.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/builtin.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h builtins/builtin.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/builtin.o: pathnames.h +builtins/builtin.o: pathnames.h execute_cmd.h builtins/caller.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/caller.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h builtins/caller.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h @@ -1389,33 +1391,34 @@ builtins/exit.o: bashtypes.h builtins/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/exit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/exit.o: pathnames.h +builtins/exit.o: pathnames.h execute_cmd.h builtins/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h builtins/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h builtins/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/fc.o: flags.h unwind_prot.h variables.h arrayfunc.h conftypes.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h quit.h -builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h pathnames.h +builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h pathnames.h parser.h builtins/fc.o: ${BASHINCDIR}/chartypes.h builtins/fg_bg.o: bashtypes.h $(DEFSRC)/bashgetopt.h builtins/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/fg_bg.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/fg_bg.o: pathnames.h +builtins/fg_bg.o: pathnames.h execute_cmd.h builtins/getopts.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/getopts.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/getopts.o: pathnames.h -builtins/hash.o: bashtypes.h +builtins/getopts.o: pathnames.h execute_cmd.h +builtins/hash.o: bashtypes.h execute_cmd.h builtins/hash.o: builtins.h command.h findcmd.h ${BASHINCDIR}/stdc.h $(DEFSRC)/common.h builtins/hash.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/hash.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h builtins/hash.o: pathnames.h builtins/help.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h +builtins/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h +builtins/help.o: conftypes.h quit.h execute_cmd.h builtins/help.o: $(GLOB_LIBSRC)/glob.h pathnames.h -builtins/history.o: bashtypes.h pathnames.h +builtins/history.o: bashtypes.h pathnames.h parser.h builtins/history.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/history.o: ${BASHINCDIR}/filecntl.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h @@ -1455,16 +1458,16 @@ builtins/read.o: pathnames.h builtins/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/return.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/return.o: pathnames.h +builtins/return.o: pathnames.h execute_cmd.h builtins/set.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/set.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h flags.h -builtins/set.o: pathnames.h +builtins/set.o: pathnames.h parser.h builtins/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h builtins/setattr.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/setattr.o: pathnames.h flags.h +builtins/setattr.o: pathnames.h flags.h execute_cmd.h builtins/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/shift.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h @@ -1479,7 +1482,7 @@ builtins/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/source.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h builtins/source.o: findcmd.h $(DEFSRC)/bashgetopt.h flags.h trap.h -builtins/source.o: pathnames.h +builtins/source.o: pathnames.h execute_cmd.h builtins/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/suspend.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h @@ -1487,7 +1490,7 @@ builtins/suspend.o: pathnames.h builtins/test.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/test.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h -builtins/test.o: test.h pathnames.h +builtins/test.o: execute_cmd.h test.h pathnames.h builtins/times.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/times.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h @@ -1501,7 +1504,7 @@ builtins/type.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h x builtins/type.o: quit.h $(DEFSRC)/common.h findcmd.h builtins/type.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h -builtins/type.o: pathnames.h +builtins/type.o: pathnames.h execute_cmd.h parser.h builtins/ulimit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/ulimit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h @@ -1513,6 +1516,7 @@ builtins/umask.o: ${BASHINCDIR}/chartypes.h pathnames.h builtins/wait.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h builtins/wait.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +builtins/wait.o: execute_cmd.h builtins/wait.o: ${BASHINCDIR}/chartypes.h pathnames.h builtins/complete.o: config.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h diff --git a/arrayfunc.c b/arrayfunc.c index cea8fba1..ac4884fc 100644 --- a/arrayfunc.c +++ b/arrayfunc.c @@ -30,6 +30,7 @@ #include "bashintl.h" #include "shell.h" +#include "execute_cmd.h" #include "pathexp.h" #include "shmbutil.h" @@ -39,10 +40,6 @@ #include "builtins/common.h" -extern char *this_command_name; -extern int last_command_exit_value; -extern int array_needs_making; - /* This variable means to not expand associative array subscripts more than once, when performing variable expansion. */ int assoc_expand_once = 0; @@ -938,12 +935,19 @@ array_expand_index (var, s, len, flags) exp = (char *)xmalloc (len); strncpy (exp, s, len - 1); exp[len - 1] = '\0'; +#if 0 /* XXX - not yet -- maybe bash-5.0 */ + if ((flags & AV_NOEXPAND) == 0) + t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */ + else + t = exp; +#endif t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */ savecmd = this_command_name; this_command_name = (char *)NULL; val = evalexp (t, 0, &expok); this_command_name = savecmd; - free (t); + if (t != exp) + free (t); free (exp); if (expok == 0) { @@ -1121,7 +1125,7 @@ array_value_internal (s, quoted, flags, rtype, indp) { if ((flags & AV_USEIND) == 0 || indp == 0) { - ind = array_expand_index (var, t, len, 0); + ind = array_expand_index (var, t, len, flags); if (ind < 0) { /* negative subscripts to indexed arrays count back from end */ diff --git a/arrayfunc.h b/arrayfunc.h index 1d3eec4f..199c8127 100644 --- a/arrayfunc.h +++ b/arrayfunc.h @@ -29,6 +29,9 @@ once, when performing variable expansion. */ extern int assoc_expand_once; +/* The analog for indexed array subscripts */ +extern int array_expand_once; + /* Flags for array_value_internal and callers array_value/get_array_value */ #define AV_ALLOWALL 0x001 #define AV_QUOTED 0x002 diff --git a/bashhist.c b/bashhist.c index 3de75134..b32373a0 100644 --- a/bashhist.c +++ b/bashhist.c @@ -44,6 +44,7 @@ #include "shell.h" #include "flags.h" +#include "parser.h" #include "input.h" #include "parser.h" /* for the struct dstack stuff. */ #include "pathexp.h" /* for the struct ignorevar stuff */ @@ -187,12 +188,6 @@ int hist_verify; /* Non-zero means to not save function definitions in the history list. */ int dont_save_function_defs; -/* Variables declared in other files used here. */ -extern int current_command_line_count; - -extern struct dstack dstack; -extern int parser_state; - #if defined (BANG_HISTORY) static int bash_history_inhibit_expansion __P((char *, int)); #endif @@ -777,8 +772,6 @@ check_add_history (line, force) #if defined (SYSLOG_HISTORY) #define SYSLOG_MAXLEN 600 -extern char *shell_name; - #ifndef OPENLOG_OPTS #define OPENLOG_OPTS 0 #endif diff --git a/bashhist.h b/bashhist.h index 48156b6f..128b36f9 100644 --- a/bashhist.h +++ b/bashhist.h @@ -46,11 +46,19 @@ extern int history_expansion; extern int history_control; extern int command_oriented_history; extern int current_command_first_line_saved; +extern int current_command_first_line_comment; extern int hist_last_line_added; extern int hist_last_line_pushed; +extern int dont_save_function_defs; + +# if defined (READLINE) +extern int hist_verify; +# endif + # if defined (BANG_HISTORY) extern int history_expansion_inhibited; +extern int double_quotes_inhibit_history_expansion; # endif /* BANG_HISTORY */ extern void bash_initialize_history __P((void)); diff --git a/bashjmp.h b/bashjmp.h index 79152fe5..8ed1ac47 100644 --- a/bashjmp.h +++ b/bashjmp.h @@ -26,6 +26,7 @@ extern procenv_t top_level; extern procenv_t subshell_top_level; extern procenv_t return_catch; /* used by `return' builtin */ +extern procenv_t wait_intr_buf; extern int no_longjmp_on_fatal_error; diff --git a/bashline.c b/bashline.c index e5d9f5e3..caf60c64 100644 --- a/bashline.c +++ b/bashline.c @@ -46,6 +46,7 @@ #include "shell.h" #include "input.h" +#include "parser.h" #include "builtins.h" #include "bashhist.h" #include "bashline.h" @@ -200,19 +201,8 @@ static char *prog_complete_return __P((const char *, int)); static char **prog_complete_matches; #endif -/* Variables used here but defined in other files. */ -#if defined (BANG_HISTORY) -extern int hist_verify; -#endif - -extern int current_command_line_count, saved_command_line_count; -extern int last_command_exit_value; -extern int array_needs_making; -extern int posixly_correct, no_symbolic_links; -extern int sigalrm_seen; -extern char *current_prompt_string, *ps1_prompt; +extern int no_symbolic_links; extern STRING_INT_ALIST word_token_alist[]; -extern sh_builtin_func_t *last_shell_builtin, *this_shell_builtin; /* SPECIFIC_COMPLETION_FUNCTIONS specifies that we have individual completion functions which indicate what type of completion should be diff --git a/bashline.h b/bashline.h index d52dfdfa..2571e11f 100644 --- a/bashline.h +++ b/bashline.h @@ -24,6 +24,16 @@ #include "stdc.h" extern int bash_readline_initialized; +extern int hostname_list_initialized; + +/* these are controlled via shopt */ +extern int perform_hostname_completion; +extern int no_empty_command_completion; +extern int force_fignore; +extern int dircomplete_spelling; +extern int dircomplete_expand; +extern int dircomplete_expand_relpath; +extern int complete_fullquote; extern void posix_readline_initialize __P((int)); extern void reset_completer_word_break_chars __P((void)); diff --git a/braces.c b/braces.c index 7f31dd5e..6a5ca5f8 100644 --- a/braces.c +++ b/braces.c @@ -61,7 +61,9 @@ extern int errno; extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3))); +#if defined (NOTDEF) extern int last_command_exit_value; +#endif /* Basic idea: diff --git a/builtins/Makefile.in b/builtins/Makefile.in index bbb96c37..c6485ede 100644 --- a/builtins/Makefile.in +++ b/builtins/Makefile.in @@ -1,6 +1,6 @@ # This Makefile for building libbuiltins.a is in -*- text -*- for Emacs. # -# Copyright (C) 1996-2015 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -331,7 +331,7 @@ bashgetopt.o: ../pathnames.h $(topdir)/externs.h $(srcdir)/common.h bashgetopt.o: $(BASHINCDIR)/chartypes.h common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h common.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h -common.o: $(topdir)/sig.h $(topdir)/command.h +common.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/parser.h common.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/stdc.h $(BASHINCDIR)/memalloc.h common.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/input.h common.o: $(topdir)/siglist.h $(topdir)/bashhist.h $(topdir)/quit.h @@ -347,7 +347,7 @@ evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir evalfile.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h evalfile.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h -evalfile.o: ../pathnames.h $(topdir)/externs.h +evalfile.o: ../pathnames.h $(topdir)/externs.h $(topdir)/parser.h evalfile.o: $(topdir)/jobs.h $(topdir)/builtins.h $(topdir)/flags.h evalfile.o: $(topdir)/input.h $(topdir)/execute_cmd.h evalfile.o: $(topdir)/bashhist.h $(srcdir)/common.h @@ -386,19 +386,18 @@ bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/ bind.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/bashgetopt.h bind.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h $(topdir)/bashline.h bind.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -bind.o: ../pathnames.h break.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h break.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h break.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h break.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h break.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -break.o: ../pathnames.h +break.o: ../pathnames.h $(topdir)/execute_cmd.h builtin.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h builtin.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -builtin.o: $(srcdir)/bashgetopt.h ../pathnames.h +builtin.o: $(srcdir)/bashgetopt.h ../pathnames.h $(topdir)/execute_cmd.h caller.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h caller.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h caller.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h @@ -457,10 +456,11 @@ exit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h exit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/jobs.h exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +exit.o: $(topdir)/execute_cmd.h exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h ../pathnames.h fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h -fc.o: $(topdir)/bashhist.h +fc.o: $(topdir)/bashhist.h $(topdir)/parser.h fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h fc.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h @@ -474,30 +474,34 @@ fg_bg.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h fg_bg.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +fg_bg.o: $(topdir)/execute_cmd.h fg_bg.o: $(topdir)/jobs.h ../pathnames.h getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h getopts.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h getopts.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +getopts.o: $(topdir)/execute_cmd.h getopts.o: ../pathnames.h hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h $(topdir)/sig.h hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h hash.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h -hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h +hash.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h hash.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h help.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h help.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h help.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h help.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h -help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h +help.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h help.o: ${srcdir}/common.h $(topdir)/sig.h ../pathnames.h history.o: $(topdir)/bashtypes.h history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h -history.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h +history.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h $(topdir)/parser.h history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h history.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h history.o: ../pathnames.h @@ -552,20 +556,22 @@ return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h return.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h return.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h -return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h +return.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h return.o: ../pathnames.h set.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h set.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h set.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h set.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h $(topdir)/sig.h -set.o: $(topdir)/arrayfunc.h ../pathnames.h +set.o: $(topdir)/arrayfunc.h ../pathnames.h $(topdir)/parser.h setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h setattr.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h setattr.o: $(topdir)/externs.h $(topdir)/flags.h $(topdir)/sig.h -setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h +setattr.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h setattr.o: $(topdir)/arrayfunc.h ../pathnames.h shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h shift.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h @@ -586,6 +592,7 @@ source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h source.o: $(srcdir)/bashgetopt.h $(topdir)/flags.h $(topdir)/trap.h +source.o: $(topdir)/execute_cmd.h source.o: ../pathnames.h suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h suspend.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h @@ -598,7 +605,7 @@ test.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h test.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h test.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -test.o: $(topdir)/test.h ../pathnames.h +test.o: $(topdir)/execute_cmd.h $(topdir)/test.h ../pathnames.h times.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h times.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h @@ -615,6 +622,7 @@ type.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h type.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h type.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h +type.o: $(topdir)/execute_cmd.h $(topdir)/parser.h type.o: $(topdir)/externs.h $(topdir)/hashcmd.h ../pathnames.h type.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h ulimit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h @@ -634,7 +642,7 @@ wait.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h wait.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h wait.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h wait.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -wait.o: $(topdir)/jobs.h $(topdir)/sig.h +wait.o: $(topdir)/jobs.h $(topdir)/sig.h $(topdir)/execute_cmd.h wait.o: $(BASHINCDIR)/chartypes.h ../pathnames.h complete.o: ../config.h ../pathnames.h diff --git a/builtins/alias.def b/builtins/alias.def index 50800247..bf484f33 100644 --- a/builtins/alias.def +++ b/builtins/alias.def @@ -65,8 +65,6 @@ $END static void print_alias __P((alias_t *, int)); -extern int posixly_correct; - /* Hack the alias command in a Korn shell way. */ int alias_builtin (list) diff --git a/builtins/bind.def b/builtins/bind.def index 649d73f6..c8721aeb 100644 --- a/builtins/bind.def +++ b/builtins/bind.def @@ -89,8 +89,6 @@ extern int errno; static int query_bindings __P((char *)); static int unbind_command __P((char *)); -extern int no_line_editing; - #define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0) #define LFLAG 0x0001 diff --git a/builtins/break.def b/builtins/break.def index bdc1182a..876d0635 100644 --- a/builtins/break.def +++ b/builtins/break.def @@ -43,11 +43,9 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../execute_cmd.h" #include "common.h" -extern char *this_command_name; -extern int posixly_correct; - static int check_loop_level __P((void)); /* The depth of while's and until's. */ diff --git a/builtins/builtin.def b/builtins/builtin.def index 3e765e41..4867f3a8 100644 --- a/builtins/builtin.def +++ b/builtins/builtin.def @@ -43,11 +43,10 @@ $END #endif #include "../shell.h" +#include "../execute_cmd.h" #include "common.h" #include "bashgetopt.h" -extern char *this_command_name; - /* Run the command mentioned in list directly, without going through the normal alias/function/builtin/filename lookup process. */ int diff --git a/builtins/cd.def b/builtins/cd.def index 421e819b..45bcf1de 100644 --- a/builtins/cd.def +++ b/builtins/cd.def @@ -54,8 +54,6 @@ $PRODUCES cd.c extern int errno; #endif /* !errno */ -extern int posixly_correct; -extern int array_needs_making; extern const char * const bash_getcwd_errstr; static int bindpwd __P((int)); diff --git a/builtins/command.def b/builtins/command.def index dcb510d5..ce694d87 100644 --- a/builtins/command.def +++ b/builtins/command.def @@ -60,8 +60,6 @@ $END extern size_t confstr __P((int, char *, size_t)); #endif -extern int subshell_environment; - static void restore_path __P((char *)); /* Run the commands mentioned in LIST without paying attention to shell diff --git a/builtins/common.c b/builtins/common.c index 52c5af55..a5f2584d 100644 --- a/builtins/common.c +++ b/builtins/common.c @@ -1,6 +1,6 @@ /* common.c - utility functions for all builtins */ -/* Copyright (C) 1987-2016 Free Software Foundation, Inc. +/* Copyright (C) 1987-2017 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -49,6 +49,7 @@ #include "../shell.h" #include "maxpath.h" #include "../flags.h" +#include "../parser.h" #include "../jobs.h" #include "../builtins.h" #include "../input.h" @@ -67,13 +68,6 @@ extern int errno; #endif /* !errno */ -extern int indirection_level, subshell_environment; -extern int line_number; -extern int last_command_exit_value; -extern int trap_saved_exit_value; -extern int running_trap; -extern int posixly_correct; -extern char *this_command_name, *shell_name; extern const char * const bash_getcwd_errstr; /* Used by some builtins and the mainline code. */ diff --git a/builtins/common.h b/builtins/common.h index 2ac0f778..c7b3ae0c 100644 --- a/builtins/common.h +++ b/builtins/common.h @@ -212,4 +212,29 @@ extern int force_execute_file __P((const char *, int)); extern int source_file __P((const char *, int)); extern int fc_execute_file __P((const char *)); +/* variables from common.c */ +extern sh_builtin_func_t *this_shell_builtin; +extern sh_builtin_func_t *last_shell_builtin; + +/* variables from evalfile.c */ +extern int sourcelevel; + +/* variables from evalstring.c */ +extern int parse_and_execute_level; + +/* variables from break.def/continue.def */ +extern int breaking; +extern int continuing; +extern int loop_level; + +/* variables from read.def */ +extern int sigalrm_seen; + +/* variables from source.def */ +extern int source_searches_cwd; +extern int source_uses_path; + +/* variables from wait.def */ +extern int wait_intr_flag; + #endif /* !__COMMON_H */ diff --git a/builtins/declare.def b/builtins/declare.def index c0fa3b56..4a8afbbe 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -88,9 +88,6 @@ $END #include "builtext.h" #include "bashgetopt.h" -extern int array_needs_making; -extern int posixly_correct; - static int declare_internal __P((register WORD_LIST *, int)); /* Declare or change variable attributes. */ @@ -303,7 +300,11 @@ declare_internal (list, local_var) name = savestring (list->word->word); wflags = list->word->flags; +#if defined (ARRAY_VARS) assoc_noexpand = assoc_expand_once && (wflags & W_ASSIGNMENT); +#else + assoc_noexpand = 0; +#endif offset = assignment (name, assoc_noexpand ? 2 : 0); aflags = 0; created_var = 0; diff --git a/builtins/echo.def b/builtins/echo.def index 3f8b5a93..b0eda849 100644 --- a/builtins/echo.def +++ b/builtins/echo.def @@ -99,8 +99,6 @@ int xpg_echo = 1; int xpg_echo = 0; #endif /* DEFAULT_ECHO_TO_XPG */ -extern int posixly_correct; - /* Print the words in LIST to standard output. If the first word is `-n', then don't print a trailing newline. We also support the echo syntax from Version 9 Unix systems. */ diff --git a/builtins/evalfile.c b/builtins/evalfile.c index 316b7940..4539b637 100644 --- a/builtins/evalfile.c +++ b/builtins/evalfile.c @@ -1,6 +1,6 @@ /* evalfile.c - read and evaluate commands from a file or file descriptor */ -/* Copyright (C) 1996-2015 Free Software Foundation, Inc. +/* Copyright (C) 1996-2017 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -36,6 +36,7 @@ #include "../bashintl.h" #include "../shell.h" +#include "../parser.h" #include "../jobs.h" #include "../builtins.h" #include "../flags.h" @@ -68,13 +69,6 @@ extern int errno; #define FEVAL_REGFILE 0x080 #define FEVAL_NOPUSHARGS 0x100 -extern int posixly_correct; -extern int indirection_level, subshell_environment; -extern int return_catch_flag, return_catch_value; -extern int last_command_exit_value; -extern int executing_command_builtin; -extern int current_token; /* parse.y */ - /* How many `levels' of sourced files we have. */ int sourcelevel = 0; diff --git a/builtins/evalstring.c b/builtins/evalstring.c index f258bd19..46dc36d6 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -1,6 +1,6 @@ /* evalstring.c - evaluate a string as one or more shell commands. */ -/* Copyright (C) 1996-2015 Free Software Foundation, Inc. +/* Copyright (C) 1996-2017 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -39,6 +39,7 @@ #include "../jobs.h" #include "../builtins.h" #include "../flags.h" +#include "../parser.h" #include "../input.h" #include "../execute_cmd.h" #include "../redir.h" @@ -60,19 +61,6 @@ extern int errno; #define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL) -extern int indirection_level, subshell_environment; -extern int line_number, line_number_for_err_trap; -extern int current_token, shell_eof_token; -extern int last_command_exit_value; -extern int running_trap; -extern int loop_level; -extern int executing_list; -extern int comsub_ignore_return; -extern int posixly_correct; -extern int return_catch_flag, return_catch_value; -extern sh_builtin_func_t *this_shell_builtin; -extern char *the_printed_command_except_trap; - int parse_and_execute_level = 0; static int cat_file __P((REDIRECT *)); diff --git a/builtins/exec.def b/builtins/exec.def index 1f4e2221..4bf51d9d 100644 --- a/builtins/exec.def +++ b/builtins/exec.def @@ -74,7 +74,6 @@ $END extern int errno; #endif /* !errno */ -extern int subshell_environment; extern REDIRECT *redirection_undo_list; extern char *exec_argv0; diff --git a/builtins/exit.def b/builtins/exit.def index f28c2342..5167b2e0 100644 --- a/builtins/exit.def +++ b/builtins/exit.def @@ -41,17 +41,14 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../execute_cmd.h" #include "../jobs.h" +#include "../trap.h" #include "common.h" #include "builtext.h" /* for jobs_builtin */ extern int check_jobs_at_exit; -extern int last_command_exit_value; -extern int running_trap, trap_saved_exit_value; -extern int subshell_environment; -extern sh_builtin_func_t *this_shell_builtin; -extern sh_builtin_func_t *last_shell_builtin; static int exit_or_logout __P((WORD_LIST *)); static int sourced_logout; diff --git a/builtins/fc.def b/builtins/fc.def index fe164710..826fabe6 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -75,6 +75,7 @@ $END #include "../shell.h" #include "../builtins.h" #include "../flags.h" +#include "../parser.h" #include "../bashhist.h" #include "maxpath.h" #include @@ -85,11 +86,6 @@ $END extern int errno; #endif /* !errno */ -extern int current_command_line_count; -extern int literal_history; -extern int posixly_correct; -extern int subshell_environment, interactive_shell; - extern int unlink __P((const char *)); extern FILE *sh_mktmpfp __P((char *, int, char **)); diff --git a/builtins/fg_bg.def b/builtins/fg_bg.def index 1565e0a1..6a68d6ab 100644 --- a/builtins/fg_bg.def +++ b/builtins/fg_bg.def @@ -46,13 +46,12 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../execute_cmd.h" #include "../jobs.h" #include "common.h" #include "bashgetopt.h" #if defined (JOB_CONTROL) -extern char *this_command_name; - static int fg_bg __P((WORD_LIST *, int)); /* How to bring a job into the foreground. */ diff --git a/builtins/getopts.def b/builtins/getopts.def index 590b1103..f473ef01 100644 --- a/builtins/getopts.def +++ b/builtins/getopts.def @@ -77,6 +77,7 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../execute_cmd.h" #include "common.h" #include "bashgetopt.h" #include "getopt.h" @@ -85,8 +86,6 @@ $END #define G_INVALID_OPT -2 #define G_ARG_MISSING -3 -extern char *this_command_name; - static int getopts_unbind_variable __P((char *)); static int getopts_bind_variable __P((char *, char *)); static int dogetopts __P((int, char **)); diff --git a/builtins/hash.def b/builtins/hash.def index bec4b073..df3e93df 100644 --- a/builtins/hash.def +++ b/builtins/hash.def @@ -61,15 +61,14 @@ $END #include "../shell.h" #include "../builtins.h" +#include "../execute_cmd.h" #include "../flags.h" #include "../findcmd.h" #include "../hashcmd.h" #include "common.h" #include "bashgetopt.h" -extern int posixly_correct; extern int dot_found_in_search; -extern char *this_command_name; static int add_hashed_command __P((char *, int)); static int print_hash_info __P((BUCKET_CONTENTS *)); diff --git a/builtins/help.def b/builtins/help.def index 8f175d1f..3b83c8ba 100644 --- a/builtins/help.def +++ b/builtins/help.def @@ -64,6 +64,7 @@ $END #include "../shell.h" #include "../builtins.h" +#include "../execute_cmd.h" #include "../pathexp.h" #include "common.h" #include "bashgetopt.h" @@ -78,9 +79,6 @@ extern int errno; extern const char * const bash_copyright; extern const char * const bash_license; -extern char *this_command_name; -extern struct builtin *current_builtin; - static void show_builtin_command_help __P((void)); static int open_helpfile __P((char *)); static void show_desc __P((char *, int)); @@ -132,7 +130,7 @@ help_builtin (list) if (glob_pattern_p (list->word->word)) { - printf (ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1))); + printf ("%s", ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1))); print_word_list (list, ", "); printf ("'\n\n"); } diff --git a/builtins/history.def b/builtins/history.def index 4573b437..7d92d2ff 100644 --- a/builtins/history.def +++ b/builtins/history.def @@ -75,6 +75,7 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../parser.h" #include "../bashhist.h" #include #include "bashgetopt.h" @@ -84,9 +85,6 @@ $END extern int errno; #endif -extern int current_command_line_count; -extern int force_append_history; /* shopt -s histappend */ - static char *histtime __P((HIST_ENTRY *, const char *)); static int display_history __P((WORD_LIST *)); static void push_history __P((WORD_LIST *)); diff --git a/builtins/kill.def b/builtins/kill.def index f05189de..ad4e5bbb 100644 --- a/builtins/kill.def +++ b/builtins/kill.def @@ -70,8 +70,6 @@ $END extern int errno; #endif /* !errno */ -extern int posixly_correct; - static void kill_error __P((pid_t, int)); #if !defined (CONTINUE_AFTER_KILL_ERROR) diff --git a/builtins/read.def b/builtins/read.def index eebdf593..131d0271 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -112,8 +112,6 @@ $END extern int errno; #endif -extern int posixly_correct; - struct ttsave { int fd; diff --git a/builtins/return.def b/builtins/return.def index 4d9fef1d..77e8d7c7 100644 --- a/builtins/return.def +++ b/builtins/return.def @@ -46,13 +46,10 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../execute_cmd.h" #include "common.h" #include "bashgetopt.h" -extern int last_command_exit_value; -extern int subshell_environment; -extern int return_catch_flag, return_catch_value; - /* If we are executing a user-defined function then exit with the value specified as an argument. if no argument is given, then the last exit status is used. */ diff --git a/builtins/set.def b/builtins/set.def index 9a45f388..3c25e3a2 100644 --- a/builtins/set.def +++ b/builtins/set.def @@ -35,6 +35,7 @@ $PRODUCES set.c #include "../bashintl.h" #include "../shell.h" +#include "../parser.h" #include "../flags.h" #include "common.h" #include "bashgetopt.h" @@ -49,14 +50,6 @@ $PRODUCES set.c # include "../bashhist.h" #endif -extern int posixly_correct, ignoreeof, eof_encountered_limit; -#if defined (HISTORY) -extern int dont_save_function_defs; -#endif -#if defined (READLINE) -extern int no_line_editing; -#endif /* READLINE */ - $BUILTIN set $FUNCTION set_builtin $SHORT_DOC set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...] diff --git a/builtins/setattr.def b/builtins/setattr.def index 8f29e11e..6eb61054 100644 --- a/builtins/setattr.def +++ b/builtins/setattr.def @@ -34,13 +34,11 @@ $PRODUCES setattr.c #include "../bashintl.h" #include "../shell.h" +#include "../execute_cmd.h" #include "../flags.h" #include "common.h" #include "bashgetopt.h" -extern int posixly_correct; -extern int array_needs_making; -extern char *this_command_name; extern sh_builtin_func_t *this_shell_builtin; #ifdef ARRAY_VARS diff --git a/builtins/shopt.def b/builtins/shopt.def index 615c7cc6..716f7c84 100644 --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -110,16 +110,13 @@ extern int enable_hostname_completion __P((int)); extern int prog_completion_enabled; #endif -#if defined (RESTRICTED_SHELL) -extern char *shell_name; -#endif - #if defined (DEBUGGER) extern int debugging_mode; #endif #if defined (ARRAY_VARS) extern int assoc_expand_once; +extern int array_expand_once; #endif static void shopt_error __P((char *)); diff --git a/builtins/source.def b/builtins/source.def index b3df1f9f..6abb337f 100644 --- a/builtins/source.def +++ b/builtins/source.def @@ -69,6 +69,7 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../execute_cmd.h" #include "../flags.h" #include "../findcmd.h" #include "common.h" @@ -79,10 +80,6 @@ $END extern int errno; #endif /* !errno */ -extern int posixly_correct; -extern int last_command_exit_value; -extern int executing_command_builtin; - static void maybe_pop_dollar_vars __P((void)); /* If non-zero, `.' uses $PATH to look up the script to be sourced. */ diff --git a/builtins/test.def b/builtins/test.def index d6c89bf9..bd9a203b 100644 --- a/builtins/test.def +++ b/builtins/test.def @@ -125,11 +125,10 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../execute_cmd.h" #include "../test.h" #include "common.h" -extern char *this_command_name; - /* TEST/[ builtin. */ int test_builtin (list) diff --git a/builtins/trap.def b/builtins/trap.def index d43b0ef6..09846981 100644 --- a/builtins/trap.def +++ b/builtins/trap.def @@ -97,9 +97,6 @@ static int display_traps __P((WORD_LIST *)); #define REVERT 1 /* Revert to this signals original value. */ #define IGNORE 2 /* Ignore this signal. */ -extern int posixly_correct, subshell_environment; -extern int sourcelevel, running_trap; - int trap_builtin (list) WORD_LIST *list; diff --git a/builtins/type.def b/builtins/type.def index 3187add2..699ecd20 100644 --- a/builtins/type.def +++ b/builtins/type.def @@ -64,6 +64,8 @@ $END #include "../bashintl.h" #include "../shell.h" +#include "../parser.h" +#include "../execute_cmd.h" #include "../findcmd.h" #include "../hashcmd.h" @@ -76,9 +78,6 @@ $END extern int find_reserved_word __P((char *)); -extern char *this_command_name; -extern int expand_aliases, posixly_correct; - /* For each word in LIST, find out what the shell is going to do with it as a simple command. i.e., which file would this shell use to execve, or if it is a builtin command, or an alias. Possible flag diff --git a/builtins/ulimit.def b/builtins/ulimit.def index 62def4f6..9b88c8cb 100644 --- a/builtins/ulimit.def +++ b/builtins/ulimit.def @@ -203,8 +203,6 @@ extern int errno; #define BLOCKSIZE(x) (((x) == POSIXBLK) ? (posixly_correct ? 512 : 1024) : (x)) -extern int posixly_correct; - static int _findlim __P((int)); static int ulimit_internal __P((int, char *, int, int)); diff --git a/builtins/wait.def b/builtins/wait.def index 974f959b..7cf7e3e4 100644 --- a/builtins/wait.def +++ b/builtins/wait.def @@ -68,12 +68,12 @@ $END #include "../bashansi.h" #include "../shell.h" +#include "../execute_cmd.h" #include "../jobs.h" #include "common.h" #include "bashgetopt.h" extern int wait_signal_received; -extern int last_command_exit_signal; procenv_t wait_intr_buf; int wait_intr_flag; diff --git a/command.h b/command.h index 3bf479ac..678df791 100644 --- a/command.h +++ b/command.h @@ -353,6 +353,7 @@ typedef struct group_com { typedef struct subshell_com { int flags; + int line; COMMAND *command; } SUBSHELL_COM; diff --git a/config-top.h b/config-top.h index d89682e5..8f02d9c8 100644 --- a/config-top.h +++ b/config-top.h @@ -123,7 +123,8 @@ /* Define if you want to include code in shell.c to support wordexp(3) */ /* #define WORDEXP_OPTION */ -/* Define as 1 if you want to enable code that implements multiple coprocs */ +/* Define as 1 if you want to enable code that implements multiple coprocs + executing simultaneously */ #ifndef MULTIPLE_COPROCS # define MULTIPLE_COPROCS 0 #endif diff --git a/copy_cmd.c b/copy_cmd.c index 826e0c3a..d3ba7673 100644 --- a/copy_cmd.c +++ b/copy_cmd.c @@ -221,6 +221,7 @@ copy_subshell_command (com) new_subshell = (SUBSHELL_COM *)xmalloc (sizeof (SUBSHELL_COM)); new_subshell->command = copy_command (com->command); new_subshell->flags = com->flags; + new_subshell->line = com->line; return (new_subshell); } diff --git a/error.c b/error.c index b05c39eb..417c902e 100644 --- a/error.c +++ b/error.c @@ -44,6 +44,7 @@ extern int errno; #include "bashintl.h" #include "shell.h" +#include "execute_cmd.h" #include "flags.h" #include "input.h" @@ -53,8 +54,6 @@ extern int errno; extern int executing_line_number __P((void)); -extern int last_command_exit_value; -extern char *shell_name; #if defined (JOB_CONTROL) extern pid_t shell_pgrp; extern int give_terminal_to __P((pid_t, int)); diff --git a/eval.c b/eval.c index db53946a..c2ebf55b 100644 --- a/eval.c +++ b/eval.c @@ -35,6 +35,7 @@ #include "bashintl.h" #include "shell.h" +#include "parser.h" #include "flags.h" #include "trap.h" @@ -47,16 +48,6 @@ # include "bashhist.h" #endif -extern int EOF_reached; -extern int indirection_level; -extern int posixly_correct; -extern int subshell_environment, running_under_emacs; -extern int last_command_exit_value, stdin_redir; -extern int need_here_doc; -extern int current_command_number, current_command_line_count, line_number; -extern int expand_aliases; -extern char *ps0_prompt; - #if defined (HAVE_POSIX_SIGNALS) extern sigset_t top_level_mask; #endif diff --git a/execute_cmd.c b/execute_cmd.c index 2fff0939..03e6b836 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -66,6 +66,7 @@ extern int errno; #include "memalloc.h" #include "shell.h" #include /* use <...> so we pick it up from the build directory */ +#include "parser.h" #include "flags.h" #include "builtins.h" #include "hashlib.h" @@ -105,28 +106,13 @@ extern int errno; # include /* mbschr */ #endif -extern int dollar_dollar_pid; -extern int posixly_correct; -extern int expand_aliases; -extern int autocd; -extern int breaking, continuing, loop_level; -extern int parse_and_execute_level, running_trap, sourcelevel; -extern int command_string_index, line_number; -extern int dot_found_in_search; -extern int already_making_children; -extern int tempenv_assign_error; -extern char *the_printed_command, *shell_name; -extern pid_t last_command_subst_pid; -extern sh_builtin_func_t *last_shell_builtin, *this_shell_builtin; -extern char **subshell_argv, **subshell_envp; -extern int subshell_argc; +extern int command_string_index; +extern char *the_printed_command; extern time_t shell_start_time; #if 0 extern char *glob_argv_flags; #endif -extern int job_control; /* XXX */ - extern int close __P((int)); /* Static functions defined and used in this file. */ @@ -606,7 +592,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, /* Fork a subshell, turn off the subshell bit, turn off job control and call execute_command () on the command again. */ - line_number_for_err_trap = line_number; /* XXX - save value? */ + line_number_for_err_trap = line_number = command->value.Subshell->line; /* XXX - save value? */ tcmd = make_command_string (command); paren_pid = make_child (p = savestring (tcmd), asynchronous); @@ -1420,9 +1406,8 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close) int pipe_in, pipe_out; struct fd_bitmap *fds_to_close; { - int user_subshell, return_code, function_value, should_redir_stdin, invert; - int ois, user_coproc; - int result; + volatile int user_subshell, user_coproc, invert; + int return_code, function_value, should_redir_stdin, ois, result; volatile COMMAND *tcom; USE_VAR(user_subshell); @@ -2137,7 +2122,9 @@ coproc_pidchk (pid, status) #if MULTIPLE_COPROCS struct cpelement *cpe; - cpe = cpl_delete (pid); + /* We're not disposing the coproc because this is executed in a signal + handler context */ + cpe = cpl_search (pid); cp = cpe ? cpe->coproc : 0; #else cp = getcoprocbypid (pid); @@ -2283,7 +2270,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close) int rpipe[2], wpipe[2], estat, invert; pid_t coproc_pid; Coproc *cp; - char *tcmd, *p; + char *tcmd, *p, *name; sigset_t set, oset; /* XXX -- can be removed after changes to handle multiple coprocs */ @@ -2293,6 +2280,21 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close) coproc_init (&sh_coproc); #endif + /* XXX - expand coproc name without splitting -- bash-5.0 */ + /* could make this dependent on a shopt option */ + name = expand_string_unsplit_to_string (command->value.Coproc->name, 0); + /* Optional check -- bash-5.0. */ + if (legal_identifier (name) == 0) + { + internal_error (_("`%s': not a valid identifier"), name); + return (invert ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + } + else + { + free (command->value.Coproc->name); + command->value.Coproc->name = name; + } + invert = (command->flags & CMD_INVERT_RETURN) != 0; command_string_index = 0; tcmd = make_command_string (command); @@ -2325,7 +2327,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close) close (rpipe[1]); close (wpipe[0]); - /* XXX - possibly run Coproc->name through word expansion? */ + /* XXX - run Coproc->name through word expansion above -- bash-5.0 */ cp = coproc_alloc (command->value.Coproc->name, coproc_pid); cp->c_rfd = rpipe[0]; cp->c_wfd = wpipe[1]; @@ -2340,7 +2342,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close) UNBLOCK_SIGNAL (oset); #if 0 - itrace ("execute_coproc: [%d] %s", coproc_pid, the_printed_command); + itrace ("execute_coproc (%s): [%d] %s", command->value.Coproc->name, coproc_pid, the_printed_command); #endif close_pipes (pipe_in, pipe_out); @@ -3600,7 +3602,7 @@ execute_arith_command (arith_command) save_line_number = line_number; this_command_name = "(("; /* )) */ - line_number = arith_command->line; + line_number_for_err_trap = line_number = arith_command->line; /* If we're in a function, update the line number information. */ if (variable_context && interactive_shell) { @@ -3801,7 +3803,7 @@ execute_cond_command (cond_command) save_line_number = line_number; this_command_name = "[["; - line_number = cond_command->line; + line_number_for_err_trap = line_number = cond_command->line; /* If we're in a function, update the line number information. */ if (variable_context && interactive_shell) { diff --git a/execute_cmd.h b/execute_cmd.h index 4f53b6f7..21675e3c 100644 --- a/execute_cmd.h +++ b/execute_cmd.h @@ -1,6 +1,6 @@ /* execute_cmd.h - functions from execute_cmd.c. */ -/* Copyright (C) 1993-2015 Free Software Foundation, Inc. +/* Copyright (C) 1993-2017 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -35,6 +35,31 @@ struct func_array_state }; #endif +/* Variables delared in execute_cmd.c, used by many other files */ +extern int return_catch_flag; +extern int return_catch_value; +extern volatile int last_command_exit_value; +extern int last_command_exit_signal; +extern int builtin_ignoring_errexit; +extern int executing_builtin; +extern int executing_list; +extern int comsub_ignore_return; +extern int subshell_level; +extern int match_ignore_case; +extern int executing_command_builtin; +extern int funcnest, funcnest_max; +extern int evalnest, evalnest_max; +extern int sourcenest, sourcenest_max; +extern int stdin_redir; +extern int line_number_for_err_trap; + +extern char *the_printed_command_except_trap; + +extern char *this_command_name; +extern SHELL_VAR *this_shell_function; + +/* Functions delared in execute_cmd.c, used by many other files */ + extern struct fd_bitmap *new_fd_bitmap __P((int)); extern void dispose_fd_bitmap __P((struct fd_bitmap *)); extern void close_fd_bitmap __P((struct fd_bitmap *)); diff --git a/expr.c b/expr.c index 48a92fc2..0af5547b 100644 --- a/expr.c +++ b/expr.c @@ -82,6 +82,9 @@ #include "bashintl.h" #include "shell.h" +#include "arrayfunc.h" +#include "execute_cmd.h" +#include "flags.h" #include "subst.h" #include "typemax.h" /* INTMAX_MAX, INTMAX_MIN */ @@ -221,11 +224,7 @@ static EXPR_CONTEXT **expr_stack; static int expr_depth; /* Location in the stack. */ static int expr_stack_size; /* Number of slots already allocated. */ -extern char *this_command_name; -extern int unbound_vars_is_error, last_command_exit_value; - #if defined (ARRAY_VARS) -extern int assoc_expand_once; extern const char * const bash_badsub_errmsg; #endif @@ -320,7 +319,11 @@ expr_bind_variable (lhs, rhs) SHELL_VAR *v; int aflags; +#if defined (ARRAY_VARS) aflags = (assoc_expand_once && already_expanded) ? ASS_NOEXPAND : 0; +#else + aflags = 0; +#endif v = bind_int_variable (lhs, rhs, aflags); if (v && (readonly_p (v) || noassign_p (v))) sh_longjmp (evalbuf, 1); /* variable assignment error */ @@ -1113,7 +1116,10 @@ expr_streval (tok, e, lvalue) if (noeval) return (0); +#if defined (ARRAY_VARS) tflag = assoc_expand_once && already_expanded; /* for a start */ +#endif + /* [[[[[ */ #if defined (ARRAY_VARS) aflag = (tflag) ? AV_NOEXPAND : 0; diff --git a/externs b/externs new file mode 100644 index 00000000..bc668039 --- /dev/null +++ b/externs @@ -0,0 +1,41 @@ +bashhist.c:extern int rl_done, rl_dispatching; /* should really include readline.h */ +bashline.c:extern int no_symbolic_links; +bashline.c:extern STRING_INT_ALIST word_token_alist[]; +braces.c:extern int last_command_exit_value; +dispose_cmd.c:extern sh_obj_cache_t wdcache, wlcache; +error.c:extern pid_t shell_pgrp; +error.c:extern const char * const bash_badsub_errmsg; +eval.c:extern sigset_t top_level_mask; +execute_cmd.c:extern int command_string_index; +execute_cmd.c:extern char *the_printed_command; +execute_cmd.c:extern time_t shell_start_time; +execute_cmd.c:extern char *glob_argv_flags; +expr.c:extern const char * const bash_badsub_errmsg; +jobs.c:extern sigset_t top_level_mask; +jobs.c:extern WORD_LIST *subst_assign_varlist; +jobs.c:extern SigHandler **original_signals; +locale.c:extern int dump_translatable_strings, dump_po_strings; +mailcheck.c:extern time_t shell_start_time; +mksyntax.c:extern int optind; +mksyntax.c:extern char *optarg; +mksyntax.c:extern char *strerror(); +nojobs.c:extern sigset_t top_level_mask; +pcomplete.c:extern STRING_INT_ALIST word_token_alist[]; +pcomplete.c:extern char *signal_names[]; +redir.c:extern REDIRECT *redirection_undo_list; +redir.c:extern REDIRECT *exec_redirection_undo_list; +shell.c:extern struct passwd *getpwuid (); +shell.c:extern char **environ; /* used if no third argument to main() */ +shell.c:extern int gnu_error_format; +sig.c:extern void initialize_siglist (); +subst.c:extern struct fd_bitmap *current_fds_to_close; +subst.c:extern int wordexp_only; +subst.c:extern PROCESS *last_procsub_child; +trap.c:extern procenv_t alrmbuf; +trap.c:extern volatile int from_return_trap; +trap.c:extern WORD_LIST *subst_assign_varlist; +variables.c:extern char **environ; +variables.c:extern time_t shell_start_time; +version.c:extern char *shell_name; +version2.c:extern char *shell_name; +xmalloc.c:extern char *sbrk(); diff --git a/findcmd.c b/findcmd.c index 7ff349ce..8c6e2d63 100644 --- a/findcmd.c +++ b/findcmd.c @@ -38,6 +38,7 @@ #include "memalloc.h" #include "shell.h" +#include "execute_cmd.h" #include "flags.h" #include "hashlib.h" #include "pathexp.h" @@ -50,9 +51,6 @@ extern int errno; #endif -extern int posixly_correct; -extern int last_command_exit_value; - /* Static functions defined and used in this file. */ static char *_find_user_command_internal __P((const char *, int)); static char *find_user_command_internal __P((const char *, int)); diff --git a/findcmd.h b/findcmd.h index bc4a41af..34b49149 100644 --- a/findcmd.h +++ b/findcmd.h @@ -39,4 +39,9 @@ extern char *search_for_command __P((const char *, int)); extern char *user_command_matches __P((const char *, int, int)); extern void setup_exec_ignore __P((char *)); +extern int dot_found_in_search; + +/* variables managed via shopt */ +extern int check_hashed_filenames; + #endif /* _FINDCMD_H_ */ diff --git a/flags.c b/flags.c index 3177efe4..6e208419 100644 --- a/flags.c +++ b/flags.c @@ -25,6 +25,7 @@ #endif #include "shell.h" +#include "execute_cmd.h" #include "flags.h" #if defined (BANG_HISTORY) @@ -35,16 +36,6 @@ extern int set_job_control __P((int)); #endif -#if defined (RESTRICTED_SHELL) -extern char *shell_name; -#endif - -extern int shell_initialized; -extern int builtin_ignoring_errexit; - -/* -c, -s invocation options -- not really flags, but they show up in $- */ -extern int want_pending_command, read_from_stdin; - /* **************************************************************** */ /* */ /* The Standard sh Flags. */ diff --git a/flags.h b/flags.h index 07149eab..fdbf7f97 100644 --- a/flags.h +++ b/flags.h @@ -50,6 +50,9 @@ extern int asynchronous_notification, interactive_comments, no_symbolic_links, function_trace_mode, error_trace_mode, pipefail_opt; +/* -c, -s invocation options -- not really flags, but they show up in $- */ +extern int want_pending_command, read_from_stdin; + #if 0 extern int lexical_scoping; #endif diff --git a/general.c b/general.c index 9e4dc7d9..338b53c8 100644 --- a/general.c +++ b/general.c @@ -39,9 +39,14 @@ #include "bashintl.h" #include "shell.h" +#include "parser.h" +#include "flags.h" +#include "findcmd.h" #include "test.h" #include "trap.h" +#include "builtins/common.h" + #if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR) # include /* mbschr */ #endif @@ -52,14 +57,6 @@ extern int errno; #endif /* !errno */ -extern int expand_aliases; -extern int interactive_comments; -extern int check_hashed_filenames; -extern int source_uses_path; -extern int source_searches_cwd; -extern int posixly_correct; -extern int inherit_errexit; - static char *bash_special_tilde_expansions __P((char *)); static int unquoted_tilde_word __P((const char *)); static void initialize_group_array __P((void)); diff --git a/hashcmd.c b/hashcmd.c index fc0bfbe2..c53764f1 100644 --- a/hashcmd.c +++ b/hashcmd.c @@ -31,11 +31,10 @@ #include "bashansi.h" #include "shell.h" +#include "flags.h" #include "findcmd.h" #include "hashcmd.h" -extern int hashing_enabled; - HASH_TABLE *hashed_filenames = (HASH_TABLE *)NULL; static void phash_freedata __P((PTR_T)); diff --git a/input.c b/input.c index a03911d3..ffd0c4b8 100644 --- a/input.c +++ b/input.c @@ -36,12 +36,9 @@ #include "bashansi.h" #include "bashintl.h" -#include "command.h" -#include "general.h" +#include "shell.h" #include "input.h" -#include "error.h" #include "externs.h" -#include "quit.h" #include "trap.h" #if !defined (errno) @@ -153,8 +150,6 @@ ungetc_with_restart (c, stream) #endif #define min(a, b) ((a) > (b) ? (b) : (a)) -extern int interactive_shell; - int bash_input_fd_changed; /* This provides a way to map from a file descriptor to the buffer diff --git a/input.h b/input.h index 0cbfcbee..5f860962 100644 --- a/input.h +++ b/input.h @@ -1,6 +1,6 @@ /* input.h -- Structures and unions used for reading input. */ -/* Copyright (C) 1993-2009 Free Software Foundation, Inc. +/* Copyright (C) 1993-2016 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -67,6 +67,7 @@ extern BUFFERED_STREAM **buffers; #endif extern int default_buffered_input; +extern int bash_input_fd_changed; #endif /* BUFFERED_INPUT */ diff --git a/jobs.c b/jobs.c index 97a32f24..657b84f1 100644 --- a/jobs.c +++ b/jobs.c @@ -68,6 +68,7 @@ #include "bashansi.h" #include "bashintl.h" #include "shell.h" +#include "parser.h" #include "jobs.h" #include "execute_cmd.h" #include "flags.h" @@ -162,19 +163,7 @@ extern int killpg __P((pid_t, int)); typedef int sh_job_map_func_t __P((JOB *, int, int, int)); /* Variables used here but defined in other files. */ -extern int subshell_environment, line_number; -extern int posixly_correct, shell_level; -extern int last_command_exit_value, last_command_exit_signal; -extern int loop_level, breaking; -extern int executing_list; -extern int sourcelevel; -extern int running_trap; -extern sh_builtin_func_t *this_shell_builtin; -extern char *shell_name, *this_command_name; extern sigset_t top_level_mask; -extern procenv_t wait_intr_buf; -extern int wait_intr_flag; -extern int wait_signal_received; extern WORD_LIST *subst_assign_varlist; extern SigHandler **original_signals; diff --git a/jobs.h b/jobs.h index 6df0607e..ae1f4356 100644 --- a/jobs.h +++ b/jobs.h @@ -183,8 +183,14 @@ extern struct jobstats js; extern pid_t original_pgrp, shell_pgrp, pipeline_pgrp; extern volatile pid_t last_made_pid, last_asynchronous_pid; +extern pid_t last_command_subst_pid; extern int asynchronous_notification; +extern int already_making_children; +extern int running_in_background; + +extern PROCESS *last_procsub_child; + extern JOB **jobs; extern void making_children __P((void)); diff --git a/make_cmd.c b/make_cmd.c index b42e9ff1..a1a41fa9 100644 --- a/make_cmd.c +++ b/make_cmd.c @@ -34,19 +34,11 @@ #include "bashintl.h" +#include "shell.h" +#include "execute_cmd.h" #include "parser.h" -#include "syntax.h" -#include "command.h" -#include "general.h" -#include "error.h" #include "flags.h" -#include "make_cmd.h" -#include "dispose_cmd.h" -#include "variables.h" -#include "subst.h" #include "input.h" -#include "ocache.h" -#include "externs.h" #if defined (JOB_CONTROL) #include "jobs.h" @@ -54,10 +46,6 @@ #include "shmbutil.h" -extern int line_number, current_command_line_count, parser_state; -extern int last_command_exit_value; -extern int shell_initialized; - int here_doc_first_line = 0; /* Object caching */ @@ -822,6 +810,7 @@ make_subshell_command (command) temp = (SUBSHELL_COM *)xmalloc (sizeof (SUBSHELL_COM)); temp->command = command; temp->flags = CMD_WANT_SUBSHELL; + temp->line = line_number; return (make_command (cm_subshell, (SIMPLE_COM *)temp)); } diff --git a/make_cmd.h b/make_cmd.h index f17774d9..fcd7766d 100644 --- a/make_cmd.h +++ b/make_cmd.h @@ -23,6 +23,8 @@ #include "stdc.h" +extern int here_doc_first_line; + extern void cmd_init __P((void)); extern WORD_DESC *alloc_word_desc __P((void)); diff --git a/nojobs.c b/nojobs.c index b1b995e0..9ea33e88 100644 --- a/nojobs.c +++ b/nojobs.c @@ -49,6 +49,7 @@ #include "trap.h" #include "builtins/builtext.h" /* for wait_builtin */ +#include "builtins/common.h" #define DEFAULT_CHILD_MAX 32 @@ -73,17 +74,9 @@ extern int errno; #endif /* !errno */ -extern int interactive, interactive_shell, login_shell; -extern int subshell_environment; -extern int last_command_exit_value, last_command_exit_signal; -extern int interrupt_immediately; -extern sh_builtin_func_t *this_shell_builtin; #if defined (HAVE_POSIX_SIGNALS) extern sigset_t top_level_mask; #endif -extern procenv_t wait_intr_buf; -extern int wait_intr_flag; -extern int wait_signal_received; extern void set_original_signal __P((int, SigHandler *)); diff --git a/parse.y b/parse.y index ed01bf50..f900c672 100644 --- a/parse.y +++ b/parse.y @@ -45,6 +45,7 @@ #define NEED_STRFTIME_DECL /* used in externs.h */ #include "shell.h" +#include "execute_cmd.h" #include "typemax.h" /* SIZE_MAX if needed */ #include "trap.h" #include "flags.h" @@ -119,20 +120,16 @@ extern int eof_encountered; extern int no_line_editing, running_under_emacs; extern int current_command_number; extern int sourcelevel, parse_and_execute_level; -extern int posixly_correct; -extern int last_command_exit_value; extern pid_t last_command_subst_pid; -extern char *shell_name, *current_host_name; extern char *dist_version; extern int patch_level; extern int dump_translatable_strings, dump_po_strings; extern sh_builtin_func_t *last_shell_builtin, *this_shell_builtin; -extern int here_doc_first_line; -#if defined (BUFFERED_INPUT) -extern int bash_input_fd_changed; + +#if !defined (errno) +extern int errno; #endif -extern int errno; /* **************************************************************** */ /* */ /* "Forward" declarations */ @@ -4246,7 +4243,9 @@ xparse_dolparen (base, string, indp, flags) sh_input_line_state_t ls; int orig_ind, nc, sflags, orig_eof_token; char *ret, *s, *ep, *ostring; +#if defined (ALIAS) || defined (DPAREN_ARITHMETIC) STRING_SAVER *saved_pushed_strings; +#endif /*yydebug = 1;*/ orig_ind = *indp; @@ -4259,8 +4258,10 @@ xparse_dolparen (base, string, indp, flags) save_parser_state (&ps); save_input_line_state (&ls); orig_eof_token = shell_eof_token; +#if defined (ALIAS) || defined (DPAREN_ARITHMETIC) saved_pushed_strings = pushed_string_list; /* separate parsing context */ pushed_string_list = (STRING_SAVER *)NULL; +#endif /*(*/ parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/ @@ -4274,7 +4275,9 @@ xparse_dolparen (base, string, indp, flags) /* reset_parser clears shell_input_line and associated variables */ restore_input_line_state (&ls); +#if defined (ALIAS) || defined (DPAREN_ARITHMETIC) pushed_string_list = saved_pushed_strings; +#endif token_to_read = 0; diff --git a/parser.h b/parser.h index 8d396dff..88c799d8 100644 --- a/parser.h +++ b/parser.h @@ -70,4 +70,30 @@ struct dstack { #define DOLBRACE_QUOTE 0x40 /* single quote is special in double quotes */ #define DOLBRACE_QUOTE2 0x80 /* single quote is semi-special in double quotes */ +/* variable declarations from parse.y */ +extern struct dstack dstack; + +extern char *primary_prompt; +extern char *secondary_prompt; + +extern char *current_prompt_string; + +extern char *ps1_prompt; +extern char *ps2_prompt; +extern char *ps0_prompt; + +extern int expand_aliases; +extern int current_command_line_count; +extern int saved_command_line_count; +extern int shell_eof_token; +extern int current_token; +extern int parser_state; +extern int need_here_doc; + +extern int ignoreeof; +extern int eof_encountered; +extern int eof_encountered_limit; + +extern int line_number, line_number_base; + #endif /* _PARSER_H_ */ diff --git a/pcomplete.c b/pcomplete.c index 3d734d97..4f4d5cae 100644 --- a/pcomplete.c +++ b/pcomplete.c @@ -84,10 +84,8 @@ typedef SHELL_VAR **SVFUNC (); extern char *strpbrk __P((char *, char *)); #endif -extern int array_needs_making; extern STRING_INT_ALIST word_token_alist[]; extern char *signal_names[]; -extern sh_builtin_func_t *last_shell_builtin, *this_shell_builtin; #if defined (DEBUG) #if defined (PREFER_STDARG) diff --git a/print_cmd.c b/print_cmd.c index f749d634..02a5049d 100644 --- a/print_cmd.c +++ b/print_cmd.c @@ -51,9 +51,6 @@ extern int printf __P((const char *, ...)); /* Yuck. Double yuck. */ #endif -extern int indirection_level; -extern int posixly_correct; - static int indentation; static int indentation_amount = 4; diff --git a/redir.c b/redir.c index 90a03bbb..1f4ce41a 100644 --- a/redir.c +++ b/redir.c @@ -1,6 +1,6 @@ /* redir.c -- Functions to perform input and output redirection. */ -/* Copyright (C) 1997-2015 Free Software Foundation, Inc. +/* Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -62,9 +62,6 @@ extern int errno; int expanding_redir; -extern int posixly_correct; -extern int last_command_exit_value; -extern int executing_builtin; extern REDIRECT *redirection_undo_list; extern REDIRECT *exec_redirection_undo_list; diff --git a/shell.c b/shell.c index fd09e0a5..f577ae20 100644 --- a/shell.c +++ b/shell.c @@ -51,6 +51,7 @@ #define NEED_SH_SETLINEBUF_DECL /* used in externs.h */ #include "shell.h" +#include "parser.h" #include "flags.h" #include "trap.h" #include "mailcheck.h" @@ -60,6 +61,7 @@ #if defined (JOB_CONTROL) #include "jobs.h" #else +extern int running_in_background; extern int initialize_job_control __P((int)); extern int get_tty_state __P((void)); #endif /* JOB_CONTROL */ @@ -101,18 +103,7 @@ extern int errno; extern char **environ; /* used if no third argument to main() */ #endif -extern char *dist_version, *release_status; -extern int patch_level, build_version; -extern int shell_level; -extern int subshell_environment; -extern int running_in_background; -extern int last_command_exit_value; -extern int line_number; -extern int expand_aliases; -extern int array_needs_making; extern int gnu_error_format; -extern char *primary_prompt, *secondary_prompt; -extern char *this_command_name; /* Non-zero means that this shell has already been run; i.e. you should call shell_reinitialize () if you need to start afresh. */ diff --git a/shell.h b/shell.h index a8ca731f..9e0704bc 100644 --- a/shell.h +++ b/shell.h @@ -91,12 +91,38 @@ extern char **shell_environment; extern WORD_LIST *rest_of_args; /* Generalized global variables. */ +extern char *command_execution_string; + extern int debugging_mode; extern int executing, login_shell; extern int interactive, interactive_shell; extern int startup_state; +extern int reading_shell_script; +extern int shell_initialized; extern int subshell_environment; +extern int current_command_number; +extern int indirection_level; extern int shell_compatibility_level; +extern int running_under_emacs; + +extern int posixly_correct; +extern int no_line_editing; + +extern char *shell_name; +extern char *current_host_name; + +extern int subshell_argc; +extern char **subshell_argv; +extern char **subshell_envp; + +/* variables managed using shopt */ +extern int hup_on_exit; +extern int check_jobs_at_exit; +extern int autocd; + +/* from version.c */ +extern int build_version, patch_level; +extern char *dist_version, *release_status; extern int locale_mb_cur_max; extern int locale_utf8locale; diff --git a/sig.c b/sig.c index ad016313..66509aab 100644 --- a/sig.c +++ b/sig.c @@ -35,6 +35,7 @@ #include "bashintl.h" #include "shell.h" +#include "execute_cmd.h" #if defined (JOB_CONTROL) #include "jobs.h" #endif /* JOB_CONTROL */ @@ -54,22 +55,6 @@ # include "bashhist.h" #endif -extern int last_command_exit_value; -extern int last_command_exit_signal; -extern int return_catch_flag; -extern int running_trap; -extern int loop_level, continuing, breaking, funcnest; -extern int executing_list; -extern int comsub_ignore_return; -extern int parse_and_execute_level, shell_initialized; -#if defined (HISTORY) -extern int history_lines_this_session; -#endif -extern int no_line_editing; -extern int wait_signal_received; -extern int wait_intr_flag; -extern sh_builtin_func_t *this_shell_builtin; - extern void initialize_siglist (); #if !defined (JOB_CONTROL) @@ -737,6 +722,13 @@ set_signal_handler (sig, handler) #if defined (SIGCHLD) if (sig == SIGCHLD) act.sa_flags |= SA_RESTART; /* XXX */ +#endif + /* XXX - bash-5.0 */ + /* Let's see if we can keep SIGWINCH from interrupting interruptible system + calls, like open(2)/read(2)/write(2) */ +#if defined (SIGWINCH) + if (sig == SIGWINCH) + act.sa_flags |= SA_RESTART; /* XXX */ #endif /* If we're installing a SIGTERM handler for interactive shells, we want it to be as close to SIG_IGN as possible. */ diff --git a/subst.c b/subst.c index fafb39aa..06ee894c 100644 --- a/subst.c +++ b/subst.c @@ -188,23 +188,8 @@ int allow_null_glob_expansion; int fail_glob_expansion; /* Extern functions and variables from different files. */ -extern int last_command_exit_value, last_command_exit_signal; -extern int subshell_environment, running_in_background; -extern int subshell_level, parse_and_execute_level, sourcelevel; -extern int eof_encountered, line_number; -extern int return_catch_flag, return_catch_value; -extern pid_t dollar_dollar_pid; -extern int posixly_correct; -extern char *this_command_name; extern struct fd_bitmap *current_fds_to_close; extern int wordexp_only; -extern int expanding_redir; -extern int tempenv_assign_error; -extern int builtin_ignoring_errexit; - -#if defined (ARRAY_VARS) -extern int assoc_expand_once; -#endif #if defined (JOB_CONTROL) && defined (PROCESS_SUBSTITUTION) extern PROCESS *last_procsub_child; @@ -6782,7 +6767,7 @@ parameter_brace_expand_indir (name, var_is_special, quoted, quoted_dollar_atp, c /* Array references to unset variables are also an error */ if (t == 0 && valid_array_reference (name, 0)) { - v = array_variable_part (name, 0, (int *)0, (int *)0); + v = array_variable_part (name, 0, (char **)0, (int *)0); if (v == 0) { report_error (_("%s: invalid indirect expansion"), name); diff --git a/subst.h b/subst.h index c588ccb3..84a6e83d 100644 --- a/subst.h +++ b/subst.h @@ -322,6 +322,10 @@ extern size_t ifs_firstc_len; extern unsigned char ifs_firstc; #endif +extern int assigning_in_environment; +extern int expanding_redir; +extern int inherit_errexit; + /* Evaluates to 1 if C is a character in $IFS. */ #define isifs(c) (ifs_cmap[(unsigned char)(c)] != 0) diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 58c375b7..554f3d6e 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -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 diff --git a/tests/array.right b/tests/array.right index 3d226091..d079a351 100644 --- a/tests/array.right +++ b/tests/array.right @@ -520,3 +520,13 @@ argv[1] = <> argv[2] = p3 argv[1] = +./array23.sub: line 9: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ") +./array23.sub: line 10: $( echo >&2 foo ) : syntax error: operand expected (error token is "$( echo >&2 foo ) ") +foo +0 +foo +foo +foo +6 +./array23.sub: line 21: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )") +./array23.sub: line 22: $( echo >&2 foo ): syntax error: operand expected (error token is "$( echo >&2 foo )") diff --git a/tests/array.tests b/tests/array.tests index 79e1a062..c8cf1753 100644 --- a/tests/array.tests +++ b/tests/array.tests @@ -398,3 +398,4 @@ ${THIS_SH} ./array19.sub ${THIS_SH} ./array20.sub ${THIS_SH} ./array21.sub ${THIS_SH} ./array22.sub +${THIS_SH} ./array23.sub diff --git a/tests/array23.sub b/tests/array23.sub new file mode 100644 index 00000000..a762aadb --- /dev/null +++ b/tests/array23.sub @@ -0,0 +1,22 @@ +# this captures how bash and ksh93 expand indexed array subscripts in +# various contexts. if changes are ever made, or an option added to do +# this differently, the diffs will show up here + +typeset -a array + +index='$( echo >&2 foo )' # Literal shell code should never be evaluated unless an 'eval' is involved. + +echo ${array[ $index ]} # [] expands $index, results in a literal that [] does not re-evaluate. +echo $(( $index )) # (( )) expands $index, results in a literal that (( )) does not re-evaluate. +echo $(( array[ $index ] )) # (( )) expands $index, results in a literal that [] DOES re-evaluate. + +(( array[ $index ] )) + +typeset -a a + +: $(( a[$index]=5 )) + +#shopt -s assoc_expand_once +echo $((1+a[$index])) +echo $((1+a[\$index])) +echo "1+${a[$index]}" diff --git a/tests/assoc.right b/tests/assoc.right index 6de4af26..4934496f 100644 --- a/tests/assoc.right +++ b/tests/assoc.right @@ -215,3 +215,7 @@ declare -A a=(["80's"]="Depeche Mode" ) ./assoc9.sub: line 83: printf: `a[80's]': not a valid identifier declare -A a declare -A a=(["80's"]="Depeche Mode" ) +6 +1 +1+5 +declare -A a=(["\$(date >&2)"]="5" ) diff --git a/tests/assoc9.sub b/tests/assoc9.sub index 30161aad..e7edee1c 100644 --- a/tests/assoc9.sub +++ b/tests/assoc9.sub @@ -87,3 +87,16 @@ shopt -s assoc_expand_once printf -v a[$b] "%s" "Depeche Mode" typeset -p a + +unset a + +declare -A a +x='$(date >&2)' +a[$x]=5 + +shopt -s assoc_expand_once +echo $((1+a[$x])) +echo $((1+a[\$x])) +echo "1+${a[$x]}" + +declare -p a diff --git a/tests/nameref.right b/tests/nameref.right index a5312aef..220b1b50 100644 --- a/tests/nameref.right +++ b/tests/nameref.right @@ -306,30 +306,38 @@ declare -a b=([0]="0") ./nameref15.sub: line 19: warning: ref: circular name reference ./nameref15.sub: line 20: warning: ref: circular name reference ./nameref15.sub: line 21: warning: ref: circular name reference -inside +inside X outside X -./nameref15.sub: line 29: typeset: ref: nameref variable self references not allowed -./nameref15.sub: line 31: ref: nameref variable self references not allowed +before: 7 +./nameref15.sub: line 32: typeset: warning: xxx: circular name reference +./nameref15.sub: line 32: warning: xxx: circular name reference +./nameref15.sub: line 33: warning: xxx: circular name reference +declare -n xxx="xxx" +./nameref15.sub: line 35: warning: xxx: circular name reference +xxx_func: inside: xxx = foo +after: foo +./nameref15.sub: line 46: typeset: ref: nameref variable self references not allowed +./nameref15.sub: line 48: ref: nameref variable self references not allowed declare -n ref="re" declare -n ref="re" declare -- re="4" 4 declare -n foo="var[@]" declare -n ref="var[@]" -./nameref15.sub: line 48: var[@]: bad array subscript +./nameref15.sub: line 65: var[@]: bad array subscript declare -n bar="var[@]" -./nameref15.sub: line 53: var[@]: bad array subscript +./nameref15.sub: line 70: var[@]: bad array subscript declare -n a="b" declare -n b="a[1]" -./nameref15.sub: line 61: warning: a: removing nameref attribute +./nameref15.sub: line 78: warning: a: removing nameref attribute declare -a a=([1]="foo") declare -n b="a[1]" -./nameref15.sub: line 66: warning: a: removing nameref attribute +./nameref15.sub: line 83: warning: a: removing nameref attribute declare -a a=([1]="foo") declare -n b="a[1]" declare -n n="v" declare -a v=([1]="1") -./nameref15.sub: line 82: typeset: n: not found +./nameref15.sub: line 99: typeset: n: not found declare -a v=([0]="0" [1]="1") declare -n n="v[1]" declare -a v=([0]="0") diff --git a/tests/nameref15.sub b/tests/nameref15.sub index 6c9ace5e..9fbacd4f 100644 --- a/tests/nameref15.sub +++ b/tests/nameref15.sub @@ -26,6 +26,23 @@ add_X_echo ref echo outside "$ref" unset ref +# same test, but assigning nameref variable circular reference directly +xxx_func() +{ + typeset -n xxx=xxx + xxx=foo + declare -p xxx + echo $FUNCNAME: inside: xxx = $xxx +} + +xxx=7 +echo before: $xxx +xxx_func +echo after: $xxx + +unset xxx +unset -f xxx_func + typeset -n ref=ref typeset -n ref=re ref+=f @@ -85,4 +102,3 @@ v=(0 1) declare -n n=v[1] unset n declare -p n v - diff --git a/trap.c b/trap.c index 5d9f5596..28013e88 100644 --- a/trap.c +++ b/trap.c @@ -38,7 +38,9 @@ #include "trap.h" #include "shell.h" +#include "execute_cmd.h" #include "flags.h" +#include "parser.h" #include "input.h" /* for save_token_state, restore_token_state */ #include "jobs.h" #include "signames.h" @@ -85,20 +87,10 @@ static void reset_or_restore_signal_handlers (sh_resetsig_func_t *); static void trap_if_untrapped (int, char *); /* Variables used here but defined in other files. */ -extern int last_command_exit_value; -extern int line_number; - -extern int sigalrm_seen; extern procenv_t alrmbuf; extern volatile int from_return_trap; -extern char *this_command_name; -extern sh_builtin_func_t *this_shell_builtin; -extern procenv_t wait_intr_buf; -extern int wait_intr_flag; -extern int return_catch_flag, return_catch_value; -extern int subshell_level; extern WORD_LIST *subst_assign_varlist; /* The list of things to do originally, before we started trapping. */ diff --git a/trap.h b/trap.h index 7b4d2923..91cec2d8 100644 --- a/trap.h +++ b/trap.h @@ -61,6 +61,9 @@ extern char *trap_list[]; extern int trapped_signal_received; +extern int wait_signal_received; +extern int running_trap; +extern int trap_saved_exit_value; /* Externally-visible functions declared in trap.c. */ extern void initialize_traps __P((void)); diff --git a/variables.c b/variables.c index 7244a465..eb0eb0f3 100644 --- a/variables.c +++ b/variables.c @@ -47,6 +47,7 @@ #define NEED_XTRACE_SET_DECL #include "shell.h" +#include "parser.h" #include "flags.h" #include "execute_cmd.h" #include "findcmd.h" @@ -96,30 +97,7 @@ extern char **environ; /* Variables used here and defined in other files. */ -extern int posixly_correct; -extern int line_number, line_number_base; -extern int subshell_environment, indirection_level, subshell_level; -extern int build_version, patch_level; -extern int expanding_redir; -extern int last_command_exit_value; -extern char *dist_version, *release_status; -extern char *shell_name; -extern char *primary_prompt, *secondary_prompt; -extern char *current_host_name; -extern sh_builtin_func_t *this_shell_builtin; -extern SHELL_VAR *this_shell_function; -extern char *the_printed_command_except_trap; -extern char *this_command_name; -extern char *command_execution_string; extern time_t shell_start_time; -extern int assigning_in_environment; -extern int executing_builtin; -extern int funcnest_max; - -#if defined (READLINE) -extern int no_line_editing; -extern int perform_hostname_completion; -#endif /* The list of shell variables that the user has created at the global scope, or that came from the environment. */ @@ -2006,6 +1984,13 @@ find_variable_nameref (v) if (v == orig || v == oldv) { internal_warning (_("%s: circular name reference"), orig->name); +#if 1 + /* XXX - provisional change - bash-5.0 - circular refs go to + global scope for resolution, without namerefs. */ + if (variable_context && v->context) + return (find_global_variable_noref (v->name)); + else +#endif return ((SHELL_VAR *)0); } } @@ -2903,12 +2888,6 @@ assign_value: /* Variables which are bound are visible. */ VUNSETATTR (entry, att_invisible); -#if defined (ARRAY_VARS) - if (assoc_p (entry) || array_p (entry)) - newval = make_array_variable_value (entry, 0, "0", value, aflags); - else -#endif - /* If we can optimize the assignment, do so and return. Right now, we optimize appends to string variables. */ if (can_optimize_assignment (entry, value, aflags)) @@ -2924,7 +2903,12 @@ assign_value: return (entry); } - + +#if defined (ARRAY_VARS) + if (assoc_p (entry) || array_p (entry)) + newval = make_array_variable_value (entry, 0, "0", value, aflags); + else +#endif newval = make_variable_value (entry, value, aflags); /* XXX */ /* Invalidate any cached export string */ @@ -5067,11 +5051,6 @@ pop_args () *************************************************/ /* Extern declarations for variables this code has to manage. */ -extern int eof_encountered, eof_encountered_limit, ignoreeof; - -#if defined (READLINE) -extern int hostname_list_initialized; -#endif /* An alist of name.function for each special variable. Most of the functions don't do much, and in fact, this would be faster with a diff --git a/variables.h b/variables.h index 7b398f33..3884f56a 100644 --- a/variables.h +++ b/variables.h @@ -236,6 +236,14 @@ extern int variable_context; extern char *dollar_vars[]; extern char **export_env; +extern int tempenv_assign_error; +extern int array_needs_making; +extern int shell_level; + +/* XXX */ +extern WORD_LIST *rest_of_args; +extern pid_t dollar_dollar_pid; + extern void initialize_shell_variables __P((char **, int)); extern SHELL_VAR *set_if_not __P((char *, char *));