diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-11-21 20:51:19 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-11-21 20:51:19 -0500 |
commit | 0001803f0b9523c94fa2ede48eaecb047fef4524 (patch) | |
tree | f334332811e033ff966d94f6268f0629a94304b3 /builtins | |
parent | 89a92869e56aba4e4cab2d639c00a86f0545c862 (diff) | |
download | android_external_bash-0001803f0b9523c94fa2ede48eaecb047fef4524.tar.gz android_external_bash-0001803f0b9523c94fa2ede48eaecb047fef4524.tar.bz2 android_external_bash-0001803f0b9523c94fa2ede48eaecb047fef4524.zip |
Bash-4.1 distribution source
Diffstat (limited to 'builtins')
-rw-r--r-- | builtins/Makefile.in | 82 | ||||
-rw-r--r-- | builtins/bind.def | 2 | ||||
-rw-r--r-- | builtins/command.def | 41 | ||||
-rw-r--r-- | builtins/common.c | 2 | ||||
-rw-r--r-- | builtins/common.h | 6 | ||||
-rw-r--r-- | builtins/complete.def | 70 | ||||
-rw-r--r-- | builtins/declare.def | 11 | ||||
-rw-r--r-- | builtins/evalfile.c | 22 | ||||
-rw-r--r-- | builtins/evalstring.c | 16 | ||||
-rw-r--r-- | builtins/help.def | 4 | ||||
-rw-r--r-- | builtins/kill.def | 5 | ||||
-rw-r--r-- | builtins/mapfile.def | 26 | ||||
-rw-r--r-- | builtins/printf.def | 35 | ||||
-rw-r--r-- | builtins/read.def | 27 | ||||
-rw-r--r-- | builtins/shopt.def | 156 |
15 files changed, 398 insertions, 107 deletions
diff --git a/builtins/Makefile.in b/builtins/Makefile.in index 96dfaa3..42f8cb8 100644 --- a/builtins/Makefile.in +++ b/builtins/Makefile.in @@ -333,7 +333,7 @@ evalstring.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h evalstring.o: $(topdir)/externs.h $(topdir)/jobs.h $(topdir)/builtins.h evalstring.o: $(topdir)/flags.h $(topdir)/input.h $(topdir)/execute_cmd.h evalstring.o: $(topdir)/bashhist.h $(srcdir)/common.h -evalstring.o: $(topdir)/trap.h $(topdir)/redir.h +evalstring.o: $(topdir)/trap.h $(topdir)/redir.h ../pathnames.h getopt.o: ../config.h $(BASHINCDIR)/memalloc.h getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/command.h getopt.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/error.h $(topdir)/variables.h $(topdir)/conftypes.h @@ -351,63 +351,67 @@ alias.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR) alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h alias.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/common.h alias.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +alias.o: ../pathnames.h bind.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h 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 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 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 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 +builtin.o: $(srcdir)/bashgetopt.h ../pathnames.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 caller.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h caller.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ./builtext.h -caller.o: ${BASHINCDIR}/chartypes.h $(topdir)/bashtypes.h +caller.o: ${BASHINCDIR}/chartypes.h $(topdir)/bashtypes.h ../pathnames.h cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h cd.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h cd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h +cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h command.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h command.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(BASHINCDIR)/maxpath.h command.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h command.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +command.o: ../pathnames.h declare.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h declare.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h declare.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h declare.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h declare.o: $(topdir)/arrayfunc.h $(srcdir)/bashgetopt.h -declare.o: ./builtext.h +declare.o: ./builtext.h ../pathnames.h echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h echo.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h echo.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -echo.o: $(BASHINCDIR)/maxpath.h +echo.o: $(BASHINCDIR)/maxpath.h ../pathnames.h enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h enable.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h enable.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h enable.o: $(topdir)/subst.h $(topdir)/externs.h enable.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -enable.o: $(BASHINCDIR)/maxpath.h +enable.o: $(BASHINCDIR)/maxpath.h ../pathnames.h enable.o: $(topdir)/pcomplete.h eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h eval.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h eval.o: $(topdir)/subst.h $(topdir)/externs.h eval.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -eval.o: $(BASHINCDIR)/maxpath.h +eval.o: $(BASHINCDIR)/maxpath.h ../pathnames.h exec.o: $(topdir)/bashtypes.h exec.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h exec.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h @@ -415,14 +419,14 @@ exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h exec.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/flags.h exec.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(BASHINCDIR)/maxpath.h -exec.o: $(topdir)/findcmd.h $(topdir)/jobs.h +exec.o: $(topdir)/findcmd.h $(topdir)/jobs.h ../pathnames.h exit.o: $(topdir)/bashtypes.h exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h exit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.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: $(BASHINCDIR)/maxpath.h ./builtext.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 @@ -432,30 +436,32 @@ fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.h $(topdir)/syntax.h fc.o: $(topdir)/flags.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h $(BASHINCDIR)/chartypes.h +fc.o: ../pathnames.h fg_bg.o: $(topdir)/bashtypes.h $(srcdir)/bashgetopt.h fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h 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 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)/jobs.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 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: ../pathnames.h hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.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: $(srcdir)/common.h $(BASHINCDIR)/maxpath.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: ${srcdir}/common.h +help.o: ${srcdir}/common.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 @@ -463,27 +469,30 @@ history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h history.o: $(topdir)/subst.h $(topdir)/externs.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 inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h inlib.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h inlib.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h inlib.o: $(BASHINCDIR)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h -inlib.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +inlib.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h ../pathnames.h jobs.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h jobs.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(srcdir)/bashgetopt.h jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h $(topdir)/jobs.h jobs.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h jobs.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +jobs.o: ../pathnames.h kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h kill.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h kill.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h kill.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/trap.h $(topdir)/unwind_prot.h kill.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/maxpath.h -kill.o: $(topdir)/jobs.h +kill.o: $(topdir)/jobs.h ../pathnames.h let.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h let.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h let.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h let.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +let.o: ../pathnames.h printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h @@ -491,104 +500,111 @@ printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h printf.o: ../pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h printf.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h printf.o: $(topdir)/bashtypes.h ${srcdir}/common.h $(BASHINCDIR)/chartypes.h +printf.o: ../pathnames.h pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h pushd.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h pushd.o: $(topdir)/subst.h $(topdir)/externs.h pushd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h +pushd.o: ../pathnames.h read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h read.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h read.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h read.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h read.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h read.o: $(BASHINCDIR)/shtty.h -read.o: $(topdir)/arrayfunc.h +read.o: $(topdir)/arrayfunc.h ../pathnames.h 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 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: ../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 -set.o: $(topdir)/arrayfunc.h +set.o: $(topdir)/arrayfunc.h ../pathnames.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 setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -setattr.o: $(topdir)/arrayfunc.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 shift.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h shift.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h shift.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +shift.o: ../pathnames.h +shopt.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +shopt.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h ../pathnames.h +shopt.o: $(topdir)/bashhist.h source.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/findcmd.h source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h 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: ../pathnames.h suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h suspend.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h suspend.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -suspend.o: $(topdir)/jobs.h +suspend.o: $(topdir)/jobs.h ../pathnames.h test.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h test.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.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 +test.o: $(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 times.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h times.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -times.o: $(BASHINCDIR)/posixtime.h +times.o: $(BASHINCDIR)/posixtime.h ../pathnames.h trap.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h trap.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h trap.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h trap.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h trap.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -trap.o: $(topdir)/findcmd.h +trap.o: $(topdir)/findcmd.h ../pathnames.h 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 type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h -type.o: $(topdir)/externs.h $(topdir)/hashcmd.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 ulimit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h ulimit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h ulimit.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h ulimit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +ulimit.o: ../pathnames.h umask.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h umask.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h umask.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h umask.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h umask.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -umask.o: $(BASHINCDIR)/chartypes.h +umask.o: $(BASHINCDIR)/chartypes.h ../pathnames.h wait.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h 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 -wait.o: $(BASHINCDIR)/chartypes.h -shopt.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h -shopt.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h -shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h -shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h -shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h +wait.o: $(BASHINCDIR)/chartypes.h ../pathnames.h -complete.o: ../config.h +complete.o: ../config.h ../pathnames.h complete.o: ${topdir}/shell.h $(topdir)/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h complete.o: ${topdir}/unwind_prot.h ${topdir}/variables.h complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h @@ -600,7 +616,7 @@ mapfile.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h mapfile.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h mapfile.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h mapfile.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/variables.h $(topdir)/conftypes.h -mapfile.o: $(topdir)/arrayfunc.h +mapfile.o: $(topdir)/arrayfunc.h ../pathnames.h #bind.o: $(RL_LIBSRC)chardefs.h $(RL_LIBSRC)readline.h $(RL_LIBSRC)keymaps.h diff --git a/builtins/bind.def b/builtins/bind.def index fcc3bbb..d0c953b 100644 --- a/builtins/bind.def +++ b/builtins/bind.def @@ -255,7 +255,7 @@ bind_builtin (list) if ((flags & RFLAG) && remove_seq) { - if (rl_set_key (remove_seq, (rl_command_func_t *)NULL, rl_get_keymap ()) != 0) + if (rl_bind_keyseq (remove_seq, (rl_command_func_t *)NULL) != 0) { builtin_error (_("`%s': cannot unbind"), remove_seq); BIND_RETURN (EXECUTION_FAILURE); diff --git a/builtins/command.def b/builtins/command.def index 77f9126..1845279 100644 --- a/builtins/command.def +++ b/builtins/command.def @@ -100,22 +100,6 @@ command_builtin (list) if (list == 0) return (EXECUTION_SUCCESS); - if (verbose) - { - int found, any_found; - - for (any_found = 0; list; list = list->next) - { - found = describe_command (list->word->word, verbose); - - if (found == 0 && verbose != CDESC_REUSABLE) - sh_notfound (list->word->word); - - any_found += found; - } - return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE); - } - #if defined (RESTRICTED_SHELL) if (use_standard_path && restricted) { @@ -126,8 +110,6 @@ command_builtin (list) begin_unwind_frame ("command_builtin"); - /* We don't want this to be reparsed (consider command echo 'foo &'), so - just make a simple_command structure and call execute_command with it. */ if (use_standard_path) { old_path = get_string_value ("PATH"); @@ -139,11 +121,32 @@ command_builtin (list) standard_path = get_standard_path (); bind_variable ("PATH", standard_path ? standard_path : "", 0); + stupidly_hack_special_variables ("PATH"); FREE (standard_path); } + if (verbose) + { + int found, any_found; + + for (any_found = 0; list; list = list->next) + { + found = describe_command (list->word->word, verbose); + + if (found == 0 && verbose != CDESC_REUSABLE) + sh_notfound (list->word->word); + + any_found += found; + } + + run_unwind_frame ("command_builtin"); + return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + } + #define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN) + /* We don't want this to be reparsed (consider command echo 'foo &'), so + just make a simple_command structure and call execute_command with it. */ command = make_bare_simple_command (); command->value.Simple->words = (WORD_LIST *)copy_word_list (list); command->value.Simple->redirects = (REDIRECT *)NULL; @@ -182,6 +185,8 @@ restore_path (var) } else unbind_variable ("PATH"); + + stupidly_hack_special_variables ("PATH"); } /* Return a value for PATH that is guaranteed to find all of the standard diff --git a/builtins/common.c b/builtins/common.c index 6ba641b..f02e99c 100644 --- a/builtins/common.c +++ b/builtins/common.c @@ -612,7 +612,7 @@ get_job_by_name (name, flags) match = STREQN (p->command, name, cl); } else if (flags & JM_SUBSTRING) - match = strindex (p->command, name) != (char *)0; + match = strcasestr (p->command, name) != (char *)0; else match = STREQN (p->command, name, wl); diff --git a/builtins/common.h b/builtins/common.h index ecf9d1b..efbb078 100644 --- a/builtins/common.h +++ b/builtins/common.h @@ -139,7 +139,11 @@ extern char **get_shopt_options __P((void)); extern int shopt_setopt __P((char *, int)); extern int shopt_listopt __P((char *, int)); -extern int set_login_shell __P((int)); +extern int set_login_shell __P((char *, int)); + +extern void set_bashopts __P((void)); +extern void parse_bashopts __P((char *)); +extern void initialize_bashopts __P((int)); /* Functions from type.def */ extern int describe_command __P((char *, int)); diff --git a/builtins/complete.def b/builtins/complete.def index d7e9aee..2267794 100644 --- a/builtins/complete.def +++ b/builtins/complete.def @@ -23,7 +23,7 @@ $PRODUCES complete.c $BUILTIN complete $DEPENDS_ON PROGRAMMABLE_COMPLETION $FUNCTION complete_builtin -$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...] +$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...] Specify how arguments are to be completed by Readline. For each NAME, specify how arguments are to be completed. If no options @@ -34,9 +34,14 @@ Options: -p print existing completion specifications in a reusable format -r remove a completion specification for each NAME, or, if no NAMEs are supplied, all completion specifications + -D apply the completions and actions as the default for commands + without any specific completion defined + -E apply the completions and actions to "empty" commands -- + completion attempted on a blank line When completion is attempted, the actions are applied in the order the -uppercase-letter options are listed above. +uppercase-letter options are listed above. The -D option takes +precedence over -E. Exit Status: Returns success unless an invalid option is supplied or an error occurs. @@ -72,6 +77,7 @@ $END struct _optflags { int pflag; int rflag; + int Dflag; int Eflag; }; @@ -187,7 +193,7 @@ build_actions (list, flagp, actp, optp) opt_given = 0; reset_internal_getopt (); - while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:E")) != -1) + while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DE")) != -1) { opt_given = 1; switch (opt) @@ -275,6 +281,18 @@ build_actions (list, flagp, actp, optp) case 'C': Carg = list_optarg; break; + case 'D': + if (flagp) + { + flagp->Dflag = 1; + break; + } + else + { + sh_invalidopt ("-D"); + builtin_usage (); + return (EX_USAGE); + } case 'E': if (flagp) { @@ -334,7 +352,7 @@ complete_builtin (list) return (EXECUTION_SUCCESS); } - opt_given = oflags.pflag = oflags.rflag = oflags.Eflag = 0; + opt_given = oflags.pflag = oflags.rflag = oflags.Dflag = oflags.Eflag = 0; acts = copts = (unsigned long)0L; Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL; @@ -349,7 +367,8 @@ complete_builtin (list) list = loptend; - wl = oflags.Eflag ? make_word_list (make_bare_word ("_EmptycmD_"), (WORD_LIST *)NULL) : 0; + wl = oflags.Dflag ? make_word_list (make_bare_word (DEFAULTCMD), (WORD_LIST *)NULL) + : (oflags.Eflag ? make_word_list (make_bare_word (EMPTYCMD), (WORD_LIST *)NULL) : 0); /* -p overrides everything else */ if (oflags.pflag || (list == 0 && opt_given == 0)) @@ -540,7 +559,12 @@ print_one_completion (cmd, cs) /* simple arguments that don't require quoting */ PRINTARG (cs->funcname, "-F"); - printf ("%s\n", cmd); + if (STREQ (cmd, EMPTYCMD)) + printf ("-E\n"); + else if (STREQ (cmd, DEFAULTCMD)) + printf ("-D\n"); + else + printf ("%s\n", cmd); return (0); } @@ -575,7 +599,12 @@ print_compopts (cmd, cs, full) PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs"); } - printf ("%s\n", cmd); + if (STREQ (cmd, EMPTYCMD)) + printf ("-E\n"); + else if (STREQ (cmd, DEFAULTCMD)) + printf ("-D\n"); + else + printf ("%s\n", cmd); } static int @@ -683,7 +712,7 @@ compgen_builtin (list) cs->filterpat = STRDUP (Xarg); rval = EXECUTION_FAILURE; - sl = gen_compspec_completions (cs, "compgen", word, 0, 0); + sl = gen_compspec_completions (cs, "compgen", word, 0, 0, 0); /* If the compspec wants the bash default completions, temporarily turn off programmable completion and call the bash completion code. */ @@ -720,7 +749,7 @@ compgen_builtin (list) $BUILTIN compopt $DEPENDS_ON PROGRAMMABLE_COMPLETION $FUNCTION compopt_builtin -$SHORT_DOC compopt [-o|+o option] [name ...] +$SHORT_DOC compopt [-o|+o option] [-DE] [name ...] Modify or display completion options. Modify the completion options for each NAME, or, if no NAMEs are supplied, @@ -729,6 +758,8 @@ the completion options for each NAME or the current completion specification. Options: -o option Set completion option OPTION for each NAME + -D Change options for the "default" command completion + -E Change options for the "empty" command completion Using `+o' instead of `-o' turns off the specified option. @@ -749,15 +780,15 @@ int compopt_builtin (list) WORD_LIST *list; { - int opts_on, opts_off, *opts, opt, oind, ret, Eflag; - WORD_LIST *l; + int opts_on, opts_off, *opts, opt, oind, ret, Dflag, Eflag; + WORD_LIST *l, *wl; COMPSPEC *cs; - opts_on = opts_off = 0; + opts_on = opts_off = Eflag = Dflag = 0; ret = EXECUTION_SUCCESS; reset_internal_getopt (); - while ((opt = internal_getopt (list, "+o:")) != EOF) + while ((opt = internal_getopt (list, "+o:DE")) != EOF) { opts = (list_opttype == '-') ? &opts_on : &opts_off; @@ -772,6 +803,12 @@ compopt_builtin (list) } *opts |= compopts[oind].optflag; break; + case 'D': + Dflag = 1; + break; + case 'E': + Eflag = 1; + break; default: builtin_usage (); return (EX_USAGE); @@ -779,7 +816,10 @@ compopt_builtin (list) } list = loptend; - if (list == 0) + wl = Dflag ? make_word_list (make_bare_word (DEFAULTCMD), (WORD_LIST *)NULL) + : (Eflag ? make_word_list (make_bare_word (EMPTYCMD), (WORD_LIST *)NULL) : 0); + + if (list == 0 && wl == 0) { if (RL_ISSTATE (RL_STATE_COMPLETING) == 0 || pcomp_curcs == 0) { @@ -805,7 +845,7 @@ compopt_builtin (list) return (ret); } - for (l = list; l; l = l->next) + for (l = wl ? wl : list; l; l = l->next) { cs = progcomp_search (l->word->word); if (cs == 0) diff --git a/builtins/declare.def b/builtins/declare.def index bd7d6b6..a0ce605 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -503,14 +503,19 @@ declare_internal (list, local_var) assign_array_var_from_string (var, value, aflags); else if (simple_array_assign && subscript_start) { - /* declare [-a] name[N]=value */ + /* declare [-aA] name[N]=value */ *subscript_start = '['; /* ] */ var = assign_array_element (name, value, 0); /* XXX - not aflags */ *subscript_start = '\0'; } else if (simple_array_assign) - /* let bind_array_variable take care of this. */ - bind_array_variable (name, 0, value, aflags); + { + /* let bind_{array,assoc}_variable take care of this. */ + if (assoc_p (var)) + bind_assoc_variable (var, name, "0", value, aflags); + else + bind_array_variable (name, 0, value, aflags); + } else #endif /* bind_variable_value duplicates the essential internals of diff --git a/builtins/evalfile.c b/builtins/evalfile.c index 55b5cb7..972d039 100644 --- a/builtins/evalfile.c +++ b/builtins/evalfile.c @@ -81,7 +81,7 @@ _evalfile (filename, flags) { volatile int old_interactive; procenv_t old_return_catch; - int return_val, fd, result, pflags; + int return_val, fd, result, pflags, i, nnull; ssize_t nr; /* return value from read(2) */ char *string; struct stat finfo; @@ -186,6 +186,26 @@ file_error_and_exit: return ((flags & FEVAL_BUILTIN) ? EX_BINARY_FILE : -1); } + i = strlen (string); + if (i < nr) + { + for (nnull = i = 0; i < nr; i++) + if (string[i] == '\0') + { + memmove (string+i, string+i+1, nr - i); + nr--; + /* Even if the `check binary' flag is not set, we want to avoid + sourcing files with more than 256 null characters -- that + probably indicates a binary file. */ + if ((flags & FEVAL_BUILTIN) && ++nnull > 256) + { + free (string); + (*errfunc) (_("%s: cannot execute binary file"), filename); + return ((flags & FEVAL_BUILTIN) ? EX_BINARY_FILE : -1); + } + } + } + if (flags & FEVAL_UNWINDPROT) { begin_unwind_frame ("_evalfile"); diff --git a/builtins/evalstring.c b/builtins/evalstring.c index a0fb3e2..40abe00 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -43,6 +43,7 @@ #include "../execute_cmd.h" #include "../redir.h" #include "../trap.h" +#include "../bashintl.h" #include <y.tab.h> @@ -51,6 +52,7 @@ #endif #include "common.h" +#include "builtext.h" #if !defined (errno) extern int errno; @@ -67,6 +69,7 @@ extern int loop_level; extern int executing_list; extern int comsub_ignore_return; extern int posixly_correct; +extern sh_builtin_func_t *this_shell_builtin; int parse_and_execute_level = 0; @@ -324,6 +327,19 @@ parse_and_execute (string, from_file, flags) { last_result = EXECUTION_FAILURE; + if (interactive_shell == 0 && this_shell_builtin && + (this_shell_builtin == source_builtin || this_shell_builtin == eval_builtin) && + last_command_exit_value == EX_BADSYNTAX && posixly_correct) + { +#if 0 /* XXX - for bash-4.2 */ + should_jump_to_top_level = 1; + code = ERREXIT; + last_command_exit_value = EX_BADUSAGE; +#else + internal_warning (_("syntax errors in . or eval will cause future versions of the shell to abort as Posix requires")); +#endif + } + /* Since we are shell compatible, syntax errors in a script abort the execution of the script. Right? */ break; diff --git a/builtins/help.def b/builtins/help.def index 004abe2..f857af9 100644 --- a/builtins/help.def +++ b/builtins/help.def @@ -23,7 +23,7 @@ $PRODUCES help.c $BUILTIN help $FUNCTION help_builtin $DEPENDS_ON HELP_BUILTIN -$SHORT_DOC help [-ds] [pattern ...] +$SHORT_DOC help [-dms] [pattern ...] Display information about builtin commands. Displays brief summaries of builtin commands. If PATTERN is @@ -350,6 +350,8 @@ A star (*) next to a name means that the command is disabled.\n\ width /= 2; if (width > sizeof (blurb)) width = sizeof (blurb); + if (width <= 3) + width = 40; height = (num_shell_builtins + 1) / 2; /* number of rows */ for (i = 0; i < height; i++) diff --git a/builtins/kill.def b/builtins/kill.def index 734da25..18c3667 100644 --- a/builtins/kill.def +++ b/builtins/kill.def @@ -121,6 +121,9 @@ kill_builtin (list) else sig = decode_signal (sigspec, dflags); list = list->next; +#if 0 + saw_signal++; /* XXX - for bash-4.2 */ +#endif } else { @@ -141,7 +144,7 @@ kill_builtin (list) /* If this is a signal specification then process it. We only process the first one seen; other arguments may signify process groups (e.g, -num == process group num). */ - else if ((*word == '-') && !saw_signal) + else if (*word == '-' && saw_signal == 0) { sigspec = word + 1; sig = decode_signal (sigspec, dflags); diff --git a/builtins/mapfile.def b/builtins/mapfile.def index e37cd22..0946de3 100644 --- a/builtins/mapfile.def +++ b/builtins/mapfile.def @@ -24,11 +24,11 @@ $PRODUCES mapfile.c $BUILTIN mapfile $FUNCTION mapfile_builtin $SHORT_DOC mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array] -Read lines from the standard input into an array variable. +Read lines from the standard input into an indexed array variable. -Read lines from the standard input into the array variable ARRAY, or from -file descriptor FD if the -u option is supplied. The variable MAPFILE is -the default ARRAY. +Read lines from the standard input into the indexed array variable ARRAY, or +from file descriptor FD if the -u option is supplied. The variable MAPFILE +is the default ARRAY. Options: -n count Copy at most COUNT lines. If COUNT is 0, all lines are copied. @@ -50,7 +50,8 @@ If not supplied with an explicit origin, mapfile will clear ARRAY before assigning to it. Exit Status: -Returns success unless an invalid option is given or ARRAY is readonly. +Returns success unless an invalid option is given or ARRAY is readonly or +not an indexed array. $END $BUILTIN readarray @@ -71,6 +72,7 @@ $END #endif #include "bashansi.h" +#include "bashintl.h" #include <stdio.h> #include <errno.h> @@ -110,10 +112,10 @@ run_callback(callback, current_index) execlen += 2; execstr = xmalloc (execlen); - flags = 0; + flags = SEVAL_NOHIST; #if 0 if (interactive) - flags |= SEVAL_NOHIST|SEVAL_INTERACT; + flags |= SEVAL_INTERACT; #endif snprintf (execstr, execlen, "%s %d", callback, current_index); return parse_and_execute(execstr, NULL, flags); @@ -153,11 +155,17 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n entry = find_or_make_array_variable (array_name, 1); if (entry == 0 || readonly_p (entry) || noassign_p (entry)) { - if (readonly_p (entry)) + if (entry && readonly_p (entry)) err_readonly (array_name); return (EXECUTION_FAILURE); } + else if (array_p (entry) == 0) + { + builtin_error (_("%s: not an indexed array"), array_name); + return (EXECUTION_FAILURE); + } + if (flags & MAPF_CLEARARRAY) array_flush (array_cell (entry)); @@ -281,7 +289,7 @@ mapfile_builtin (list) break; case 'c': code = legal_number (list_optarg, &intval); - if (code == 0 || intval < 0 || intval != (unsigned)intval) + if (code == 0 || intval <= 0 || intval != (unsigned)intval) { builtin_error (_("%s: invalid callback quantum"), list_optarg); return (EXECUTION_FAILURE); diff --git a/builtins/printf.def b/builtins/printf.def index 757fcea..e447633 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -135,7 +135,7 @@ extern int errno; { \ if (vflag) \ { \ - bind_variable (vname, vbuf, 0); \ + bind_printf_variable (vname, vbuf, 0); \ stupidly_hack_special_variables (vname); \ } \ if (conv_bufsize > 4096 ) \ @@ -156,6 +156,7 @@ extern int errno; fflush (stdout); \ if (ferror (stdout)) \ { \ + sh_wrerror (); \ clearerr (stdout); \ return (EXECUTION_FAILURE); \ } \ @@ -166,11 +167,11 @@ extern int errno; #define SKIP1 "#'-+ 0" #define LENMODS "hjlLtz" -#ifndef HAVE_ASPRINTF +#if !HAVE_ASPRINTF extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3))); #endif -#ifndef HAVE_VSNPRINTF +#if !HAVE_VSNPRINTF extern int vsnprintf __P((char *, size_t, const char *, ...)) __attribute__((__format__ (printf, 3, 4))); #endif @@ -186,6 +187,7 @@ static char *getstr __P((void)); static int getint __P((void)); static intmax_t getintmax __P((void)); static uintmax_t getuintmax __P((void)); +static SHELL_VAR *bind_printf_variable __P((char *, char *, int)); #if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN) typedef long double floatmax_t; @@ -234,7 +236,12 @@ printf_builtin (list) switch (ch) { case 'v': - if (legal_identifier (vname = list_optarg)) + vname = list_optarg; +#if defined (ARRAY_VARS) + if (legal_identifier (vname) || valid_array_reference (vname)) +#else + if (legal_identifier (vname)) +#endif { vflag = 1; vblen = 0; @@ -997,7 +1004,9 @@ getintmax () shall continue processing any remaining operands and shall write the value accumulated at the time the error was detected to standard output.'' Yecch. */ - ret = 0; +#if 0 + ret = 0; /* return partially-converted value from strtoimax */ +#endif conversion_error = 1; } else if (errno == ERANGE) @@ -1091,3 +1100,19 @@ asciicode () garglist = garglist->next; return (ch); } + +static SHELL_VAR * +bind_printf_variable (name, value, flags) + char *name; + char *value; + int flags; +{ +#if defined (ARRAY_VARS) + if (valid_array_reference (name) == 0) + return (bind_variable (name, value, flags)); + else + return (assign_array_element (name, value, flags)); +#else /* !ARRAY_VARS */ + return bind_variable (name, value, flags); +#endif /* !ARRAY_VARS */ +} diff --git a/builtins/read.def b/builtins/read.def index 8fc5647..1ef9142 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -22,7 +22,7 @@ $PRODUCES read.c $BUILTIN read $FUNCTION read_builtin -$SHORT_DOC read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-p prompt] [-t timeout] [-u fd] [name ...] +$SHORT_DOC read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] Read a line from the standard input and split it into fields. Reads a single line from the standard input, or from file descriptor FD @@ -42,7 +42,10 @@ Options: -e use Readline to obtain the line in an interactive shell -i text Use TEXT as the initial text for Readline -n nchars return after reading NCHARS characters rather than waiting - for a newline + for a newline, but honor a delimiter if fewer than NCHARS + characters are read before the delimiter + -N nchars return only after reading exactly NCHARS characters, unless + EOF is encountered or read times out, ignoring any delimiter -p prompt output the string PROMPT without a trailing newline before attempting to read -r do not allow backslashes to escape any characters @@ -155,7 +158,7 @@ read_builtin (list) register char *varname; int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2; int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul; - int raw, edit, nchars, silent, have_timeout, fd; + int raw, edit, nchars, silent, have_timeout, ignore_delim, fd; unsigned int tmsec, tmusec; long ival, uval; intmax_t intval; @@ -211,9 +214,10 @@ read_builtin (list) tmsec = tmusec = 0; /* no timeout */ nr = nchars = input_is_tty = input_is_pipe = unbuffered_read = have_timeout = 0; delim = '\n'; /* read until newline */ + ignore_delim = 0; reset_internal_getopt (); - while ((opt = internal_getopt (list, "ersa:d:i:n:p:t:u:")) != -1) + while ((opt = internal_getopt (list, "ersa:d:i:n:p:t:u:N:")) != -1) { switch (opt) { @@ -255,6 +259,9 @@ read_builtin (list) tmusec = uval; } break; + case 'N': + ignore_delim = 1; + delim = -1; case 'n': code = legal_number (list_optarg, &intval); if (code == 0 || intval < 0 || intval != (int)intval) @@ -299,10 +306,17 @@ read_builtin (list) return (input_avail (fd) ? EXECUTION_SUCCESS : EXECUTION_FAILURE); #endif + /* If we're asked to ignore the delimiter, make sure we do. */ + if (ignore_delim) + delim = -1; + /* IF IFS is unset, we use the default of " \t\n". */ ifs_chars = getifs (); if (ifs_chars == 0) /* XXX - shouldn't happen */ ifs_chars = ""; + /* If we want to read exactly NCHARS chars, don't split on IFS */ + if (ignore_delim) + ifs_chars = ""; for (skip_ctlesc = skip_ctlnul = 0, e = ifs_chars; *e; e++) skip_ctlesc |= *e == CTLESC, skip_ctlnul |= *e == CTLNUL; @@ -601,15 +615,14 @@ add_char: if (unbuffered_read == 0) zsyncfd (fd); + interrupt_immediately--; + terminate_immediately--; discard_unwind_frame ("read_builtin"); retval = eof ? EXECUTION_FAILURE : EXECUTION_SUCCESS; assign_vars: - interrupt_immediately--; - terminate_immediately--; - #if defined (ARRAY_VARS) /* If -a was given, take the string read, break it into a list of words, an assign them to `arrayname' in turn. */ diff --git a/builtins/shopt.def b/builtins/shopt.def index d30a869..68c7245 100644 --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -112,19 +112,20 @@ extern int debugging_mode; static void shopt_error __P((char *)); -static int set_shellopts_after_change __P((int)); - -static int set_compatibility_level __P((int)); +static int set_shellopts_after_change __P((char *, int)); +static int shopt_enable_hostname_completion __P((char *, int)); +static int set_compatibility_level __P((char *, int)); #if defined (RESTRICTED_SHELL) -static int set_restricted_shell __P((int)); +static int set_restricted_shell __P((char *, int)); #endif static int shopt_login_shell; static int shopt_compat31; static int shopt_compat32; +static int shopt_compat40; -typedef int shopt_set_func_t __P((int)); +typedef int shopt_set_func_t __P((char *, int)); static struct { char *name; @@ -144,6 +145,7 @@ static struct { #endif { "compat31", &shopt_compat31, set_compatibility_level }, { "compat32", &shopt_compat32, set_compatibility_level }, + { "compat40", &shopt_compat40, set_compatibility_level }, #if defined (READLINE) { "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL }, #endif @@ -169,7 +171,7 @@ static struct { #if defined (READLINE) { "histreedit", &history_reediting, (shopt_set_func_t *)NULL }, { "histverify", &hist_verify, (shopt_set_func_t *)NULL }, - { "hostcomplete", &perform_hostname_completion, enable_hostname_completion }, + { "hostcomplete", &perform_hostname_completion, shopt_enable_hostname_completion }, #endif { "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL }, { "interactive_comments", &interactive_comments, set_shellopts_after_change }, @@ -197,6 +199,10 @@ static struct { { (char *)0, (int *)0, (shopt_set_func_t *)NULL } }; +#define N_SHOPT_OPTIONS (sizeof (shopt_vars) / sizeof (shopt_vars[0])) + +#define GET_SHOPT_OPTION_VALUE(i) (*shopt_vars[i].value) + static const char * const on = "on"; static const char * const off = "off"; @@ -340,9 +346,11 @@ toggle_shopts (mode, list, quiet) { *shopt_vars[ind].value = mode; /* 1 for set, 0 for unset */ if (shopt_vars[ind].set_func) - (*shopt_vars[ind].set_func) (mode); + (*shopt_vars[ind].set_func) (shopt_vars[ind].name, mode); } } + + set_bashopts (); return (rval); } @@ -479,7 +487,8 @@ set_shopt_o_options (mode, list, quiet) /* If we set or unset interactive_comments with shopt, make sure the change is reflected in $SHELLOPTS. */ static int -set_shellopts_after_change (mode) +set_shellopts_after_change (option_name, mode) + char *option_name; int mode; { set_shellopts (); @@ -487,14 +496,36 @@ set_shellopts_after_change (mode) } static int -set_compatibility_level (mode) +shopt_enable_hostname_completion (option_name, mode) + char *option_name; + int mode; +{ + return (enable_hostname_completion (mode)); +} + +static int +set_compatibility_level (option_name, mode) + char *option_name; int mode; { /* Need to change logic here as we add more compatibility levels */ + + /* First, check option_name so we can turn off other compat options when + one is set. */ + if (mode && option_name[6] == '3' && option_name[7] == '1') + shopt_compat32 = shopt_compat40 = 0; + else if (mode && option_name[6] == '3' && option_name[7] == '2') + shopt_compat31 = shopt_compat40 = 0; + else if (mode && option_name[6] == '4' && option_name[7] == '0') + shopt_compat31 = shopt_compat32 = 0; + + /* Then set shell_compatibility_level based on what remains */ if (shopt_compat31) shell_compatibility_level = 31; else if (shopt_compat32) shell_compatibility_level = 32; + else if (shopt_compat40) + shell_compatibility_level = 40; else shell_compatibility_level = DEFAULT_COMPAT_LEVEL; return 0; @@ -504,7 +535,8 @@ set_compatibility_level (mode) /* Don't allow the value of restricted_shell to be modified. */ static int -set_restricted_shell (mode) +set_restricted_shell (option_name, mode) + char *option_name; int mode; { static int save_restricted = -1; @@ -519,7 +551,8 @@ set_restricted_shell (mode) /* Not static so shell.c can call it to initialize shopt_login_shell */ int -set_login_shell (mode) +set_login_shell (option_name, mode) + char *option_name; int mode; { shopt_login_shell = login_shell != 0; @@ -579,3 +612,104 @@ shopt_listopt (name, reusable) print_shopt (name, *shopt_vars[i].value, reusable ? PFLAG : 0); return (sh_chkwrite (EXECUTION_SUCCESS)); } + +void +set_bashopts () +{ + char *value; + char tflag[N_SHOPT_OPTIONS]; + int vsize, i, vptr, *ip, exported; + SHELL_VAR *v; + + for (vsize = i = 0; shopt_vars[i].name; i++) + { + tflag[i] = 0; + if (GET_SHOPT_OPTION_VALUE (i)) + { + vsize += strlen (shopt_vars[i].name) + 1; + tflag[i] = 1; + } + } + + value = (char *)xmalloc (vsize + 1); + + for (i = vptr = 0; shopt_vars[i].name; i++) + { + if (tflag[i]) + { + strcpy (value + vptr, shopt_vars[i].name); + vptr += strlen (shopt_vars[i].name); + value[vptr++] = ':'; + } + } + + if (vptr) + vptr--; /* cut off trailing colon */ + value[vptr] = '\0'; + + v = find_variable ("BASHOPTS"); + + /* Turn off the read-only attribute so we can bind the new value, and + note whether or not the variable was exported. */ + if (v) + { + VUNSETATTR (v, att_readonly); + exported = exported_p (v); + } + else + exported = 0; + + v = bind_variable ("BASHOPTS", value, 0); + + /* Turn the read-only attribute back on, and turn off the export attribute + if it was set implicitly by mark_modified_vars and SHELLOPTS was not + exported before we bound the new value. */ + VSETATTR (v, att_readonly); + if (mark_modified_vars && exported == 0 && exported_p (v)) + VUNSETATTR (v, att_exported); + + free (value); +} + +void +parse_bashopts (value) + char *value; +{ + char *vname; + int vptr, ind; + + vptr = 0; + while (vname = extract_colon_unit (value, &vptr)) + { + ind = find_shopt (vname); + if (ind >= 0) + *shopt_vars[ind].value = 1; + free (vname); + } +} + +void +initialize_bashopts (no_bashopts) + int no_bashopts; +{ + char *temp; + SHELL_VAR *var; + + if (no_bashopts == 0) + { + var = find_variable ("BASHOPTS"); + /* set up any shell options we may have inherited. */ + if (var && imported_p (var)) + { + temp = (array_p (var) || assoc_p (var)) ? (char *)NULL : savestring (value_cell (var)); + if (temp) + { + parse_bashopts (temp); + free (temp); + } + } + } + + /* Set up the $BASHOPTS variable. */ + set_bashopts (); +} |