aboutsummaryrefslogtreecommitdiffstats
path: root/builtins
diff options
context:
space:
mode:
Diffstat (limited to 'builtins')
-rw-r--r--builtins/Makefile.in90
-rw-r--r--builtins/alias.def2
-rw-r--r--builtins/bind.def4
-rw-r--r--builtins/break.def7
-rw-r--r--builtins/cd.def470
-rw-r--r--builtins/common.c229
-rw-r--r--builtins/common.h8
-rw-r--r--builtins/complete.def100
-rw-r--r--builtins/declare.def10
-rw-r--r--builtins/enable.def8
-rw-r--r--builtins/evalfile.c11
-rw-r--r--builtins/evalstring.c8
-rw-r--r--builtins/fc.def15
-rw-r--r--builtins/getopts.def4
-rw-r--r--builtins/hash.def16
-rw-r--r--builtins/history.def6
-rw-r--r--builtins/mkbuiltins.c14
-rw-r--r--builtins/printf.def64
-rw-r--r--builtins/pushd.def38
-rw-r--r--builtins/read.def48
-rw-r--r--builtins/set.def48
-rw-r--r--builtins/setattr.def24
-rw-r--r--builtins/shopt.def3
-rw-r--r--builtins/source.def21
-rw-r--r--builtins/trap.def11
-rw-r--r--builtins/type.def14
-rw-r--r--builtins/ulimit.def10
-rw-r--r--builtins/umask.def2
-rw-r--r--builtins/wait.def12
29 files changed, 529 insertions, 768 deletions
diff --git a/builtins/Makefile.in b/builtins/Makefile.in
index 652fb08..688e55d 100644
--- a/builtins/Makefile.in
+++ b/builtins/Makefile.in
@@ -213,14 +213,14 @@ complete.o: complete.def
# C files
bashgetopt.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
-bashgetopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h
+bashgetopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h
bashgetopt.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
bashgetopt.o: $(topdir)/variables.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
bashgetopt.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
bashgetopt.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
bashgetopt.o: $(topdir)/pathnames.h $(topdir)/externs.h $(srcdir)/common.h
common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
-common.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.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)/general.h $(BASHINCDIR)/stdc.h $(BASHINCDIR)/memalloc.h
common.o: $(topdir)/variables.h $(topdir)/input.h
@@ -231,7 +231,7 @@ common.o: $(topdir)/subst.h $(topdir)/execute_cmd.h $(topdir)/error.h
common.o: $(topdir)/externs.h $(topdir)/pathnames.h ./builtext.h
evalfile.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h ${BASHINCDIR}/filecntl.h
evalfile.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
-evalfile.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h
+evalfile.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h
evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
evalfile.o: $(topdir)/variables.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
@@ -241,7 +241,7 @@ 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
evalstring.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
-evalstring.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
+evalstring.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
evalstring.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/siglist.h
evalstring.o: $(BASHINCDIR)/memalloc.h $(topdir)/variables.h $(topdir)/input.h
evalstring.o: $(topdir)/quit.h $(topdir)/unwind_prot.h
@@ -251,7 +251,7 @@ 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
getopt.o: ../config.h $(BASHINCDIR)/memalloc.h
-getopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(topdir)/command.h
+getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/command.h
getopt.o: $(topdir)/general.h $(topdir)/error.h $(topdir)/variables.h
getopt.o: $(topdir)/quit.h $(BASHINCDIR)/maxpath.h $(topdir)/unwind_prot.h
getopt.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
@@ -266,61 +266,61 @@ alias.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
alias.o: $(topdir)/error.h $(topdir)/general.h $(BASHINCDIR)/maxpath.h
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)/unwind_prot.h $(topdir)/variables.h
+alias.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.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 $(BASHINCDIR)/maxpath.h $(topdir)/bashline.h
-bind.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
+bind.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
break.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
break.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+break.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
builtin.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
builtin.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
cd.o: $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+cd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
command.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
command.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+command.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
declare.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
declare.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+declare.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
echo.o: $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+echo.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
echo.o: $(BASHINCDIR)/maxpath.h
enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
enable.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+enable.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
enable.o: $(BASHINCDIR)/maxpath.h
enable.o: $(topdir)/pcomplete.h
eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
eval.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+eval.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
eval.o: $(BASHINCDIR)/maxpath.h
exec.o: $(topdir)/bashtypes.h
exec.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exec.o: $(topdir)/error.h $(topdir)/general.h
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)/unwind_prot.h $(topdir)/variables.h
+exec.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(BASHINCDIR)/maxpath.h
exec.o: $(topdir)/findcmd.h
exit.o: $(topdir)/bashtypes.h
@@ -328,7 +328,7 @@ exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exit.o: $(topdir)/error.h $(topdir)/general.h
exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exit.o: $(topdir)/subst.h $(topdir)/externs.h
-exit.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
+exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h
fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h
@@ -336,7 +336,7 @@ fc.o: $(topdir)/bashhist.h
fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
fc.o: $(topdir)/general.h $(BASHINCDIR)/maxpath.h
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.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
fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
fg_bg.o: $(topdir)/bashtypes.h
@@ -344,147 +344,147 @@ fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
fg_bg.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+fg_bg.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
getopts.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+getopts.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.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
-hash.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
+hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
hash.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
help.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
help.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
history.o: $(topdir)/bashtypes.h
history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
history.o: $(topdir)/error.h $(topdir)/general.h
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)/unwind_prot.h
+history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
history.o: $(topdir)/variables.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h
inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
inlib.o: $(topdir)/error.h $(topdir)/general.h
-inlib.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
+inlib.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.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
jobs.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
jobs.o: $(topdir)/general.h $(topdir)/quit.h $(srcdir)/bashgetopt.h
jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h
jobs.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
-jobs.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
+jobs.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
kill.o: $(topdir)/general.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)/trap.h $(topdir)/unwind_prot.h
+kill.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/trap.h $(topdir)/unwind_prot.h
kill.o: $(topdir)/variables.h $(BASHINCDIR)/maxpath.h
let.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
let.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+let.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h
printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h
printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
-printf.o: $(topdir)/pathnames.h $(topdir)/shell.h $(topdir)/unwind_prot.h
+printf.o: $(topdir)/pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
printf.o: $(topdir)/variables.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h
pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
pushd.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+pushd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h
read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
read.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+read.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
read.o: $(BASHINCDIR)/shtty.h
return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
return.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
set.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
set.o: $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+set.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h
setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
setattr.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shift.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+shift.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
source.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
source.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
suspend.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+suspend.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
test.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
test.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+test.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
test.o: $(topdir)/test.h
times.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
times.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+times.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
times.o: $(BASHINCDIR)/posixtime.h
trap.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
trap.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+trap.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
trap.o: $(topdir)/findcmd.h
type.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
type.o: $(topdir)/error.h $(topdir)/general.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)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
+type.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
ulimit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
ulimit.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+ulimit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
umask.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
umask.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+umask.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
wait.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
wait.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+wait.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shopt.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shopt.o: $(topdir)/error.h $(topdir)/general.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)/unwind_prot.h $(topdir)/variables.h
+shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h
complete.o: ../config.h
-complete.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.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
complete.o: ${topdir}/builtins.h
diff --git a/builtins/alias.def b/builtins/alias.def
index 50e7ffc..5f7bfe7 100644
--- a/builtins/alias.def
+++ b/builtins/alias.def
@@ -198,7 +198,7 @@ print_alias (alias)
{
char *value;
- value = single_quote (alias->value);
+ value = sh_single_quote (alias->value);
printf ("alias %s=%s\n", alias->name, value);
free (value);
diff --git a/builtins/bind.def b/builtins/bind.def
index 5adfe38..ce996a0 100644
--- a/builtins/bind.def
+++ b/builtins/bind.def
@@ -189,10 +189,10 @@ bind_builtin (list)
{
kmap = rl_get_keymap_by_name (map_name);
if (!kmap)
- {
+ {
builtin_error ("`%s': invalid keymap name", map_name);
BIND_RETURN (EXECUTION_FAILURE);
- }
+ }
}
if (kmap)
diff --git a/builtins/break.def b/builtins/break.def
index d996536..778d1f8 100644
--- a/builtins/break.def
+++ b/builtins/break.def
@@ -40,6 +40,7 @@ $END
#include "common.h"
extern char *this_command_name;
+extern int posixly_correct;
static int check_loop_level ();
@@ -61,7 +62,7 @@ break_builtin (list)
int newbreak;
if (check_loop_level () == 0)
- return (EXECUTION_FAILURE);
+ return (EXECUTION_SUCCESS);
newbreak = get_numeric_arg (list, 1);
@@ -96,7 +97,7 @@ continue_builtin (list)
int newcont;
if (check_loop_level () == 0)
- return (EXECUTION_FAILURE);
+ return (EXECUTION_SUCCESS);
newcont = get_numeric_arg (list, 1);
@@ -121,7 +122,7 @@ static int
check_loop_level ()
{
#if defined (BREAK_COMPLAINS)
- if (loop_level == 0)
+ if (loop_level == 0 && posixly_correct == 0)
builtin_error ("only meaningful in a `for', `while', or `until' loop");
#endif /* BREAK_COMPLAINS */
diff --git a/builtins/cd.def b/builtins/cd.def
index 4761623..57306a5 100644
--- a/builtins/cd.def
+++ b/builtins/cd.def
@@ -60,7 +60,6 @@ extern char *bash_getcwd_errstr;
static int change_to_directory ();
static char *cdspell ();
-static int spname (), mindist (), spdist ();
/* Change this to 1 to get cd spelling correction by default. */
int cdspelling = 0;
@@ -91,15 +90,10 @@ bindpwd (no_symlinks)
int old_symlinks, old_anm;
SHELL_VAR *tvar;
- if (no_symlinks)
- {
- old_symlinks = no_symbolic_links;
- no_symbolic_links = 1;
- dirname = get_working_directory ("cd");
- no_symbolic_links = old_symlinks;
- }
- else
- dirname = get_working_directory ("cd");
+#define tcwd the_current_working_directory
+ dirname = tcwd ? (no_symlinks ? sh_physpath (tcwd, 0) : tcwd)
+ : get_working_directory ("cd");
+#undef tcwd
old_anm = array_needs_making;
pwdvar = get_string_value ("PWD");
@@ -118,10 +112,16 @@ bindpwd (no_symlinks)
array_needs_making = 0;
}
- FREE (dirname);
+ if (dirname && dirname != the_current_working_directory)
+ free (dirname);
return (EXECUTION_SUCCESS);
}
+#define LCD_DOVARS 0x001
+#define LCD_DOSPELL 0x002
+#define LCD_PRINTPATH 0x004
+#define LCD_FREEDIRNAME 0x010
+
/* This builtin is ultimately the way that all user-visible commands should
change the current working directory. It is called by cd_to_string (),
so the programming interface is simple, and it handles errors and
@@ -131,8 +131,7 @@ cd_builtin (list)
WORD_LIST *list;
{
char *dirname, *cdpath, *path, *temp;
- int path_index, no_symlinks, opt;
- struct stat sb;
+ int path_index, no_symlinks, opt, lflag;
#if defined (RESTRICTED_SHELL)
if (restricted)
@@ -161,6 +160,9 @@ cd_builtin (list)
}
list = loptend;
+ lflag = (cdable_vars ? LCD_DOVARS : 0) |
+ ((interactive && cdspelling) ? LCD_DOSPELL : 0);
+
if (list == 0)
{
/* `cd' without arguments is equivalent to `cd $HOME' */
@@ -171,118 +173,106 @@ cd_builtin (list)
builtin_error ("HOME not set");
return (EXECUTION_FAILURE);
}
-
- if (change_to_directory (dirname, no_symlinks) == 0)
- {
- builtin_error ("%s: %s", dirname, strerror (errno));
- return (EXECUTION_FAILURE);
- }
+ lflag = 0;
}
else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
{
/* This is `cd -', equivalent to `cd $OLDPWD' */
dirname = get_string_value ("OLDPWD");
- if (dirname == 0 || change_to_directory (dirname, no_symlinks) == 0)
+ if (dirname == 0)
{
- if (dirname == 0)
- builtin_error ("OLDPWD not set");
- else
- builtin_error ("%s: %s", dirname, strerror (errno));
+ builtin_error ("OLDPWD not set");
return (EXECUTION_FAILURE);
}
- if (interactive)
- printf ("%s\n", dirname);
+ lflag = interactive ? LCD_PRINTPATH : 0;
}
- else
+ else if (absolute_pathname (list->word->word))
+ dirname = list->word->word;
+ else if (cdpath = get_string_value ("CDPATH"))
{
dirname = list->word->word;
- if (absolute_pathname (dirname) == 0 && (cdpath = get_string_value ("CDPATH")))
+ /* Find directory in $CDPATH. */
+ path_index = 0;
+ while (path = extract_colon_unit (cdpath, &path_index))
{
- /* Find directory in $CDPATH. */
- path_index = 0;
- while (path = extract_colon_unit (cdpath, &path_index))
- {
- /* OPT is 1 if the path element is non-empty */
- opt = path[0] != '\0';
- temp = sh_makepath (path, dirname, MP_DOTILDE);
- free (path);
-
- if (stat (temp, &sb) < 0 || S_ISDIR (sb.st_mode) == 0)
- {
- free (temp);
- continue;
- }
-
- if (change_to_directory (temp, no_symlinks))
- {
- /* POSIX.2 says that if a nonempty directory from CDPATH
- is used to find the directory to change to, the new
- directory name is echoed to stdout, whether or not
- the shell is interactive. */
- if (opt)
- printf ("%s\n", no_symlinks ? temp : the_current_working_directory);
-
- free (temp);
- /* Posix.2 says that after using CDPATH, the resultant
- value of $PWD will not contain symlinks. */
- return (bindpwd (posixly_correct || no_symlinks));
- }
- else
- free (temp);
- }
+ /* OPT is 1 if the path element is non-empty */
+ opt = path[0] != '\0';
+ temp = sh_makepath (path, dirname, MP_DOTILDE);
+ free (path);
- /* POSIX.2 says that if `.' does not appear in $CDPATH, we don't
- try the current directory, so we just punt now with an error
- message if POSIXLY_CORRECT is non-zero. The check for cdpath[0]
- is so we don't mistakenly treat a CDPATH value of "" as not
- specifying the current directory. */
- if (posixly_correct && cdpath[0])
+ if (change_to_directory (temp, no_symlinks))
{
- builtin_error ("%s: %s", dirname, strerror (ENOENT));
- return (EXECUTION_FAILURE);
+ /* POSIX.2 says that if a nonempty directory from CDPATH
+ is used to find the directory to change to, the new
+ directory name is echoed to stdout, whether or not
+ the shell is interactive. */
+ if (opt)
+ printf ("%s\n", no_symlinks ? temp : the_current_working_directory);
+
+ free (temp);
+ /* Posix.2 says that after using CDPATH, the resultant
+ value of $PWD will not contain `.' or `..'. */
+ return (bindpwd (posixly_correct || no_symlinks));
}
+ else
+ free (temp);
}
- if (change_to_directory (dirname, no_symlinks))
- return (bindpwd (no_symlinks));
-
- /* If the user requests it, then perhaps this is the name of
- a shell variable, whose value contains the directory to
- change to. If that is the case, then change to that
- directory. */
- if (cdable_vars)
+ /* POSIX.2 says that if `.' does not appear in $CDPATH, we don't
+ try the current directory, so we just punt now with an error
+ message if POSIXLY_CORRECT is non-zero. The check for cdpath[0]
+ is so we don't mistakenly treat a CDPATH value of "" as not
+ specifying the current directory. */
+ if (posixly_correct && cdpath[0])
{
- temp = get_string_value (dirname);
- if (temp && change_to_directory (temp, no_symlinks))
- {
- printf ("%s\n", temp);
- return (bindpwd (no_symlinks));
- }
+ builtin_error ("%s: %s", dirname, strerror (ENOENT));
+ return (EXECUTION_FAILURE);
}
+ }
+ else
+ dirname = list->word->word;
+
+ /* When we get here, DIRNAME is the directory to change to. If we
+ chdir successfully, just return. */
+ if (change_to_directory (dirname, no_symlinks))
+ {
+ if (lflag & LCD_PRINTPATH)
+ printf ("%s\n", dirname);
+ return (bindpwd (no_symlinks));
+ }
- /* If the user requests it, try to find a directory name similar in
- spelling to the one requested, in case the user made a simple
- typo. This is similar to the UNIX 8th and 9th Edition shells. */
- if (interactive && cdspelling)
+ /* If the user requests it, then perhaps this is the name of
+ a shell variable, whose value contains the directory to
+ change to. */
+ if (lflag & LCD_DOVARS)
+ {
+ temp = get_string_value (dirname);
+ if (temp && change_to_directory (temp, no_symlinks))
{
- temp = cdspell (dirname);
- if (temp && change_to_directory (temp, no_symlinks))
- {
- printf ("%s\n", temp);
- free (temp);
- return (bindpwd (no_symlinks));
- }
- else
- FREE (temp);
+ printf ("%s\n", temp);
+ return (bindpwd (no_symlinks));
}
+ }
- builtin_error ("%s: %s", dirname, strerror (errno));
- return (EXECUTION_FAILURE);
+ /* If the user requests it, try to find a directory name similar in
+ spelling to the one requested, in case the user made a simple
+ typo. This is similar to the UNIX 8th and 9th Edition shells. */
+ if (lflag & LCD_DOSPELL)
+ {
+ temp = cdspell (dirname);
+ if (temp && change_to_directory (temp, no_symlinks))
+ {
+ printf ("%s\n", temp);
+ return (bindpwd (no_symlinks));
+ }
+ else
+ FREE (temp);
}
- return (bindpwd (no_symlinks));
+ builtin_error ("%s: %s", dirname, strerror (errno));
+ return (EXECUTION_FAILURE);
}
$BUILTIN pwd
@@ -302,7 +292,7 @@ int
pwd_builtin (list)
WORD_LIST *list;
{
- char *directory, *buffer;
+ char *directory;
int opt;
verbatim_pwd = no_symbolic_links;
@@ -324,25 +314,23 @@ pwd_builtin (list)
}
list = loptend;
- if (verbatim_pwd)
- {
- buffer = xmalloc (PATH_MAX);
- directory = getcwd (buffer, PATH_MAX);
+#define tcwd the_current_working_directory
- if (directory == 0)
- {
- builtin_error ("%s: %s", bash_getcwd_errstr, strerror (errno));
- free (buffer);
- }
- }
- else
- directory = get_working_directory ("pwd");
+ directory = tcwd ? (verbatim_pwd ? sh_physpath (tcwd, 0) : tcwd)
+ : get_working_directory ("pwd");
+#undef tcwd
if (directory)
{
printf ("%s\n", directory);
+ if (directory != the_current_working_directory)
+ free (directory);
fflush (stdout);
- free (directory);
+ if (ferror (stdout))
+ {
+ builtin_error ("write error: %s", strerror (errno));
+ return (EXECUTION_FAILURE);
+ }
return (EXECUTION_SUCCESS);
}
else
@@ -350,83 +338,79 @@ pwd_builtin (list)
}
/* Do the work of changing to the directory NEWDIR. Handle symbolic
- link following, etc. */
+ link following, etc. This function *must* return with
+ the_current_working_directory either set to NULL (in which case
+ getcwd() will eventually be called), or set to a string corresponding
+ to the working directory. Return 1 on success, 0 on failure. */
static int
change_to_directory (newdir, nolinks)
char *newdir;
int nolinks;
{
- char *t;
-
- if (nolinks == 0)
- {
- int chdir_return = 0;
- char *tdir = (char *)NULL;
+ char *t, *tdir;
+ int err;
- if (the_current_working_directory == 0)
- {
- t = get_working_directory ("cd_links");
- FREE (t);
- }
+ tdir = (char *)NULL;
- if (the_current_working_directory)
- t = make_absolute (newdir, the_current_working_directory);
- else
- t = savestring (newdir);
+ if (the_current_working_directory == 0)
+ {
+ t = get_working_directory ("chdir");
+ FREE (t);
+ }
- /* TDIR is the canonicalized absolute pathname of the NEWDIR. */
- tdir = canonicalize_pathname (t);
+ t = make_absolute (newdir, the_current_working_directory);
- /* Use the canonicalized version of NEWDIR, or, if canonicalization
- failed, use the non-canonical form. */
- if (tdir && *tdir)
- free (t);
- else
- {
- FREE (tdir);
- tdir = t;
- }
+ /* TDIR is either the canonicalized absolute pathname of NEWDIR
+ (nolinks == 0) or the absolute physical pathname of NEWDIR
+ (nolinks != 0). */
+ tdir = nolinks ? sh_physpath (t, 0)
+ : sh_canonpath (t, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
- if (chdir (tdir) < 0)
- {
- int err;
+ /* Use the canonicalized version of NEWDIR, or, if canonicalization
+ failed, use the non-canonical form. */
+ if (tdir && *tdir)
+ free (t);
+ else
+ {
+ FREE (tdir);
+ tdir = t;
+ }
- chdir_return = 0;
- free (tdir);
+ /* If the chdir succeeds, update the_current_working_directory. */
+ if (chdir (nolinks ? newdir : tdir) == 0)
+ {
+ FREE (the_current_working_directory);
+ the_current_working_directory = tdir;
+
+ return (1);
+ }
- err = errno;
+ /* We failed to change to the appropriate directory name. If we tried
+ what the user passed (nolinks != 0), punt now. */
+ if (nolinks)
+ return (0);
- /* We failed changing to the canonicalized directory name. Try
- what the user passed verbatim. If we succeed, reinitialize
- the_current_working_directory. */
- if (chdir (newdir) == 0)
- {
- chdir_return = 1;
- if (the_current_working_directory)
- {
- free (the_current_working_directory);
- the_current_working_directory = (char *)NULL;
- }
-
- tdir = get_working_directory ("cd");
- FREE (tdir);
- }
- else
- errno = err;
- }
- else
- {
- chdir_return = 1;
+ err = errno;
+ free (tdir);
- FREE (the_current_working_directory);
- the_current_working_directory = tdir;
- }
+ /* We're not in physical mode (nolinks == 0), but we failed to change to
+ the canonicalized directory name (TDIR). Try what the user passed
+ verbatim. If we succeed, reinitialize the_current_working_directory. */
+ if (chdir (newdir) == 0)
+ {
+ FREE (the_current_working_directory);
+ the_current_working_directory = (char *)NULL;
+ tdir = get_working_directory ("cd");
+ FREE (tdir);
- return (chdir_return);
+ return (1);
}
else
- return (chdir (newdir) == 0);
+ {
+ errno = err;
+ return (0);
+ }
}
/* Code for cd spelling correction. Original patch submitted by
@@ -453,147 +437,3 @@ cdspell (dirname)
return guess;
}
}
-
-/*
- * `spname' and its helpers are inspired by the code in "The UNIX
- * Programming Environment, Kernighan & Pike, Prentice-Hall 1984",
- * pages 209 - 213.
- */
-
-/*
- * `spname' -- return a correctly spelled filename
- *
- * int spname(char * oldname, char * newname)
- * Returns: -1 if no reasonable match found
- * 0 if exact match found
- * 1 if corrected
- * Stores corrected name in `newname'.
- */
-static int
-spname(oldname, newname)
- char *oldname;
- char *newname;
-{
- char *op, *np, *p;
- char guess[PATH_MAX + 1], best[PATH_MAX + 1];
-
- op = oldname;
- np = newname;
- for (;;)
- {
- while (*op == '/') /* Skip slashes */
- *np++ = *op++;
- *np = '\0';
-
- if (*op == '\0') /* Exact or corrected */
- {
- /* `.' is rarely the right thing. */
- if (oldname[1] == '\0' && newname[1] == '\0' &&
- oldname[0] != '.' && newname[0] == '.')
- return -1;
- return strcmp(oldname, newname) != 0;
- }
-
- /* Copy next component into guess */
- for (p = guess; *op != '/' && *op != '\0'; op++)
- if (p < guess + PATH_MAX)
- *p++ = *op;
- *p = '\0';
-
- if (mindist(newname, guess, best) >= 3)
- return -1; /* Hopeless */
-
- /*
- * Add to end of newname
- */
- for (p = best; *np = *p++; np++)
- ;
- }
-}
-
-/*
- * Search directory for a guess
- */
-static int
-mindist(dir, guess, best)
- char *dir;
- char *guess;
- char *best;
-{
- DIR *fd;
- struct dirent *dp;
- int dist, x;
-
- dist = 3; /* Worst distance */
- if (*dir == '\0')
- dir = ".";
-
- if ((fd = opendir(dir)) == NULL)
- return dist;
-
- while ((dp = readdir(fd)) != NULL)
- {
- /*
- * Look for a better guess. If the new guess is as
- * good as the current one, we take it. This way,
- * any single character match will be a better match
- * than ".".
- */
- x = spdist(dp->d_name, guess);
- if (x <= dist && x != 3)
- {
- strcpy(best, dp->d_name);
- dist = x;
- if (dist == 0) /* Exact match */
- break;
- }
- }
- (void)closedir(fd);
-
- /* Don't return `.' */
- if (best[0] == '.' && best[1] == '\0')
- dist = 3;
- return dist;
-}
-
-/*
- * `spdist' -- return the "distance" between two names.
- *
- * int spname(char * oldname, char * newname)
- * Returns: 0 if strings are identical
- * 1 if two characters are transposed
- * 2 if one character is wrong, added or deleted
- * 3 otherwise
- */
-static int
-spdist(cur, new)
- char *cur, *new;
-{
- while (*cur == *new)
- {
- if (*cur == '\0')
- return 0; /* Exact match */
- cur++;
- new++;
- }
-
- if (*cur)
- {
- if (*new)
- {
- if (cur[1] && new[1] && cur[0] == new[1] && cur[1] == new[0] && strcmp (cur + 2, new + 2) == 0)
- return 1; /* Transposition */
-
- if (strcmp (cur + 1, new + 1) == 0)
- return 2; /* One character mismatch */
- }
-
- if (strcmp(&cur[1], &new[0]) == 0)
- return 2; /* Extra character */
- }
-
- if (*new && strcmp(cur, new + 1) == 0)
- return 2; /* Missing character */
-
- return 3;
-}
diff --git a/builtins/common.c b/builtins/common.c
index a92e4d9..e3e9cc3 100644
--- a/builtins/common.c
+++ b/builtins/common.c
@@ -327,7 +327,7 @@ set_dollar_vars_changed ()
/* **************************************************************** */
/* */
-/* Validating numeric input and arguments */
+/* Validating numeric input and arguments */
/* */
/* **************************************************************** */
@@ -371,10 +371,10 @@ read_octal (string)
int result, digits;
result = digits = 0;
- while (*string && *string >= '0' && *string < '8')
+ while (*string && ISOCTAL (*string))
{
digits++;
- result = (result * 8) + *string++ - '0';
+ result = (result * 8) + (*string++ - '0');
}
if (!digits || result > 0777 || *string)
@@ -416,10 +416,7 @@ get_working_directory (for_whom)
{
fprintf (stderr, "%s: could not get current directory: %s: %s\n",
(for_whom && *for_whom) ? for_whom : get_name_for_error (),
- the_current_working_directory[0]
- ? the_current_working_directory
- : bash_getcwd_errstr,
- strerror (errno));
+ bash_getcwd_errstr, strerror (errno));
free (the_current_working_directory);
the_current_working_directory = (char *)NULL;
@@ -710,221 +707,3 @@ initialize_shell_builtins ()
qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
(QSFUNC *)shell_builtin_compare);
}
-
-/* **************************************************************** */
-/* */
-/* Functions for quoting strings to be re-read as input */
-/* */
-/* **************************************************************** */
-
-/* Return a new string which is the single-quoted version of STRING.
- Used by alias and trap, among others. */
-char *
-single_quote (string)
- char *string;
-{
- register int c;
- char *result, *r, *s;
-
- result = (char *)xmalloc (3 + (4 * strlen (string)));
- r = result;
- *r++ = '\'';
-
- for (s = string; s && (c = *s); s++)
- {
- *r++ = c;
-
- if (c == '\'')
- {
- *r++ = '\\'; /* insert escaped single quote */
- *r++ = '\'';
- *r++ = '\''; /* start new quoted string */
- }
- }
-
- *r++ = '\'';
- *r = '\0';
-
- return (result);
-}
-
-/* Quote STRING using double quotes. Return a new string. */
-char *
-double_quote (string)
- char *string;
-{
- register int c;
- char *result, *r, *s;
-
- result = (char *)xmalloc (3 + (2 * strlen (string)));
- r = result;
- *r++ = '"';
-
- for (s = string; s && (c = *s); s++)
- {
- switch (c)
- {
- case '"':
- case '$':
- case '`':
- case '\\':
- case '\n': /* XXX */
- *r++ = '\\';
- default:
- *r++ = c;
- break;
- }
- }
-
- *r++ = '"';
- *r = '\0';
-
- return (result);
-}
-
-/* Remove backslashes that are quoting characters that are special between
- double quotes. Return a new string. */
-char *
-un_double_quote (string)
- char *string;
-{
- register int c, pass_next;
- char *result, *r, *s;
-
- r = result = xmalloc (strlen (string) + 1);
-
- for (pass_next = 0, s = string; s && (c = *s); s++)
- {
- if (pass_next)
- {
- *r++ = c;
- pass_next = 0;
- continue;
- }
- if (c == '\\' && strchr (slashify_in_quotes, s[1]))
- {
- pass_next = 1;
- continue;
- }
- *r++ = c;
- }
-
- *r = '\0';
- return result;
-}
-
-/* Quote special characters in STRING using backslashes. Return a new
- string. */
-char *
-backslash_quote (string)
- char *string;
-{
- int c;
- char *result, *r, *s;
-
- result = xmalloc (2 * strlen (string) + 1);
-
- for (r = result, s = string; s && (c = *s); s++)
- {
- switch (c)
- {
- case ' ': case '\t': case '\n': /* IFS white space */
- case '\'': case '"': case '\\': /* quoting chars */
- case '|': case '&': case ';': /* shell metacharacters */
- case '(': case ')': case '<': case '>':
- case '!': case '{': case '}': /* reserved words */
- case '*': case '[': case '?': case ']': /* globbing chars */
- case '^':
- case '$': case '`': /* expansion chars */
- *r++ = '\\';
- *r++ = c;
- break;
-#if 0
- case '~': /* tilde expansion */
- if (s == string || s[-1] == '=' || s[-1] == ':')
- *r++ = '\\';
- *r++ = c;
- break;
-#endif
- case '#': /* comment char */
- if (s == string)
- *r++ = '\\';
- /* FALLTHROUGH */
- default:
- *r++ = c;
- break;
- }
- }
-
- *r = '\0';
- return (result);
-}
-
-#if defined (PROMPT_STRING_DECODE)
-/* Quote characters that get special treatment when in double quotes in STRING
- using backslashes. Return a new string. */
-char *
-backslash_quote_for_double_quotes (string)
- char *string;
-{
- int c;
- char *result, *r, *s;
-
- result = xmalloc (2 * strlen (string) + 1);
-
- for (r = result, s = string; s && (c = *s); s++)
- {
- switch (c)
- {
- case '"':
- case '$':
- case '`':
- case '\\':
- case '\n':
- *r++ = '\\';
- *r++ = c;
- break;
- default:
- *r++ = c;
- break;
- }
- }
-
- *r = '\0';
- return (result);
-}
-#endif /* PROMPT_STRING_DECODE */
-
-int
-contains_shell_metas (string)
- char *string;
-{
- char *s;
-
- for (s = string; s && *s; s++)
- {
- switch (*s)
- {
- case ' ': case '\t': case '\n': /* IFS white space */
- case '\'': case '"': case '\\': /* quoting chars */
- case '|': case '&': case ';': /* shell metacharacters */
- case '(': case ')': case '<': case '>':
- case '!': case '{': case '}': /* reserved words */
- case '*': case '[': case '?': case ']': /* globbing chars */
- case '^':
- case '$': case '`': /* expansion chars */
- return (1);
- case '~': /* tilde expansion */
- if (s == string || s[-1] == '=' || s[-1] == ':')
- return (1);
- case '#':
- if (s == string) /* comment char */
- return (1);
- /* FALLTHROUGH */
- default:
- break;
- }
- }
-
- return (0);
-}
diff --git a/builtins/common.h b/builtins/common.h
index 1404354..8f3366b 100644
--- a/builtins/common.h
+++ b/builtins/common.h
@@ -70,13 +70,6 @@ extern Function *builtin_address __P((char *));
extern Function *find_special_builtin __P((char *));
extern void initialize_shell_builtins __P((void));
-extern char *single_quote __P((char *));
-extern char *double_quote __P((char *));
-extern char *un_double_quote __P((char *));
-extern char *backslash_quote __P((char *));
-extern char *backslash_quote_for_double_quotes __P((char *));
-extern int contains_shell_metas __P((char *));
-
/* Functions from set.def */
extern void initialize_shell_options __P((int));
extern void list_minus_o_opts __P((int, int));
@@ -111,5 +104,6 @@ extern void parse_and_execute_cleanup __P((void));
/* Functions from evalfile.c */
extern int maybe_execute_file __P((char *, int));
extern int source_file __P((char *));
+extern int fc_execute_file __P((char *));
#endif /* !__COMMON_H */
diff --git a/builtins/complete.def b/builtins/complete.def
index 6ff29f1..3ac41d0 100644
--- a/builtins/complete.def
+++ b/builtins/complete.def
@@ -24,7 +24,7 @@ $PRODUCES complete.c
$BUILTIN complete
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION complete_builtin
-$SHORT_DOC complete [-abcdefjkvu] [-pr] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
+$SHORT_DOC complete [-abcdefjkvu] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
For each NAME, specify how arguments are to be completed.
If the -p option is supplied, or if no options are supplied, existing
completion specifications are printed in a way that allows them to be
@@ -90,6 +90,16 @@ static struct _compacts {
{ (char *)NULL, 0, 0 },
};
+static struct _compopt {
+ char *optname;
+ int optflag;
+} compopts[] = {
+ { "default", COPT_DEFAULT },
+ { "dirnames", COPT_DIRNAMES },
+ { "filenames",COPT_FILENAMES},
+ { (char *)NULL, 0 },
+};
+
static int
find_compact (name)
char *name;
@@ -102,32 +112,46 @@ find_compact (name)
return -1;
}
-/* Build the actions from the options specified in LIST. ACTP is a pointer
- to an unsigned long in which to place the bitmap of actions. PP, if
- non-null, gets 1 if -p is supplied; RP, if non-null, gets 1 if -r is
- supplied. If either is null, the corresponding option generates an
- error. This also sets variables corresponding to options that take
- arguments as a side effect; the caller should ensure that those variables
- are set to NULL before calling build_actions. Return value:
+static int
+find_compopt (name)
+ char *name;
+{
+ register int i;
+
+ for (i = 0; compopts[i].optname; i++)
+ if (STREQ (name, compopts[i].optname))
+ return i;
+ return -1;
+}
+
+/* Build the actions and compspec options from the options specified in LIST.
+ ACTP is a pointer to an unsigned long in which to place the bitmap of
+ actions. OPTP is a pointer to an unsigned long in which to place the
+ btmap of compspec options (arguments to `-o'). PP, if non-null, gets 1
+ if -p is supplied; RP, if non-null, gets 1 if -r is supplied.
+ If either is null, the corresponding option generates an error.
+ This also sets variables corresponding to options that take arguments as
+ a side effect; the caller should ensure that those variables are set to
+ NULL before calling build_actions. Return value:
EX_USAGE = bad option
EXECUTION_SUCCESS = some options supplied
EXECUTION_FAILURE = no options supplied
*/
static int
-build_actions (list, pp, rp, actp)
+build_actions (list, pp, rp, actp, optp)
WORD_LIST *list;
int *pp, *rp;
- unsigned long *actp;
+ unsigned long *actp, *optp;
{
int opt, ind, pflag, rflag, opt_given;
- unsigned long acts;
+ unsigned long acts, copts;
- acts = (unsigned long)0L;
+ acts = copts = (unsigned long)0L;
opt_given = 0;
reset_internal_getopt ();
- while ((opt = internal_getopt (list, "abcdefjkpruvA:G:W:P:S:X:F:C:")) != -1)
+ while ((opt = internal_getopt (list, "abcdefjko:pruvA:G:W:P:S:X:F:C:")) != -1)
{
opt_given = 1;
switch (opt)
@@ -188,6 +212,15 @@ build_actions (list, pp, rp, actp)
case 'v':
acts |= CA_VARIABLE;
break;
+ case 'o':
+ ind = find_compopt (list_optarg);
+ if (ind < 0)
+ {
+ builtin_error ("%s: invalid option name", list_optarg);
+ return (EX_USAGE);
+ }
+ copts |= compopts[ind].optflag;
+ break;
case 'A':
ind = find_compact (list_optarg);
if (ind < 0)
@@ -225,6 +258,8 @@ build_actions (list, pp, rp, actp)
}
*actp = acts;
+ *optp = copts;
+
return (opt_given ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
@@ -234,7 +269,7 @@ complete_builtin (list)
WORD_LIST *list;
{
int opt_given, pflag, rflag, rval;
- unsigned long acts;
+ unsigned long acts, copts;
char *cmd;
COMPSPEC *cs;
@@ -245,13 +280,13 @@ complete_builtin (list)
}
opt_given = pflag = rflag = 0;
- acts = (unsigned long)0L;
+ acts = copts = (unsigned long)0L;
Aarg = Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
cs = (COMPSPEC *)NULL;
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
as a side effect if they are supplied as options. */
- rval = build_actions (list, &pflag, &rflag, &acts);
+ rval = build_actions (list, &pflag, &rflag, &acts, &copts);
if (rval == EX_USAGE)
return (rval);
opt_given = rval != EXECUTION_FAILURE;
@@ -290,6 +325,7 @@ complete_builtin (list)
remaining argument. */
cs = alloc_compspec ();
cs->actions = acts;
+ cs->options = copts;
cs->globpat = STRDUP (Garg);
cs->words = STRDUP (Warg);
@@ -304,7 +340,7 @@ complete_builtin (list)
/* Add CS as the compspec for the specified commands. */
cmd = list->word->word;
if (add_progcomp (cmd, cs) == 0)
- rval = EXECUTION_FAILURE;
+ rval = EXECUTION_FAILURE;
}
return (rval);
@@ -332,7 +368,7 @@ remove_cmd_completions (list)
do { \
if (a) \
{ \
- x = single_quote (a); \
+ x = sh_single_quote (a); \
printf ("%s %s ", f, x); \
free (x); \
} \
@@ -356,19 +392,32 @@ remove_cmd_completions (list)
printf ("-A %s ", f); \
} while (0)
+#define PRINTCOMPOPT(a, f) \
+ do { \
+ if (copts & a) \
+ printf ("-o %s ", f); \
+ } while (0)
+
static void
print_one_completion (cmd, cs)
char *cmd;
COMPSPEC *cs;
{
- unsigned long acts;
+ unsigned long acts, copts;
char *x;
printf ("complete ");
+ copts = cs->options;
+
+ /* First, print the -o options. */
+ PRINTCOMPOPT (COPT_DEFAULT, "default");
+ PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
+ PRINTCOMPOPT (COPT_FILENAMES, "filenames");
+
acts = cs->actions;
- /* simple flags first */
+ /* simple flags next */
PRINTOPT (CA_ALIAS, "-a");
PRINTOPT (CA_BUILTIN, "-b");
PRINTOPT (CA_COMMAND, "-c");
@@ -428,7 +477,7 @@ print_cmd_completions (list)
{
cs = find_compspec (l->word->word);
if (cs)
- print_one_completion (l->word->word, cs);
+ print_one_completion (l->word->word, cs);
else
{
builtin_error ("%s: no completion specification", l->word->word);
@@ -441,7 +490,7 @@ print_cmd_completions (list)
$BUILTIN compgen
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION compgen_builtin
-$SHORT_DOC compgen [-abcdefjkvu] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
+$SHORT_DOC compgen [-abcdefjkvu] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
Display the possible completions depending on the options. Intended
to be used from within a shell function generating possible completions.
If the optional WORD argument is supplied, matches against WORD are
@@ -453,7 +502,7 @@ compgen_builtin (list)
WORD_LIST *list;
{
int rval;
- unsigned long acts;
+ unsigned long acts, copts;
COMPSPEC *cs;
STRINGLIST *sl;
char *word;
@@ -461,13 +510,13 @@ compgen_builtin (list)
if (list == 0)
return (EXECUTION_SUCCESS);
- acts = (unsigned long)0L;
+ acts = copts = (unsigned long)0L;
Aarg = Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
cs = (COMPSPEC *)NULL;
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
as a side effect if they are supplied as options. */
- rval = build_actions (list, (int *)NULL, (int *)NULL, &acts);
+ rval = build_actions (list, (int *)NULL, (int *)NULL, &acts, &copts);
if (rval == EX_USAGE)
return (rval);
if (rval == EXECUTION_FAILURE)
@@ -485,6 +534,7 @@ compgen_builtin (list)
/* If we get here, we need to build a compspec and evaluate it. */
cs = alloc_compspec ();
cs->actions = acts;
+ cs->options = copts;
cs->refcount = 1;
cs->globpat = STRDUP (Garg);
diff --git a/builtins/declare.def b/builtins/declare.def
index c6664d9..6686f0a 100644
--- a/builtins/declare.def
+++ b/builtins/declare.def
@@ -333,10 +333,12 @@ declare_internal (list, local_var)
NEXT_VARIABLE ();
}
- /* Cannot use declare to assign value to readonly variable. */
- if (readonly_p (var) && offset)
+ /* Cannot use declare to assign value to readonly or noassign
+ variable. */
+ if ((readonly_p (var) || noassign_p (var)) && offset)
{
- builtin_error ("%s: readonly variable", name);
+ if (readonly_p (var))
+ builtin_error ("%s: readonly variable", name);
assign_error++;
NEXT_VARIABLE ();
}
@@ -347,7 +349,7 @@ declare_internal (list, local_var)
if ((making_array_special || (flags_on & att_array) || array_p (var)) && offset)
{
if (value[0] == '(' && strchr (value, ')'))
- assigning_array_special = 1;
+ assigning_array_special = 1;
else
{
builtin_error ("%s: cannot assign to array variables in this way", name);
diff --git a/builtins/enable.def b/builtins/enable.def
index 0f701a2..b6ac483 100644
--- a/builtins/enable.def
+++ b/builtins/enable.def
@@ -164,7 +164,7 @@ enable_builtin (list)
{
filter = (flags & NFLAG) ? DISABLED : ENABLED;
if (flags & SFLAG)
- filter |= SPECIAL;
+ filter |= SPECIAL;
result = dyn_load_builtin (list, filter, filename);
#if defined (PROGRAMMABLE_COMPLETION)
@@ -326,10 +326,10 @@ dyn_load_builtin (list, flags, filename)
b->handle = handle;
if (old_builtin = builtin_address_internal (name, 1))
- {
- replaced++;
+ {
+ replaced++;
FASTCOPY ((char *)b, (char *)old_builtin, sizeof (struct builtin));
- }
+ }
else
new_builtins[new++] = b;
}
diff --git a/builtins/evalfile.c b/builtins/evalfile.c
index dad987a..1116b09 100644
--- a/builtins/evalfile.c
+++ b/builtins/evalfile.c
@@ -56,6 +56,7 @@ extern int errno;
#define FEVAL_NONINT 0x008
#define FEVAL_LONGJMP 0x010
#define FEVAL_HISTORY 0x020
+#define FEVAL_CHECKBINARY 0x040
extern int interactive, interactive_shell, posixly_correct;
extern int indirection_level, startup_state, subshell_environment;
@@ -87,7 +88,7 @@ file_error_and_exit:
file_error (filename);
if (flags & FEVAL_LONGJMP)
- {
+ {
last_command_exit_value = 1;
jump_to_top_level (EXITPROG);
}
@@ -116,6 +117,11 @@ file_error_and_exit:
(*errfunc) ("%s: file is too large", filename);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
}
+
+#if defined (__CYGWIN__) && defined (O_TEXT)
+ setmode (fd, O_TEXT);
+#endif
+
string = xmalloc (1 + file_size);
result = read (fd, string, file_size);
string[result] = '\0';
@@ -136,7 +142,8 @@ file_error_and_exit:
return ((flags & FEVAL_BUILTIN) ? EXECUTION_SUCCESS : 1);
}
- if (check_binary_file ((unsigned char *)string, (result > 80) ? 80 : result))
+ if ((flags & FEVAL_CHECKBINARY) &&
+ check_binary_file ((unsigned char *)string, (result > 80) ? 80 : result))
{
free (string);
(*errfunc) ("%s: cannot execute binary file", filename);
diff --git a/builtins/evalstring.c b/builtins/evalstring.c
index 37516bb..21e4772 100644
--- a/builtins/evalstring.c
+++ b/builtins/evalstring.c
@@ -175,7 +175,7 @@ parse_and_execute (string, from_file, flags)
case DISCARD:
run_unwind_frame ("pe_dispose");
- last_command_exit_value = 1; /* XXX */
+ last_result = last_command_exit_value = EXECUTION_FAILURE; /* XXX */
if (subshell_environment)
{
should_jump_to_top_level = 1;
@@ -238,7 +238,7 @@ parse_and_execute (string, from_file, flags)
/* See if this is a candidate for $( <file ). */
if (startup_state == 2 &&
- subshell_environment == SUBSHELL_COMSUB &&
+ (subshell_environment & SUBSHELL_COMSUB) &&
*bash_input.location.string == '\0' &&
command->type == cm_simple && !command->redirects &&
(command->flags & CMD_TIME_PIPELINE) == 0 &&
@@ -277,8 +277,8 @@ parse_and_execute (string, from_file, flags)
if (interrupt_state && parse_and_execute_level == 0)
{
/* An interrupt during non-interactive execution in an
- interactive shell (e.g. via $PROMPT_COMMAND) should
- not cause the shell to exit. */
+ interactive shell (e.g. via $PROMPT_COMMAND) should
+ not cause the shell to exit. */
interactive = interactive_shell;
throw_to_top_level ();
}
diff --git a/builtins/fc.def b/builtins/fc.def
index 0c30ebb..60a940e 100644
--- a/builtins/fc.def
+++ b/builtins/fc.def
@@ -86,7 +86,7 @@ extern int literal_history;
extern int unlink ();
-extern int fc_execute_file ();
+extern FILE *sh_mktmpfp __P((char *, int, char **));
/* **************************************************************** */
/* */
@@ -161,7 +161,7 @@ fc_builtin (list)
REPL *rlist, *rl;
char *ename, *command, *newcom, *line;
HIST_ENTRY **hlist;
- char fn[64];
+ char *fn;
numbering = 1;
reverse = listing = execute = 0;
@@ -327,14 +327,11 @@ fc_builtin (list)
else
{
numbering = 0;
- /* XXX - this is raceable */
- sprintf (fn, "/tmp/bash%d", (int)time ((time_t *) 0) + (int)getpid ());
-
- stream = fopen (fn, "w");
-
+ stream = sh_mktmpfp ("bash-fc", MT_USERANDOM|MT_USETMPDIR, &fn);
if (stream == 0)
{
- builtin_error ("cannot open temp file %s", fn);
+ builtin_error ("cannot open temp file %s", fn ? fn : "");
+ FREE (fn);
return (EXECUTION_FAILURE);
}
}
@@ -369,6 +366,7 @@ fc_builtin (list)
if (retval != EXECUTION_SUCCESS)
{
unlink (fn);
+ free (fn);
return (EXECUTION_FAILURE);
}
@@ -381,6 +379,7 @@ fc_builtin (list)
/* Turn on the `v' flag while fc_execute_file runs so the commands
will be echoed as they are read by the parser. */
begin_unwind_frame ("fc builtin");
+ add_unwind_protect ((Function *)xfree, fn);
add_unwind_protect (unlink, fn);
unwind_protect_int (echo_input_at_read);
echo_input_at_read = 1;
diff --git a/builtins/getopts.def b/builtins/getopts.def
index dcd4ec3..6abd1e4 100644
--- a/builtins/getopts.def
+++ b/builtins/getopts.def
@@ -196,9 +196,9 @@ dogetopts (argc, argv)
;
v = alloc_array (i + 1);
for (i = 0; i < 10 && dollar_vars[i]; i++)
- v[i] = dollar_vars[i];
+ v[i] = dollar_vars[i];
for (words = rest_of_args; words; words = words->next, i++)
- v[i] = words->word->word;
+ v[i] = words->word->word;
v[i] = (char *)NULL;
sh_getopt_restore_state (v);
ret = sh_getopt (i, v, optstr);
diff --git a/builtins/hash.def b/builtins/hash.def
index 8fa9653..7598d1b 100644
--- a/builtins/hash.def
+++ b/builtins/hash.def
@@ -41,6 +41,8 @@ $END
# include <unistd.h>
#endif
+#include <errno.h>
+
#include "../bashansi.h"
#include "../shell.h"
@@ -119,7 +121,19 @@ hash_builtin (list)
/* Add or rehash the specified commands. */
w = list->word->word;
if (pathname)
- remember_filename (w, pathname, 0, 0);
+ {
+ if (is_directory (pathname))
+ {
+#ifdef EISDIR
+ builtin_error ("%s: %s", pathname, strerror (EISDIR));
+#else
+ builtin_error ("%s: is a directory", pathname);
+#endif
+ opt = EXECUTION_FAILURE;
+ }
+ else
+ remember_filename (w, pathname, 0, 0);
+ }
else if (absolute_program (w))
continue;
else if (add_hashed_command (w, 0))
diff --git a/builtins/history.def b/builtins/history.def
index 07c08f3..1ea3489 100644
--- a/builtins/history.def
+++ b/builtins/history.def
@@ -157,7 +157,7 @@ history_builtin (list)
else if (flags & PFLAG)
{
if (list)
- return (expand_and_print_history (list));
+ return (expand_and_print_history (list));
return (EXECUTION_SUCCESS);
}
#endif
@@ -326,10 +326,10 @@ expand_and_print_history (list)
result = EXECUTION_FAILURE;
}
else
- {
+ {
fputs (s, stdout);
putchar ('\n');
- }
+ }
FREE (s);
list = list->next;
}
diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c
index 3098ad6..139a46f 100644
--- a/builtins/mkbuiltins.c
+++ b/builtins/mkbuiltins.c
@@ -205,7 +205,7 @@ main (argc, argv)
#if !defined (OLDCODE)
else if (strcmp (arg, "-nodocument") == 0)
no_long_document = 1;
-#endif /* !OLDCODE */
+#endif /* !OLDCODE */
else
{
fprintf (stderr, "%s: Unknown flag %s.\n", argv[0], arg);
@@ -614,10 +614,10 @@ free_defs (defs)
if (defs->builtins)
{
for (i = 0; builtin = (BUILTIN_DESC *)defs->builtins->array[i]; i++)
- {
+ {
free_builtin (builtin);
free (builtin);
- }
+ }
array_free (defs->builtins);
}
free (defs);
@@ -990,9 +990,9 @@ copy_builtin (builtin)
new = (BUILTIN_DESC *)xmalloc (sizeof (BUILTIN_DESC));
- new->name = savestring (builtin->name);
- new->shortdoc = savestring (builtin->shortdoc);
- new->longdoc = copy_string_array (builtin->longdoc);
+ new->name = savestring (builtin->name);
+ new->shortdoc = savestring (builtin->shortdoc);
+ new->longdoc = copy_string_array (builtin->longdoc);
new->dependencies = copy_string_array (builtin->dependencies);
new->function =
@@ -1151,7 +1151,7 @@ write_builtins (defs, structfile, externfile)
builtin->function);
fprintf (externfile, "extern char *%s_doc[];\n",
- builtin->docname ?builtin->docname : builtin->name);
+ builtin->docname ? builtin->docname : builtin->name);
}
/* Write the structure definition. */
diff --git a/builtins/printf.def b/builtins/printf.def
index f0b4590..1d40608 100644
--- a/builtins/printf.def
+++ b/builtins/printf.def
@@ -88,13 +88,13 @@ static char *getstr __P((void));
static int getint __P((void));
static int getlong __P((long *));
static int getulong __P((unsigned long *));
-static double getdouble __P((void));
+static int getdouble __P((double *));
static int asciicode __P((void));
static WORD_LIST *garglist;
static int retval;
-extern char *backslash_quote ();
+extern char *sh_backslash_quote ();
int
printf_builtin (list)
@@ -255,7 +255,7 @@ printf_builtin (list)
char *p, *xp;
p = getstr ();
- xp = backslash_quote (p);
+ xp = sh_backslash_quote (p);
if (xp)
{
/* Use printstr to get fieldwidth and precision right. */
@@ -307,7 +307,8 @@ printf_builtin (list)
{
double p;
- p = getdouble ();
+ if (getdouble (&p))
+ PRETURN (EXECUTION_FAILURE);
PF(start, p);
break;
}
@@ -471,7 +472,8 @@ tescape (estart, trans_squote, cp, sawc)
case 'b': *cp = '\b'; break;
- case 'e': *cp = '\033'; break; /* ESC -- non-ANSI */
+ case 'e':
+ case 'E': *cp = '\033'; break; /* ESC -- non-ANSI */
case 'f': *cp = '\f'; break;
@@ -484,7 +486,7 @@ tescape (estart, trans_squote, cp, sawc)
case 'v': *cp = '\v'; break;
/* %b octal constants are `\0' followed by one, two, or three
- octal digits... */
+ octal digits... */
case '0':
for (temp = 3, evalue = 0; isoctal (*p) && temp--; p++)
evalue = (evalue * 8) + OCTVALUE (*p);
@@ -638,8 +640,13 @@ getint ()
if (ret > INT_MAX)
{
- builtin_error ("%s: %s", garglist->word->word, strerror(ERANGE));
- return (0);
+ builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
+ ret = INT_MAX;
+ }
+ else if (ret < INT_MIN)
+ {
+ builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
+ ret = INT_MIN;
}
return ((int)ret);
@@ -676,10 +683,7 @@ getlong (lp)
return (1);
}
else if (errno == ERANGE)
- {
- builtin_error ("%s: %s", garglist->word->word, strerror(ERANGE));
- return (1);
- }
+ builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
*lp = ret;
garglist = garglist->next;
@@ -714,31 +718,45 @@ getulong (ulp)
return (1);
}
else if (errno == ERANGE)
- {
- builtin_error ("%s: %s", garglist->word->word, strerror(ERANGE));
- return (1);
- }
+ builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
*ulp = ret;
garglist = garglist->next;
return (0);
}
-static double
-getdouble ()
+static int
+getdouble (dp)
+ double *dp;
{
double ret;
+ char *ep;
if (garglist == 0)
- return ((double)0);
+ {
+ *dp = (double)0;
+ return (0);
+ }
if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"')
- return ((double)asciicode ());
+ {
+ *dp = (double)asciicode ();
+ return (0);
+ }
- /* This should use strtod if it is available. */
- ret = atof (garglist->word->word);
+ errno = 0;
+ ret = strtod (garglist->word->word, &ep);
+ if (*ep)
+ {
+ builtin_error ("%s: invalid number", garglist->word->word);
+ return (1);
+ }
+ else if (errno == ERANGE)
+ builtin_error ("warning: %s: %s", garglist->word->word, strerror(ERANGE));
+
+ *dp = ret;
garglist = garglist->next;
- return (ret);
+ return (0);
}
/* NO check is needed for garglist here. */
diff --git a/builtins/pushd.def b/builtins/pushd.def
index 4866f41..83f7e9b 100644
--- a/builtins/pushd.def
+++ b/builtins/pushd.def
@@ -186,10 +186,10 @@ pushd_builtin (list)
flags |= NOCD;
}
else if (ISOPTION (list->word->word, '-'))
- {
- list = list->next;
- break;
- }
+ {
+ list = list->next;
+ break;
+ }
else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
/* Let `pushd -' work like it used to. */
break;
@@ -296,14 +296,14 @@ popd_builtin (list)
for (flags = 0, which = 0L, direction = '+'; list; list = list->next)
{
if (ISOPTION (list->word->word, 'n'))
- {
- flags |= NOCD;
- }
+ {
+ flags |= NOCD;
+ }
else if (ISOPTION (list->word->word, '-'))
- {
- list = list->next;
- break;
- }
+ {
+ list = list->next;
+ break;
+ }
else if (((direction = list->word->word[0]) == '+') || direction == '-')
{
if (legal_number (list->word->word + 1, &which) == 0)
@@ -335,7 +335,7 @@ popd_builtin (list)
(direction == '-' && which == directory_list_offset))
{
i = ((flags & NOCD) == 0) ? cd_to_string (pushd_directory_list[directory_list_offset - 1])
- : EXECUTION_SUCCESS;
+ : EXECUTION_SUCCESS;
if (i != EXECUTION_SUCCESS)
return (i);
free (pushd_directory_list[--directory_list_offset]);
@@ -386,14 +386,14 @@ dirs_builtin (list)
vflag |= 1;
}
else if (ISOPTION (list->word->word, '-'))
- {
- list = list->next;
- break;
- }
+ {
+ list = list->next;
+ break;
+ }
else if (*list->word->word == '+' || *list->word->word == '-')
- {
- int sign;
- if (legal_number (w = list->word->word + 1, &i) == 0)
+ {
+ int sign;
+ if (legal_number (w = list->word->word + 1, &i) == 0)
{
builtin_error (m_badarg, list->word->word);
builtin_usage ();
diff --git a/builtins/read.def b/builtins/read.def
index 8e16152..d63f27a 100644
--- a/builtins/read.def
+++ b/builtins/read.def
@@ -58,6 +58,11 @@ $END
#include <signal.h>
#include <errno.h>
+#ifdef __CYGWIN__
+# include <fcntl.h>
+# include <io.h>
+#endif
+
#include "../shell.h"
#include "common.h"
#include "bashgetopt.h"
@@ -148,8 +153,8 @@ read_builtin (list)
while ((opt = internal_getopt (list, "erp:a:d:t:n:s")) != -1)
{
switch (opt)
- {
- case 'r':
+ {
+ case 'r':
raw = 1;
break;
case 'p':
@@ -211,15 +216,13 @@ read_builtin (list)
input_string = xmalloc (size = 128);
begin_unwind_frame ("read_builtin");
- add_unwind_protect (xfree, input_string);
#if defined (READLINE)
add_unwind_protect (xfree, rlbuf);
#endif
- interrupt_immediately++;
input_is_tty = isatty (0);
if (input_is_tty == 0)
-#ifndef __CYGWIN32__
+#ifndef __CYGWIN__
input_is_pipe = (lseek (0, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
#else
input_is_pipe = 1;
@@ -247,7 +250,7 @@ read_builtin (list)
/* Turn off the timeout if stdin is a regular file (e.g. from
input redirection). */
if ((fstat (0, &tsb) < 0) || S_ISREG (tsb.st_mode))
- tmout = -1;
+ tmout = -1;
}
if (tmout > 0)
@@ -285,7 +288,7 @@ read_builtin (list)
else
#endif
if (input_is_tty)
- {
+ {
ttsave ();
if (silent)
ttcbreak ();
@@ -301,8 +304,17 @@ read_builtin (list)
add_unwind_protect ((Function *)ttrestore, (char *)NULL);
}
+ /* This *must* be the top unwind-protect on the stack, so the manipulation
+ of the unwind-protect stack after the realloc() works right. */
+ add_unwind_protect (xfree, input_string);
+ interrupt_immediately++;
+
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
+#if defined (__CYGWIN__) && defined (O_TEXT)
+ setmode (0, O_TEXT);
+#endif
+
for (eof = 0;;)
{
#if defined (READLINE)
@@ -345,7 +357,11 @@ read_builtin (list)
#endif
if (i + 2 >= size)
- input_string = xrealloc (input_string, size += 128);
+ {
+ input_string = xrealloc (input_string, size += 128);
+ remove_unwind_protect ();
+ add_unwind_protect (xfree, input_string);
+ }
/* If the next character is to be accepted verbatim, a backslash
newline pair still disappears from the input. */
@@ -419,9 +435,9 @@ read_builtin (list)
{
var = find_variable (arrayname);
if (var == 0)
- var = make_new_array_variable (arrayname);
+ var = make_new_array_variable (arrayname);
else if (array_p (var) == 0)
- var = convert_var_to_array (var);
+ var = convert_var_to_array (var);
empty_array (array_cell (var));
@@ -441,7 +457,8 @@ read_builtin (list)
so that `read x ; echo "$x"' and `read ; echo "$REPLY"' behave the
same way, but I believe that the difference in behaviors is useful
enough to not do it. Without the bash behavior, there is no way
- to read a line completely without interpretation or modification.
+ to read a line completely without interpretation or modification
+ unless you mess with $IFS (e.g., setting it to the empty string).
If you disagree, change the occurrences of `#if 0' to `#if 1' below. */
if (list == 0)
{
@@ -462,11 +479,8 @@ read_builtin (list)
else
var = bind_variable ("REPLY", input_string);
VUNSETATTR (var, att_invisible);
-#if 0
- free (orig_input_string);
-#else
+
free (input_string);
-#endif
return (retval);
}
@@ -572,10 +586,10 @@ bind_read_variable (name, value)
{
#if 0
if (legal_identifier (name) == 0)
- {
+ {
builtin_error ("`%s': not a valid identifier", name);
return ((SHELL_VAR *)NULL);
- }
+ }
#endif
return (bind_variable (name, value));
}
diff --git a/builtins/set.def b/builtins/set.def
index fd7dc99..700b518 100644
--- a/builtins/set.def
+++ b/builtins/set.def
@@ -52,7 +52,7 @@ $PRODUCES set.c
extern int interactive;
extern int noclobber, posixly_correct, ignoreeof, eof_encountered_limit;
#if defined (READLINE)
-extern int rl_editing_mode, no_line_editing;
+extern int no_line_editing;
#endif /* READLINE */
$BUILTIN set
@@ -224,9 +224,9 @@ minus_o_option_value (name)
for (i = 0; binary_o_options[i].name; i++)
{
if (STREQ (name, binary_o_options[i].name))
- return (GET_BINARY_O_OPTION_VALUE (i, name));
+ return (GET_BINARY_O_OPTION_VALUE (i, name));
}
-
+
return (-1);
}
@@ -256,13 +256,13 @@ list_minus_o_opts (mode, reusable)
if (on_or_off == FLAG_UNKNOWN)
on_or_off = &value;
if (mode == -1 || mode == *on_or_off)
- print_minus_o_option (o_options[i].name, *on_or_off, reusable);
+ print_minus_o_option (o_options[i].name, *on_or_off, reusable);
}
for (i = 0; binary_o_options[i].name; i++)
{
value = GET_BINARY_O_OPTION_VALUE (i, binary_o_options[i].name);
if (mode == -1 || mode == value)
- print_minus_o_option (binary_o_options[i].name, value, reusable);
+ print_minus_o_option (binary_o_options[i].name, value, reusable);
}
}
@@ -390,10 +390,10 @@ set_minus_o_option (on_or_off, option_name)
for (i = 0, option_char = -1, set_func = 0; o_options[i].name; i++)
{
if (STREQ (option_name, o_options[i].name))
- {
- option_char = o_options[i].letter;
- break;
- }
+ {
+ option_char = o_options[i].letter;
+ break;
+ }
}
if (option_char == -1)
{
@@ -420,11 +420,16 @@ print_all_shell_variables ()
free (vars);
}
- vars = all_shell_functions ();
- if (vars)
+ /* POSIX.2 does not allow function names and definitions to be output when
+ `set' is invoked without options (PASC Interp #202). */
+ if (posixly_correct == 0)
{
- print_var_list (vars);
- free (vars);
+ vars = all_shell_functions ();
+ if (vars)
+ {
+ print_func_list (vars);
+ free (vars);
+ }
}
}
@@ -533,14 +538,16 @@ initialize_shell_options (no_shellopts)
set_shellopts ();
}
-/* Reset the values of the -o options that are not also shell flags. */
+/* Reset the values of the -o options that are not also shell flags. This is
+ called from execute_cmd.c:initialize_subshell() when setting up a subshell
+ to run an executable shell script without a leading `#!'. */
void
reset_shell_options ()
{
#if defined (HISTORY)
remember_on_history = 1;
#endif
- ignoreeof = posixly_correct = 0;
+ ignoreeof = 0;
}
/* Set some flags from the word values in the input list. If LIST is empty,
@@ -695,8 +702,7 @@ For each NAME, remove the corresponding variable or function. Given
the `-v', unset will only act on variables. Given the `-f' flag,
unset will only act on functions. With neither flag, unset first
tries to unset a variable, and if that fails, then tries to unset a
-function. Some variables (such as PATH and IFS) cannot be unset; also
-see readonly.
+function. Some variables cannot be unset; also see readonly.
$END
#define NEXT_VARIABLE() any_failed++; list = list->next; continue;
@@ -758,10 +764,10 @@ unset_builtin (list)
to be created when not in posix mode, so check only when in posix
mode when unsetting a function. */
if (((unset_function && posixly_correct) || !unset_function) && legal_identifier (name) == 0)
- {
- builtin_error ("`%s': not a valid identifier", name);
- NEXT_VARIABLE ();
- }
+ {
+ builtin_error ("`%s': not a valid identifier", name);
+ NEXT_VARIABLE ();
+ }
var = unset_function ? find_function (name) : find_variable (name);
diff --git a/builtins/setattr.def b/builtins/setattr.def
index 8112cf6..2e3ad84 100644
--- a/builtins/setattr.def
+++ b/builtins/setattr.def
@@ -169,7 +169,7 @@ set_or_show_attributes (list, attribute, nodefs)
/* xxx [-np] name[=value] */
assign = assignment (name);
- if (assign)
+ if (assign)
name[assign] = '\0';
if (legal_identifier (name) == 0)
@@ -233,11 +233,11 @@ set_or_show_attributes (list, attribute, nodefs)
#if defined (ARRAY_VARS)
if (attribute & att_array)
- {
- arrays_only++;
- if (attribute != att_array)
+ {
+ arrays_only++;
+ if (attribute != att_array)
attribute &= ~att_array;
- }
+ }
#endif
if (variable_list)
@@ -246,7 +246,7 @@ set_or_show_attributes (list, attribute, nodefs)
{
#if defined (ARRAY_VARS)
if (arrays_only && array_p (var) == 0)
- continue;
+ continue;
#endif
if ((var->attributes & attribute) && invisible_p (var) == 0)
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
@@ -285,16 +285,16 @@ show_var_attributes (var, pattr, nodefs)
#endif
if (function_p (var))
- flags[i++] = 'f';
+ flags[i++] = 'f';
if (integer_p (var))
- flags[i++] = 'i';
+ flags[i++] = 'i';
if (readonly_p (var))
- flags[i++] = 'r';
+ flags[i++] = 'r';
if (exported_p (var))
- flags[i++] = 'x';
+ flags[i++] = 'x';
}
else
{
@@ -304,7 +304,7 @@ show_var_attributes (var, pattr, nodefs)
#endif
if (function_p (var))
- flags[i++] = 'f';
+ flags[i++] = 'f';
}
flags[i] = '\0';
@@ -329,7 +329,7 @@ show_var_attributes (var, pattr, nodefs)
printf ("%s\n", named_function_string (var->name, function_cell (var), 1));
else
{
- x = double_quote (value_cell (var) ? value_cell (var) : "");
+ x = sh_double_quote (value_cell (var) ? value_cell (var) : "");
printf ("%s=%s\n", var->name, x);
free (x);
}
diff --git a/builtins/shopt.def b/builtins/shopt.def
index 550b7f6..138b88d 100644
--- a/builtins/shopt.def
+++ b/builtins/shopt.def
@@ -332,8 +332,9 @@ list_shopts (list, flags)
if (val == 0)
rval = EXECUTION_FAILURE;
if ((flags & QFLAG) == 0)
- print_shopt (l->word->word, val, flags);
+ print_shopt (l->word->word, val, flags);
}
+
return (rval);
}
diff --git a/builtins/source.def b/builtins/source.def
index 2da47a1..f9086f8 100644
--- a/builtins/source.def
+++ b/builtins/source.def
@@ -67,15 +67,20 @@ extern int restricted;
/* If non-zero, `.' uses $PATH to look up the script to be sourced. */
int source_uses_path = 1;
+/* If non-zero, `.' looks in the current directory if the filename argument
+ is not found in the $PATH. */
+int source_searches_cwd = 1;
+
/* If this . script is supplied arguments, we save the dollar vars and
replace them with the script arguments for the duration of the script's
execution. If the script does not change the dollar vars, we restore
- what we saved. If the dollar vars are changed in the script, we leave
- the new values alone and free the saved values. */
+ what we saved. If the dollar vars are changed in the script, and we are
+ not executing a shell function, we leave the new values alone and free
+ the saved values. */
static void
maybe_pop_dollar_vars ()
{
- if (dollar_vars_changed ())
+ if (variable_context == 0 && dollar_vars_changed ())
{
dispose_saved_dollar_vars ();
set_dollar_vars_unchanged ();
@@ -117,7 +122,15 @@ source_builtin (list)
if (source_uses_path)
filename = find_path_file (list->word->word);
if (filename == 0)
- filename = savestring (list->word->word);
+ {
+ if (source_searches_cwd == 0)
+ {
+ builtin_error ("%s: file not found", list->word->word);
+ return (EXECUTION_FAILURE);
+ }
+ else
+ filename = savestring (list->word->word);
+ }
begin_unwind_frame ("source");
add_unwind_protect ((Function *)xfree, filename);
diff --git a/builtins/trap.def b/builtins/trap.def
index 8bba165..8503035 100644
--- a/builtins/trap.def
+++ b/builtins/trap.def
@@ -79,7 +79,7 @@ static int display_traps ();
#define REVERT 1 /* Revert to this signals original value. */
#define IGNORE 2 /* Ignore this signal. */
-extern int interactive;
+extern int interactive, posixly_correct;
int
trap_builtin (list)
@@ -201,12 +201,19 @@ showtrap (i)
if (p == (char *)DEFAULT_SIG)
return;
- t = (p == (char *)IGNORE_SIG) ? (char *)NULL : single_quote (p);
+ t = (p == (char *)IGNORE_SIG) ? (char *)NULL : sh_single_quote (p);
sn = signal_name (i);
/* Make sure that signals whose names are unknown (for whatever reason)
are printed as signal numbers. */
if (STREQN (sn, "SIGJUNK", 7) || STREQN (sn, "unknown", 7))
printf ("trap -- %s %d\n", t ? t : "''", i);
+ else if (posixly_correct)
+ {
+ if (STREQN (sn, "SIG", 3))
+ printf ("trap -- %s %s\n", t ? t : "''", sn+3);
+ else
+ printf ("trap -- %s %s\n", t ? t : "''", sn);
+ }
else
printf ("trap -- %s %s\n", t ? t : "''", sn);
diff --git a/builtins/type.def b/builtins/type.def
index 9a4ef0d..a60db0a 100644
--- a/builtins/type.def
+++ b/builtins/type.def
@@ -123,12 +123,12 @@ type_builtin (list)
type_only = 0;
}
else if (STREQ (flag, "all") || STREQ (flag, "-all"))
- all = 1;
+ all = 1;
else
{
- prev = this;
- this = this->next;
- continue;
+ prev = this;
+ this = this->next;
+ continue;
}
/* We found a long option; remove it from the argument list. Don't
@@ -234,7 +234,7 @@ describe_command (command, verbose, all)
printf ("%s is aliased to `%s'\n", command, alias->value);
else if (verbose == 4)
{
- x = single_quote (alias->value);
+ x = sh_single_quote (alias->value);
printf ("alias %s=%s\n", command, x);
free (x);
}
@@ -317,7 +317,7 @@ describe_command (command, verbose, all)
{
f = file_status (command);
if (f & FS_EXECABLE)
- {
+ {
if (verbose == 1)
puts ("file");
else if (verbose == 2)
@@ -329,7 +329,7 @@ describe_command (command, verbose, all)
because they're not consulted when an absolute program
name is supplied. */
return (1);
- }
+ }
}
/* If the user isn't doing "-a", then we might care about
diff --git a/builtins/ulimit.def b/builtins/ulimit.def
index e57e76d..a9d5d6a 100644
--- a/builtins/ulimit.def
+++ b/builtins/ulimit.def
@@ -202,6 +202,9 @@ static RESOURCE_LIMITS limits[] = {
#if defined (HAVE_RESOURCE)
{ 'v', RLIMIT_VIRTMEM, RLIMIT_VMBLKSZ, "virtual memory (kbytes)" },
#endif
+#ifdef RLIMIT_SWAP
+ { 'w', RLIMIT_SWAP, 1024, "swap size (kbytes)" },
+#endif
{ -1, -1, -1, (char *)NULL }
};
#define NCMDS (sizeof(limits) / sizeof(limits[0]))
@@ -476,7 +479,13 @@ set_limit (ind, newlim, mode)
case RLIMIT_OPENFILES:
#if defined (HAVE_SETDTABLESIZE)
+# if defined (__CYGWIN__)
+ /* Grrr... Cygwin declares setdtablesize as void. */
+ setdtablesize (newlim);
+ return 0;
+# else
return (setdtablesize (newlim));
+# endif
#endif
case RLIMIT_PIPESIZE:
case RLIMIT_VIRTMEM:
@@ -495,6 +504,7 @@ set_limit (ind, newlim, mode)
newlim /= 512; /* Ugh. */
# endif /* HPUX9 */
val = (current_user.euid != 0 && newlim == RLIM_INFINITY &&
+ (mode & LIMIT_HARD) == 0 && /* XXX -- test */
(limit.rlim_cur <= limit.rlim_max))
? limit.rlim_max : newlim;
if (mode & LIMIT_SOFT)
diff --git a/builtins/umask.def b/builtins/umask.def
index 9205c94..1c1591e 100644
--- a/builtins/umask.def
+++ b/builtins/umask.def
@@ -188,7 +188,7 @@ parse_symbolic_mode (mode, initial_bits)
/* Parse the `who' portion of the symbolic mode clause. */
while (member (*s, "agou"))
- {
+ {
switch (c = *s++)
{
case 'u':
diff --git a/builtins/wait.def b/builtins/wait.def
index 2e3fac5..5154a77 100644
--- a/builtins/wait.def
+++ b/builtins/wait.def
@@ -66,21 +66,27 @@ procenv_t wait_intr_buf;
0. If a list of pids or job specs are given, return the exit status of
the last one waited for. */
-#define WAIT_RETURN(s) do { run_unwind_frame ("wait_builtin"); return (s); } while (0)
+#define WAIT_RETURN(s) \
+ do \
+ { \
+ interrupt_immediately = old_interrupt_immediately;\
+ return (s);\
+ } \
+ while (0)
int
wait_builtin (list)
WORD_LIST *list;
{
int status, code;
+ volatile int old_interrupt_immediately;
if (no_options (list))
return (EX_USAGE);
if (list != loptend)
list = loptend;
- begin_unwind_frame ("wait_builtin");
- unwind_protect_int (interrupt_immediately);
+ old_interrupt_immediately = interrupt_immediately;
interrupt_immediately++;
/* POSIX.2 says: When the shell is waiting (by means of the wait utility)