Bash-4.4 distribution sources and documentation
This commit is contained in:
parent
30a978b7d8
commit
a0c0a00fc4
588 changed files with 130746 additions and 80164 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
|
||||
#
|
||||
# Copyright (C) 1996-2009 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -36,7 +36,7 @@ EXEEXT = @EXEEXT@
|
|||
prefix = @prefix@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
VPATH = @srcdir@
|
||||
topdir = @top_srcdir@
|
||||
|
||||
datarootdir = @datarootdir@
|
||||
|
|
@ -45,6 +45,8 @@ includedir = @includedir@
|
|||
datadir = @datadir@
|
||||
localedir = @localedir@
|
||||
|
||||
loadablesdir = @loadablesdir@
|
||||
|
||||
# Support an alternate destination root directory for package building
|
||||
DESTDIR =
|
||||
|
||||
|
|
@ -375,31 +377,31 @@ mkbuiltins.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
|
|||
# def files
|
||||
alias.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
alias.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
|
||||
alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
|
||||
break.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
break.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
break.o: ../pathnames.h
|
||||
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)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
|
||||
builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
|
||||
builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
builtin.o: $(srcdir)/bashgetopt.h ../pathnames.h
|
||||
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)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.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 ../pathnames.h
|
||||
|
|
@ -408,41 +410,43 @@ cd.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose
|
|||
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 ../pathnames.h
|
||||
cd.o: $(topdir)/sig.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)/sig.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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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: $(topdir)/arrayfunc.h $(srcdir)/bashgetopt.h $(topdir)/flags.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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
|
||||
echo.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.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)/subst.h $(topdir)/externs.h $(topdir)/sig.h
|
||||
enable.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.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)/subst.h $(topdir)/externs.h $(topdir)/sig.h
|
||||
eval.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.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
|
||||
exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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
|
||||
|
|
@ -450,7 +454,7 @@ 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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
|
||||
exit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/jobs.h
|
||||
exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h ../pathnames.h
|
||||
|
|
@ -459,7 +463,7 @@ fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h
|
|||
fc.o: $(topdir)/bashhist.h
|
||||
fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
|
||||
fc.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
|
||||
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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
|
||||
|
|
@ -467,18 +471,18 @@ 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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
|
||||
fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
fg_bg.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
fg_bg.o: $(topdir)/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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
|
||||
getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
getopts.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
getopts.o: ../pathnames.h
|
||||
hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h
|
||||
hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h
|
||||
hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h $(topdir)/sig.h
|
||||
hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
hash.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
|
|
@ -488,12 +492,12 @@ 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 ../pathnames.h
|
||||
help.o: ${srcdir}/common.h $(topdir)/sig.h ../pathnames.h
|
||||
history.o: $(topdir)/bashtypes.h
|
||||
history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
|
||||
history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
|
||||
history.o: $(topdir)/subst.h $(topdir)/externs.h
|
||||
history.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.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
|
||||
|
|
@ -507,16 +511,16 @@ jobs.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(srcdir)/bashg
|
|||
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
|
||||
jobs.o: $(topdir)/sig.h ../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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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 ../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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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
|
||||
|
|
@ -527,11 +531,12 @@ 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: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.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)/subst.h $(topdir)/externs.h $(topdir)/sig.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
|
||||
|
|
@ -540,11 +545,12 @@ 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: $(BASHINCDIR)/shtty.h $(topdir)/sig.h
|
||||
read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
|
||||
return.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
return.o: ../pathnames.h
|
||||
|
|
@ -552,18 +558,18 @@ 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: $(BASHINCDIR)/maxpath.h $(topdir)/error.h $(topdir)/sig.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)/externs.h $(topdir)/flags.h $(topdir)/sig.h
|
||||
setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
setattr.o: $(topdir)/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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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
|
||||
|
|
@ -573,53 +579,53 @@ 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 $(topdir)/bashline.h
|
||||
shopt.o: $(topdir)/bashhist.h $(topdir)/bashline.h $(topdir)/sig.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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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 ../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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
|
||||
test.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
|
||||
test.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
|
||||
test.o: $(topdir)/test.h ../pathnames.h
|
||||
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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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 ../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)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.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 ../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)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
|
||||
type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
|
||||
type.o: $(topdir)/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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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 ../pathnames.h
|
||||
|
|
@ -628,19 +634,21 @@ 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: $(topdir)/jobs.h $(topdir)/sig.h
|
||||
wait.o: $(BASHINCDIR)/chartypes.h ../pathnames.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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
|
||||
complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
complete.o: ${topdir}/builtins.h
|
||||
complete.o: ${topdir}/builtins.h ${topdir}/general.h
|
||||
complete.o: ${topdir}/bashtypes.h ${BASHINCDIR}/chartypes.h ${topdir}/xmalloc.h
|
||||
complete.o: ${topdir}/pcomplete.h
|
||||
complete.o: ${srcdir}/common.h ${srcdir}/bashgetopt.h
|
||||
mapfile.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
|
||||
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)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.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 ../pathnames.h
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is alias.def, from which is created alias.c
|
||||
It implements the builtins "alias" and "unalias" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ A trailing space in VALUE causes the next word to be checked for
|
|||
alias substitution when the alias is expanded.
|
||||
|
||||
Options:
|
||||
-p Print all defined aliases in a reusable format
|
||||
-p print all defined aliases in a reusable format
|
||||
|
||||
Exit Status:
|
||||
alias returns true unless a NAME is supplied for which no alias has been
|
||||
|
|
@ -87,6 +87,7 @@ alias_builtin (list)
|
|||
pflag = 1;
|
||||
dflags |= AL_REUSABLE;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -160,7 +161,7 @@ $SHORT_DOC unalias [-a] name [name ...]
|
|||
Remove each NAME from the list of defined aliases.
|
||||
|
||||
Options:
|
||||
-a remove all alias definitions.
|
||||
-a remove all alias definitions
|
||||
|
||||
Return success unless a NAME is not an existing alias.
|
||||
$END
|
||||
|
|
@ -183,6 +184,7 @@ unalias_builtin (list)
|
|||
case 'a':
|
||||
aflag = 1;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -232,7 +234,7 @@ print_alias (alias, flags)
|
|||
|
||||
value = sh_single_quote (alias->value);
|
||||
if (flags & AL_REUSABLE)
|
||||
printf ("alias ");
|
||||
printf ("alias %s", (alias->name && alias->name[0] == '-') ? "-- " : "");
|
||||
printf ("%s=%s\n", alias->name, value);
|
||||
free (value);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "bashgetopt.h"
|
||||
|
||||
#define ISOPT(s) (((*(s) == '-') || (plus && *(s) == '+')) && (s)[1])
|
||||
#define NOTOPT(s) (((*(s) != '-') && (!plus || *(s) != '+')) || (s)[1] == '\0')
|
||||
|
||||
|
|
@ -76,6 +78,10 @@ char *opts;
|
|||
lhead = (WORD_LIST *)NULL;
|
||||
loptend = lcurrent;
|
||||
return(-1);
|
||||
} else if (ISHELP (lcurrent->word->word)) {
|
||||
lhead = (WORD_LIST *)NULL;
|
||||
loptend = lcurrent;
|
||||
return (GETOPT_HELP);
|
||||
} else if (lcurrent->word->word[0] == '-' &&
|
||||
lcurrent->word->word[1] == '-' &&
|
||||
lcurrent->word->word[2] == 0) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
#include <stdc.h>
|
||||
|
||||
#define GETOPT_EOF -1
|
||||
#define GETOPT_HELP -99
|
||||
|
||||
extern char *list_optarg;
|
||||
|
||||
extern int list_optopt;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is bind.def, from which is created bind.c.
|
||||
It implements the builtin "bind" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ Options:
|
|||
-f filename Read key bindings from FILENAME.
|
||||
-x keyseq:shell-command Cause SHELL-COMMAND to be executed when
|
||||
KEYSEQ is entered.
|
||||
-X List key sequences bound with -x and associated commands
|
||||
-X List key sequences bound with -x and associated commands
|
||||
in a form that can be reused as input.
|
||||
|
||||
Exit Status:
|
||||
|
|
@ -115,7 +115,7 @@ bind_builtin (list)
|
|||
int return_code;
|
||||
Keymap kmap, saved_keymap;
|
||||
int flags, opt;
|
||||
char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq;
|
||||
char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq, *t;
|
||||
|
||||
if (no_line_editing)
|
||||
{
|
||||
|
|
@ -129,7 +129,7 @@ bind_builtin (list)
|
|||
|
||||
kmap = saved_keymap = (Keymap) NULL;
|
||||
flags = 0;
|
||||
initfile = map_name = fun_name = unbind_name = remove_seq = (char *)NULL;
|
||||
initfile = map_name = fun_name = unbind_name = remove_seq = cmd_seq = (char *)NULL;
|
||||
return_code = EXECUTION_SUCCESS;
|
||||
|
||||
if (bash_readline_initialized == 0)
|
||||
|
|
@ -141,7 +141,7 @@ bind_builtin (list)
|
|||
rl_outstream = stdout;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "lvpVPsSXf:q:u:m:r:x:")) != EOF)
|
||||
while ((opt = internal_getopt (list, "lvpVPsSXf:q:u:m:r:x:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
|
|
@ -193,6 +193,7 @@ bind_builtin (list)
|
|||
case 'X':
|
||||
flags |= XXFLAG;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
BIND_RETURN (EX_USAGE);
|
||||
|
|
@ -248,7 +249,10 @@ bind_builtin (list)
|
|||
{
|
||||
if (rl_read_init_file (initfile) != 0)
|
||||
{
|
||||
builtin_error (_("%s: cannot read: %s"), initfile, strerror (errno));
|
||||
t = printable_filename (initfile, 0);
|
||||
builtin_error (_("%s: cannot read: %s"), t, strerror (errno));
|
||||
if (t != initfile)
|
||||
free (t);
|
||||
BIND_RETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ break_builtin (list)
|
|||
{
|
||||
intmax_t newbreak;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
if (check_loop_level () == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
|
|
@ -107,6 +109,8 @@ continue_builtin (list)
|
|||
{
|
||||
intmax_t newcont;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
if (check_loop_level () == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ caller_builtin (list)
|
|||
char *funcname_s, *source_s, *lineno_s;
|
||||
intmax_t num;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a);
|
||||
GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a);
|
||||
GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is cd.def, from which is created cd.c. It implements the
|
||||
builtins "cd" and "pwd" in Bash.
|
||||
|
||||
Copyright (C) 1987-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -93,16 +93,17 @@ the word is assumed to be a variable name. If that variable has a value,
|
|||
its value is used for DIR.
|
||||
|
||||
Options:
|
||||
-L force symbolic links to be followed: resolve symbolic links in
|
||||
DIR after processing instances of `..'
|
||||
-P use the physical directory structure without following symbolic
|
||||
links: resolve symbolic links in DIR before processing instances
|
||||
of `..'
|
||||
-e if the -P option is supplied, and the current working directory
|
||||
cannot be determined successfully, exit with a non-zero status
|
||||
-L force symbolic links to be followed: resolve symbolic
|
||||
links in DIR after processing instances of `..'
|
||||
-P use the physical directory structure without following
|
||||
symbolic links: resolve symbolic links in DIR before
|
||||
processing instances of `..'
|
||||
-e if the -P option is supplied, and the current working
|
||||
directory cannot be determined successfully, exit with
|
||||
a non-zero status
|
||||
#if defined (O_XATTR)
|
||||
-@ on systems that support it, present a file with extended attributes
|
||||
as a directory containing the file attributes
|
||||
-@ on systems that support it, present a file with extended
|
||||
attributes as a directory containing the file attributes
|
||||
#endif
|
||||
|
||||
The default is to follow symbolic links, as if `-L' were specified.
|
||||
|
|
@ -261,7 +262,7 @@ cd_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
char *dirname, *cdpath, *path, *temp;
|
||||
int path_index, no_symlinks, opt, lflag;
|
||||
int path_index, no_symlinks, opt, lflag, e;
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
if (restricted)
|
||||
|
|
@ -297,6 +298,7 @@ cd_builtin (list)
|
|||
xattrflag = 1;
|
||||
break;
|
||||
#endif
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -327,6 +329,13 @@ cd_builtin (list)
|
|||
builtin_error (_("too many arguments"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
else if (list->word->word[0] == '\0')
|
||||
{
|
||||
builtin_error (_("null directory"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
#endif
|
||||
else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
|
||||
{
|
||||
|
|
@ -436,7 +445,11 @@ cd_builtin (list)
|
|||
FREE (temp);
|
||||
}
|
||||
|
||||
builtin_error ("%s: %s", dirname, strerror (errno));
|
||||
e = errno;
|
||||
temp = printable_filename (dirname, 0);
|
||||
builtin_error ("%s: %s", temp, strerror (e));
|
||||
if (temp != dirname)
|
||||
free (temp);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -447,7 +460,7 @@ Print the name of the current working directory.
|
|||
|
||||
Options:
|
||||
-L print the value of $PWD if it names the current working
|
||||
directory
|
||||
directory
|
||||
-P print the physical directory, without any symbolic links
|
||||
|
||||
By default, `pwd' behaves as if `-L' were specified.
|
||||
|
|
@ -482,6 +495,7 @@ pwd_builtin (list)
|
|||
case 'L':
|
||||
verbatim_pwd = 0;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is command.def, from which is created command.c.
|
||||
It implements the builtin "command" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -30,10 +30,10 @@ information about the specified COMMANDs. Can be used to invoke commands
|
|||
on disk when a function with the same name exists.
|
||||
|
||||
Options:
|
||||
-p use a default value for PATH that is guaranteed to find all of
|
||||
the standard utilities
|
||||
-v print a description of COMMAND similar to the `type' builtin
|
||||
-V print a more verbose description of each COMMAND
|
||||
-p use a default value for PATH that is guaranteed to find all of
|
||||
the standard utilities
|
||||
-v print a description of COMMAND similar to the `type' builtin
|
||||
-V print a more verbose description of each COMMAND
|
||||
|
||||
Exit Status:
|
||||
Returns exit status of COMMAND, or failure if COMMAND is not found.
|
||||
|
|
@ -63,7 +63,6 @@ extern size_t confstr __P((int, char *, size_t));
|
|||
extern int subshell_environment;
|
||||
|
||||
static void restore_path __P((char *));
|
||||
static char *get_standard_path __P((void));
|
||||
|
||||
/* Run the commands mentioned in LIST without paying attention to shell
|
||||
functions. */
|
||||
|
|
@ -82,7 +81,7 @@ command_builtin (list)
|
|||
switch (opt)
|
||||
{
|
||||
case 'p':
|
||||
use_standard_path = 1;
|
||||
use_standard_path = CDESC_STDPATH;
|
||||
break;
|
||||
case 'V':
|
||||
verbose = CDESC_SHORTDESC|CDESC_ABSPATH; /* look in common.h for constants */
|
||||
|
|
@ -90,6 +89,7 @@ command_builtin (list)
|
|||
case 'v':
|
||||
verbose = CDESC_REUSABLE; /* ditto */
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -108,30 +108,13 @@ command_builtin (list)
|
|||
}
|
||||
#endif
|
||||
|
||||
begin_unwind_frame ("command_builtin");
|
||||
|
||||
if (use_standard_path)
|
||||
{
|
||||
old_path = get_string_value ("PATH");
|
||||
/* If old_path is NULL, $PATH is unset. If so, we want to make sure
|
||||
it's unset after this command completes. */
|
||||
if (old_path)
|
||||
old_path = savestring (old_path);
|
||||
add_unwind_protect ((Function *)restore_path, old_path);
|
||||
|
||||
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);
|
||||
found = describe_command (list->word->word, verbose|use_standard_path);
|
||||
|
||||
if (found == 0 && verbose != CDESC_REUSABLE)
|
||||
sh_notfound (list->word->word);
|
||||
|
|
@ -139,11 +122,12 @@ command_builtin (list)
|
|||
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)
|
||||
begin_unwind_frame ("command_builtin");
|
||||
|
||||
#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN | (use_standard_path ? CMD_STDPATH : 0))
|
||||
|
||||
/* 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. */
|
||||
|
|
@ -152,18 +136,7 @@ command_builtin (list)
|
|||
command->value.Simple->redirects = (REDIRECT *)NULL;
|
||||
command->flags |= COMMAND_BUILTIN_FLAGS;
|
||||
command->value.Simple->flags |= COMMAND_BUILTIN_FLAGS;
|
||||
#if 0
|
||||
/* This breaks for things like ( cd /tmp ; command z ababa ; echo next )
|
||||
or $(command echo a ; command echo b;) or even
|
||||
{ command echo a; command echo b; } & */
|
||||
/* If we're in a subshell, see if we can get away without forking
|
||||
again, since we've already forked to run this builtin. */
|
||||
if (subshell_environment)
|
||||
{
|
||||
command->flags |= CMD_NO_FORK;
|
||||
command->value.Simple->flags |= CMD_NO_FORK;
|
||||
}
|
||||
#endif
|
||||
|
||||
add_unwind_protect ((char *)dispose_command, command);
|
||||
result = execute_command (command);
|
||||
|
||||
|
|
@ -188,32 +161,3 @@ restore_path (var)
|
|||
|
||||
stupidly_hack_special_variables ("PATH");
|
||||
}
|
||||
|
||||
/* Return a value for PATH that is guaranteed to find all of the standard
|
||||
utilities. This uses Posix.2 configuration variables, if present. It
|
||||
uses a value defined in config.h as a last resort. */
|
||||
static char *
|
||||
get_standard_path ()
|
||||
{
|
||||
#if defined (_CS_PATH) && defined (HAVE_CONFSTR)
|
||||
char *p;
|
||||
size_t len;
|
||||
|
||||
len = (size_t)confstr (_CS_PATH, (char *)NULL, (size_t)0);
|
||||
if (len > 0)
|
||||
{
|
||||
p = (char *)xmalloc (len + 2);
|
||||
*p = '\0';
|
||||
confstr (_CS_PATH, p, len);
|
||||
return (p);
|
||||
}
|
||||
else
|
||||
return (savestring (STANDARD_UTILS_PATH));
|
||||
#else /* !_CS_PATH || !HAVE_CONFSTR */
|
||||
# if defined (CS_PATH)
|
||||
return (savestring (CS_PATH));
|
||||
# else
|
||||
return (savestring (STANDARD_UTILS_PATH));
|
||||
# endif /* !CS_PATH */
|
||||
#endif /* !_CS_PATH || !HAVE_CONFSTR */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* common.c - utility functions for all builtins */
|
||||
|
||||
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -70,6 +70,7 @@ extern int errno;
|
|||
extern int indirection_level, subshell_environment;
|
||||
extern int line_number;
|
||||
extern int last_command_exit_value;
|
||||
extern int trap_saved_exit_value;
|
||||
extern int running_trap;
|
||||
extern int posixly_correct;
|
||||
extern char *this_command_name, *shell_name;
|
||||
|
|
@ -175,9 +176,16 @@ int
|
|||
no_options (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int opt;
|
||||
|
||||
reset_internal_getopt ();
|
||||
if (internal_getopt (list, "") != -1)
|
||||
if ((opt = internal_getopt (list, "")) != -1)
|
||||
{
|
||||
if (opt == GETOPT_HELP)
|
||||
{
|
||||
builtin_help ();
|
||||
return (2);
|
||||
}
|
||||
builtin_usage ();
|
||||
return (1);
|
||||
}
|
||||
|
|
@ -234,7 +242,7 @@ sh_invalidnum (s)
|
|||
{
|
||||
char *msg;
|
||||
|
||||
if (*s == '0' && isdigit (s[1]))
|
||||
if (*s == '0' && isdigit ((unsigned char)s[1]))
|
||||
msg = _("invalid octal number");
|
||||
else if (*s == '0' && s[1] == 'x')
|
||||
msg = _("invalid hex number");
|
||||
|
|
@ -335,7 +343,9 @@ int
|
|||
sh_chkwrite (s)
|
||||
int s;
|
||||
{
|
||||
QUIT;
|
||||
fflush (stdout);
|
||||
QUIT;
|
||||
if (ferror (stdout))
|
||||
{
|
||||
sh_wrerror ();
|
||||
|
|
@ -403,6 +413,8 @@ remember_args (list, destructive)
|
|||
|
||||
if (destructive)
|
||||
set_dollar_vars_changed ();
|
||||
|
||||
invalidate_cached_quoted_dollar_at ();
|
||||
}
|
||||
|
||||
static int changed_dollar_vars;
|
||||
|
|
@ -494,7 +506,17 @@ get_exitstat (list)
|
|||
list = list->next;
|
||||
|
||||
if (list == 0)
|
||||
return (last_command_exit_value);
|
||||
{
|
||||
/* If we're not running the DEBUG trap, the return builtin, when not
|
||||
given any arguments, uses the value of $? before the trap ran. If
|
||||
given an argument, return uses it. This means that the trap can't
|
||||
change $?. The DEBUG trap gets to change $?, though, since that is
|
||||
part of its reason for existing, and because the extended debug mode
|
||||
does things with the return value. */
|
||||
if (this_shell_builtin == return_builtin && running_trap > 0 && running_trap != DEBUG_TRAP+1)
|
||||
return (trap_saved_exit_value);
|
||||
return (last_command_exit_value);
|
||||
}
|
||||
|
||||
arg = list->word->word;
|
||||
if (arg == 0 || legal_number (arg, &sval) == 0)
|
||||
|
|
@ -888,3 +910,11 @@ initialize_shell_builtins ()
|
|||
qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
|
||||
(QSFUNC *)shell_builtin_compare);
|
||||
}
|
||||
|
||||
#if !defined (HELP_BUILTIN)
|
||||
void
|
||||
builtin_help ()
|
||||
{
|
||||
printf ("%s: %s\n", this_command_name, _("help not available in this version"));
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* common.h -- extern declarations for functions defined in common.c. */
|
||||
|
||||
/* Copyright (C) 1993-2010 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -24,6 +24,21 @@
|
|||
#include "stdc.h"
|
||||
|
||||
#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c)
|
||||
#define ISHELP(s) (STREQ ((s), "--help"))
|
||||
|
||||
#define CHECK_HELPOPT(l) \
|
||||
do { \
|
||||
if ((l) && (l)->word && ISHELP((l)->word->word)) \
|
||||
{ \
|
||||
builtin_help (); \
|
||||
return (EX_USAGE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CASE_HELPOPT \
|
||||
case GETOPT_HELP: \
|
||||
builtin_help (); \
|
||||
return (EX_USAGE)
|
||||
|
||||
/* Flag values for parse_and_execute () */
|
||||
#define SEVAL_NONINT 0x001
|
||||
|
|
@ -35,6 +50,7 @@
|
|||
#define SEVAL_NOLONGJMP 0x040
|
||||
#define SEVAL_FUNCDEF 0x080 /* only allow function definitions */
|
||||
#define SEVAL_ONECMD 0x100 /* only allow a single command */
|
||||
#define SEVAL_NOHISTEXP 0x200 /* inhibit history expansion */
|
||||
|
||||
/* Flags for describe_command, shared between type.def and command.def */
|
||||
#define CDESC_ALL 0x001 /* type -a */
|
||||
|
|
@ -45,6 +61,7 @@
|
|||
#define CDESC_FORCE_PATH 0x020 /* type -ap or type -P */
|
||||
#define CDESC_NOFUNCS 0x040 /* type -f */
|
||||
#define CDESC_ABSPATH 0x080 /* convert to absolute path, no ./ */
|
||||
#define CDESC_STDPATH 0x100 /* command -p */
|
||||
|
||||
/* Flags for get_job_by_name */
|
||||
#define JM_PREFIX 0x01 /* prefix of job name */
|
||||
|
|
@ -59,6 +76,9 @@
|
|||
#define ARGS_FUNC 0x02
|
||||
#define ARGS_SETBLTIN 0x04
|
||||
|
||||
/* Maximum number of attribute letters */
|
||||
#define MAX_ATTRIBUTES 16
|
||||
|
||||
/* Functions from common.c */
|
||||
extern void builtin_error __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
extern void builtin_warning __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
|
|
@ -122,6 +142,9 @@ extern void bash_logout __P((void));
|
|||
/* Functions from getopts.def */
|
||||
extern void getopts_reset __P((int));
|
||||
|
||||
/* Functions from help.def */
|
||||
extern void builtin_help __P((void));
|
||||
|
||||
/* Functions from read.def */
|
||||
extern void read_tty_cleanup __P((void));
|
||||
extern int read_tty_modified __P((void));
|
||||
|
|
@ -138,6 +161,9 @@ extern void initialize_shell_options __P((int));
|
|||
|
||||
extern void reset_shell_options __P((void));
|
||||
|
||||
extern char *get_current_options __P((void));
|
||||
extern void set_current_options __P((const char *));
|
||||
|
||||
/* Functions from shopt.def */
|
||||
extern void reset_shopt_options __P((void));
|
||||
extern char **get_shopt_options __P((void));
|
||||
|
|
@ -163,6 +189,7 @@ extern int show_var_attributes __P((SHELL_VAR *, int, int));
|
|||
extern int show_name_attributes __P((char *, int));
|
||||
extern int show_func_attributes __P((char *, int));
|
||||
extern void set_var_attribute __P((char *, int, int));
|
||||
extern int var_attribute_string __P((SHELL_VAR *, int, char *));
|
||||
|
||||
/* Functions from pushd.def */
|
||||
extern char *get_dirstack_from_string __P((char *));
|
||||
|
|
@ -175,9 +202,12 @@ extern int parse_and_execute __P((char *, const char *, int));
|
|||
extern int evalstring __P((char *, const char *, int));
|
||||
extern void parse_and_execute_cleanup __P((void));
|
||||
extern int parse_string __P((char *, const char *, int, char **));
|
||||
extern int should_suppress_fork __P((COMMAND *));
|
||||
extern void optimize_fork __P((COMMAND *));
|
||||
|
||||
/* Functions from evalfile.c */
|
||||
extern int maybe_execute_file __P((const char *, int));
|
||||
extern int force_execute_file __P((const char *, int));
|
||||
extern int source_file __P((const char *, int));
|
||||
extern int fc_execute_file __P((const char *));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is complete.def, from which is created complete.c.
|
||||
It implements the builtins "complete", "compgen", and "compopt" in Bash.
|
||||
|
||||
Copyright (C) 1999-2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -33,11 +33,11 @@ allows them to be reused as input.
|
|||
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
|
||||
NAMEs are supplied, all completion specifications
|
||||
-D apply the completions and actions as the default for commands
|
||||
without any specific completion defined
|
||||
without any specific completion defined
|
||||
-E apply the completions and actions to "empty" commands --
|
||||
completion attempted on a blank line
|
||||
completion attempted on a blank line
|
||||
|
||||
When completion is attempted, the actions are applied in the order the
|
||||
uppercase-letter options are listed above. The -D option takes
|
||||
|
|
@ -138,6 +138,7 @@ static const struct _compopt {
|
|||
{ "dirnames", COPT_DIRNAMES },
|
||||
{ "filenames",COPT_FILENAMES},
|
||||
{ "noquote", COPT_NOQUOTE },
|
||||
{ "nosort", COPT_NOSORT },
|
||||
{ "nospace", COPT_NOSPACE },
|
||||
{ "plusdirs", COPT_PLUSDIRS },
|
||||
{ (char *)NULL, 0 },
|
||||
|
|
@ -170,7 +171,7 @@ find_compopt (name)
|
|||
/* 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
|
||||
bitmap 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
|
||||
|
|
@ -324,6 +325,7 @@ build_actions (list, flagp, actp, optp)
|
|||
case 'X':
|
||||
Xarg = list_optarg;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -653,7 +655,7 @@ print_cmd_completions (list)
|
|||
$BUILTIN compgen
|
||||
$DEPENDS_ON PROGRAMMABLE_COMPLETION
|
||||
$FUNCTION compgen_builtin
|
||||
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
|
||||
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
|
||||
Display possible completions depending on the options.
|
||||
|
||||
Intended to be used from within a shell function generating possible
|
||||
|
|
@ -790,7 +792,7 @@ compopt_builtin (list)
|
|||
ret = EXECUTION_SUCCESS;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "+o:DE")) != EOF)
|
||||
while ((opt = internal_getopt (list, "+o:DE")) != -1)
|
||||
{
|
||||
opts = (list_opttype == '-') ? &opts_on : &opts_off;
|
||||
|
||||
|
|
@ -811,6 +813,7 @@ compopt_builtin (list)
|
|||
case 'E':
|
||||
Eflag = 1;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -867,5 +870,8 @@ compopt_builtin (list)
|
|||
pcomp_set_compspec_options (cs, opts_off, 0);
|
||||
}
|
||||
|
||||
if (wl)
|
||||
dispose_words (wl);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is declare.def, from which is created declare.c.
|
||||
It implements the builtins "declare" and "local" in Bash.
|
||||
|
||||
Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -31,9 +31,9 @@ display the attributes and values of all variables.
|
|||
Options:
|
||||
-f restrict action or display to function names and definitions
|
||||
-F restrict display to function names only (plus line number and
|
||||
source file when debugging)
|
||||
source file when debugging)
|
||||
-g create global variables when used in a shell function; otherwise
|
||||
ignored
|
||||
ignored
|
||||
-p display the attributes and value of each NAME
|
||||
|
||||
Options which set attributes:
|
||||
|
|
@ -62,10 +62,10 @@ $END
|
|||
|
||||
$BUILTIN typeset
|
||||
$FUNCTION declare_builtin
|
||||
$SHORT_DOC typeset [-aAfFgilrtux] [-p] name[=value] ...
|
||||
$SHORT_DOC typeset [-aAfFgilnrtux] [-p] name[=value] ...
|
||||
Set variable values and attributes.
|
||||
|
||||
Obsolete. See `help declare'.
|
||||
A synonym for `declare'. See `help declare'.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
|
@ -83,6 +83,7 @@ $END
|
|||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../flags.h"
|
||||
#include "common.h"
|
||||
#include "builtext.h"
|
||||
#include "bashgetopt.h"
|
||||
|
|
@ -149,10 +150,12 @@ declare_internal (list, local_var)
|
|||
flags_on = flags_off = any_failed = assign_error = pflag = nodefs = mkglobal = 0;
|
||||
refvar = (SHELL_VAR *)NULL;
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, DECLARE_OPTS)) != EOF)
|
||||
while ((opt = internal_getopt (list, DECLARE_OPTS)) != -1)
|
||||
{
|
||||
flags = list_opttype == '+' ? &flags_off : &flags_on;
|
||||
|
||||
/* If you add options here, see whether or not they need to be added to
|
||||
the loop in subst.c:shell_expand_word_list() */
|
||||
switch (opt)
|
||||
{
|
||||
case 'a':
|
||||
|
|
@ -221,6 +224,7 @@ declare_internal (list, local_var)
|
|||
flags_off |= att_capcase|att_lowercase;
|
||||
break;
|
||||
#endif /* CASEMOD_ATTRS */
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -282,15 +286,28 @@ declare_internal (list, local_var)
|
|||
/* There are arguments left, so we are making variables. */
|
||||
while (list) /* declare [-aAfFirx] name [name ...] */
|
||||
{
|
||||
char *value, *name;
|
||||
int offset, aflags;
|
||||
char *value, *name, *oldname;
|
||||
int offset, aflags, wflags, created_var, namelen;
|
||||
#if defined (ARRAY_VARS)
|
||||
int making_array_special, compound_array_assign, simple_array_assign;
|
||||
int var_exists, array_exists, creating_array, array_subscript_assignment;
|
||||
#endif
|
||||
|
||||
name = savestring (list->word->word);
|
||||
wflags = list->word->flags;
|
||||
offset = assignment (name, 0);
|
||||
aflags = 0;
|
||||
created_var = 0;
|
||||
|
||||
if (local_var && variable_context && STREQ (name, "-"))
|
||||
{
|
||||
var = make_local_variable ("-");
|
||||
FREE (value_cell (var)); /* just in case */
|
||||
value = get_current_options ();
|
||||
var_setvalue (var, value);
|
||||
VSETATTR (var, att_invisible);
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
||||
if (offset) /* declare [-aAfFirx] name=value */
|
||||
{
|
||||
|
|
@ -309,8 +326,8 @@ declare_internal (list, local_var)
|
|||
that is specific to nameref variables. */
|
||||
if (flags_on & att_nameref)
|
||||
{
|
||||
#if defined (ARRAY_VARIABLES)
|
||||
if (valid_array_reference (name))
|
||||
#if defined (ARRAY_VARS)
|
||||
if (valid_array_reference (name, 0))
|
||||
{
|
||||
builtin_error (_("%s: reference variable cannot be an array"), name);
|
||||
assign_error++;
|
||||
|
|
@ -318,22 +335,39 @@ declare_internal (list, local_var)
|
|||
}
|
||||
else
|
||||
#endif
|
||||
/* disallow self references at global scope */
|
||||
if (STREQ (name, value) && variable_context == 0)
|
||||
/* disallow self references at global scope, warn at function scope */
|
||||
if (check_selfref (name, value, 0))
|
||||
{
|
||||
builtin_error (_("%s: nameref variable self references not allowed"), name);
|
||||
if (variable_context == 0)
|
||||
{
|
||||
builtin_error (_("%s: nameref variable self references not allowed"), name);
|
||||
assign_error++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
else
|
||||
builtin_warning (_("%s: circular name reference"), name);
|
||||
}
|
||||
#if 1
|
||||
if (value && *value && (aflags & ASS_APPEND) == 0 && valid_nameref_value (value, 1) == 0)
|
||||
{
|
||||
builtin_error (_("`%s': invalid variable name for name reference"), value);
|
||||
assign_error++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
restart_new_var_name:
|
||||
#if defined (ARRAY_VARS)
|
||||
var_exists = array_exists = creating_array = 0;
|
||||
compound_array_assign = simple_array_assign = 0;
|
||||
array_subscript_assignment = 0;
|
||||
subscript_start = (char *)NULL;
|
||||
if (t = strchr (name, '[')) /* ] */
|
||||
{
|
||||
/* If offset != 0 we have already validated any array reference */
|
||||
if (offset == 0 && valid_array_reference (name) == 0)
|
||||
/* If offset != 0 we have already validated any array reference
|
||||
because assignment() calls skipsubscript() */
|
||||
if (offset == 0 && valid_array_reference (name, 0) == 0)
|
||||
{
|
||||
sh_invalidid (name);
|
||||
assign_error++;
|
||||
|
|
@ -341,7 +375,8 @@ declare_internal (list, local_var)
|
|||
}
|
||||
subscript_start = t;
|
||||
*t = '\0';
|
||||
making_array_special = 1;
|
||||
making_array_special = 1; /* XXX - should this check offset? */
|
||||
array_subscript_assignment = offset != 0;
|
||||
}
|
||||
else
|
||||
making_array_special = 0;
|
||||
|
|
@ -368,6 +403,7 @@ declare_internal (list, local_var)
|
|||
refvar = (SHELL_VAR *)NULL;
|
||||
if (variable_context && mkglobal == 0 && ((flags_on & att_function) == 0))
|
||||
{
|
||||
/* check name for validity here? */
|
||||
#if defined (ARRAY_VARS)
|
||||
if (flags_on & att_assoc)
|
||||
var = make_local_assoc_variable (name);
|
||||
|
|
@ -375,12 +411,41 @@ declare_internal (list, local_var)
|
|||
var = make_local_array_variable (name, making_array_special);
|
||||
else
|
||||
#endif
|
||||
if (offset == 0 && (flags_on & att_nameref))
|
||||
{
|
||||
/* First look for refvar at current scope */
|
||||
refvar = find_variable_last_nameref (name, 1);
|
||||
var = find_variable (name);
|
||||
/* VARIABLE_CONTEXT != 0, so we are attempting to create or modify
|
||||
the attributes for a local variable at the same scope. If we've
|
||||
used a reference from a previous context to resolve VAR, we
|
||||
want to throw REFVAR and VAR away and create a new local var. */
|
||||
if (refvar && refvar->context != variable_context)
|
||||
{
|
||||
refvar = 0;
|
||||
var = make_local_variable (name);
|
||||
}
|
||||
else if (refvar && refvar->context == variable_context)
|
||||
var = refvar;
|
||||
/* Maybe we just want to create a new local variable */
|
||||
else if (var == 0 || var->context != variable_context)
|
||||
var = make_local_variable (name);
|
||||
/* otherwise we have a var at the right context */
|
||||
}
|
||||
else
|
||||
/* XXX - check name for validity here with valid_nameref_value */
|
||||
var = make_local_variable (name); /* sets att_invisible for new vars */
|
||||
if (var == 0)
|
||||
{
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
if (var && nameref_p (var) && readonly_p (var) && nameref_cell (var) && (flags_off & att_nameref))
|
||||
{
|
||||
sh_readonly (name);
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
}
|
||||
else
|
||||
var = (SHELL_VAR *)NULL;
|
||||
|
|
@ -444,18 +509,33 @@ declare_internal (list, local_var)
|
|||
NEXT_VARIABLE ();
|
||||
}
|
||||
}
|
||||
else /* declare -[aAirx] name [name...] */
|
||||
else /* declare -[aAinrx] name [name...] */
|
||||
{
|
||||
/* Non-null if we just created or fetched a local variable. */
|
||||
#if 0
|
||||
/* This is bash-4.3 code. */
|
||||
/* Here's what ksh93 seems to do. If we are modifying an existing
|
||||
nameref variable, we don't follow the nameref chain past the last
|
||||
nameref, and we set the nameref variable's value so future
|
||||
references to that variable will return the value of the variable
|
||||
we're assigning right now. */
|
||||
#else
|
||||
/* Here's what ksh93 seems to do as of the 2012 version: if we are
|
||||
using declare -n to modify the value of an existing nameref
|
||||
variable, don't follow the nameref chain at all and just search
|
||||
for a nameref at the current context. If we have a nameref,
|
||||
modify its value (changing which variable it references). */
|
||||
#endif
|
||||
if (var == 0 && (flags_on & att_nameref))
|
||||
{
|
||||
#if 0
|
||||
/* See if we are trying to modify an existing nameref variable */
|
||||
var = mkglobal ? find_global_variable_last_nameref (name) : find_variable_last_nameref (name);
|
||||
var = mkglobal ? find_global_variable_last_nameref (name, 1) : find_variable_last_nameref (name, 1);
|
||||
#else
|
||||
/* See if we are trying to modify an existing nameref variable,
|
||||
but don't follow the nameref chain. */
|
||||
var = mkglobal ? find_global_variable_noref (name) : find_variable_noref (name);
|
||||
#endif
|
||||
if (var && nameref_p (var) == 0)
|
||||
var = 0;
|
||||
}
|
||||
|
|
@ -467,41 +547,137 @@ declare_internal (list, local_var)
|
|||
else if (var == 0 && (flags_off & att_nameref))
|
||||
{
|
||||
/* See if we are trying to modify an existing nameref variable */
|
||||
refvar = mkglobal ? find_global_variable_last_nameref (name) : find_variable_last_nameref (name);
|
||||
refvar = mkglobal ? find_global_variable_last_nameref (name, 0) : find_variable_last_nameref (name, 0);
|
||||
if (refvar && nameref_p (refvar) == 0)
|
||||
refvar = 0;
|
||||
/* If the nameref is readonly but doesn't have a value, ksh93
|
||||
allows the nameref attribute to be removed. If it's readonly
|
||||
and has a value, even if the value doesn't reference an
|
||||
existing variable, we disallow the modification */
|
||||
if (refvar && nameref_cell (refvar) && readonly_p (refvar))
|
||||
{
|
||||
sh_readonly (name);
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
if (refvar)
|
||||
var = mkglobal ? find_global_variable (nameref_cell (refvar)) : find_variable (nameref_cell (refvar));
|
||||
}
|
||||
#if defined (ARRAY_VARS)
|
||||
/* If we have an array assignment to a nameref, remove the nameref
|
||||
attribute and go on. */
|
||||
else if (var == 0 && offset && array_subscript_assignment)
|
||||
{
|
||||
var = mkglobal ? find_global_variable_noref (name) : find_variable_noref (name);
|
||||
if (var && nameref_p (var))
|
||||
{
|
||||
internal_warning (_("%s: removing nameref attribute"), name);
|
||||
FREE (value_cell (var)); /* XXX - bash-4.3 compat */
|
||||
var_setvalue (var, (char *)NULL);
|
||||
VUNSETATTR (var, att_nameref);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* See if we are trying to set flags or value for an existing nameref
|
||||
that points to a non-existent variable: e.g.,
|
||||
declare -n foo=bar
|
||||
unset foo # unsets bar
|
||||
declare -i foo
|
||||
foo=4+4
|
||||
declare -p foo */
|
||||
if (var == 0 && (flags_on || flags_off || offset))
|
||||
{
|
||||
refvar = mkglobal ? find_global_variable_last_nameref (name, 0) : find_variable_last_nameref (name, 0);
|
||||
if (refvar && nameref_p (refvar) == 0)
|
||||
refvar = 0;
|
||||
if (refvar)
|
||||
var = mkglobal ? find_global_variable (nameref_cell (refvar)) : find_variable (nameref_cell (refvar));
|
||||
if (refvar && var == 0)
|
||||
{
|
||||
oldname = name; /* need to free this */
|
||||
|
||||
namelen = strlen (nameref_cell (refvar));
|
||||
#if defined (ARRAY_VARS)
|
||||
if (subscript_start)
|
||||
{
|
||||
*subscript_start = '['; /*]*/
|
||||
namelen += strlen (subscript_start);
|
||||
}
|
||||
#endif
|
||||
name = xmalloc (namelen + 2 + strlen (value) + 1);
|
||||
strcpy (name, nameref_cell (refvar));
|
||||
#if defined (ARRAY_VARS)
|
||||
if (subscript_start)
|
||||
strcpy (name + strlen (nameref_cell (refvar)), subscript_start);
|
||||
#endif
|
||||
/* We are committed to using the new name, so reset */
|
||||
if (offset)
|
||||
{
|
||||
/* Rebuild assignment and restore offset and value */
|
||||
if (aflags & ASS_APPEND)
|
||||
name[namelen++] = '+';
|
||||
name[namelen++] = '=';
|
||||
if (value && *value)
|
||||
strcpy (name + namelen, value);
|
||||
else
|
||||
name[namelen] = '\0';
|
||||
offset = assignment (name, 0);
|
||||
/* if offset was valid previously, but the substituting
|
||||
of the nameref value results in an invalid assignment,
|
||||
throw an invalid identifier error */
|
||||
if (offset == 0)
|
||||
{
|
||||
free (oldname);
|
||||
sh_invalidid (name);
|
||||
assign_error++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
name[offset] = '\0';
|
||||
value = name + namelen;
|
||||
}
|
||||
free (oldname);
|
||||
goto restart_new_var_name;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
if (var == 0)
|
||||
var = mkglobal ? find_global_variable (name) : find_variable (name);
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
var_exists = var != 0;
|
||||
array_exists = var && (array_p (var) || assoc_p (var));
|
||||
creating_array = flags_on & (att_array|att_assoc);
|
||||
#endif
|
||||
|
||||
if (var == 0)
|
||||
{
|
||||
#if defined (ARRAY_VARS)
|
||||
if (flags_on & att_assoc)
|
||||
{
|
||||
var = make_new_assoc_variable (name);
|
||||
if (offset == 0)
|
||||
if (var && offset == 0 && no_invisible_vars == 0)
|
||||
VSETATTR (var, att_invisible);
|
||||
}
|
||||
else if ((flags_on & att_array) || making_array_special)
|
||||
{
|
||||
var = make_new_array_variable (name);
|
||||
if (offset == 0)
|
||||
if (var && offset == 0 && no_invisible_vars == 0)
|
||||
VSETATTR (var, att_invisible);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
if (offset)
|
||||
var = mkglobal ? bind_global_variable (name, "", 0) : bind_variable (name, "", 0);
|
||||
else
|
||||
{
|
||||
var = mkglobal ? bind_global_variable (name, (char *)NULL, 0) : bind_variable (name, (char *)NULL, 0);
|
||||
VSETATTR (var, att_invisible);
|
||||
var = mkglobal ? bind_global_variable (name, (char *)NULL, ASS_FORCE) : bind_variable (name, (char *)NULL, ASS_FORCE);
|
||||
if (var && offset == 0 && no_invisible_vars == 0)
|
||||
VSETATTR (var, att_invisible);
|
||||
}
|
||||
if (var == 0)
|
||||
{
|
||||
/* Has to appear in brackets */
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
created_var = 1;
|
||||
}
|
||||
/* Can't take an existing array variable and make it a nameref */
|
||||
else if ((array_p (var) || assoc_p (var)) && (flags_on & att_nameref))
|
||||
|
|
@ -510,8 +686,30 @@ declare_internal (list, local_var)
|
|||
assign_error++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
else if (nameref_p (var) && (flags_on & att_nameref) == 0 && (flags_off & att_nameref) == 0 && offset && valid_nameref_value (value, 1) == 0)
|
||||
{
|
||||
builtin_error (_("`%s': invalid variable name for name reference"), value);
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
else if (flags_on & att_nameref)
|
||||
{
|
||||
#if 1
|
||||
/* Check of offset is to allow an assignment to a nameref var as
|
||||
part of the declare word to override existing value */
|
||||
if (nameref_p (var) == 0 && var_isset (var) && offset == 0 && valid_nameref_value (value_cell (var), 0) == 0)
|
||||
{
|
||||
builtin_error (_("`%s': invalid variable name for name reference"), value_cell (var));
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
#endif
|
||||
if (readonly_p (var))
|
||||
{
|
||||
sh_readonly (name);
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
/* ksh93 compat: turning on nameref attribute turns off -ilu */
|
||||
VUNSETATTR (var, att_integer|att_uppercase|att_lowercase|att_capcase);
|
||||
}
|
||||
|
|
@ -519,7 +717,7 @@ declare_internal (list, local_var)
|
|||
/* Cannot use declare +r to turn off readonly attribute. */
|
||||
if (readonly_p (var) && (flags_off & att_readonly))
|
||||
{
|
||||
sh_readonly (name);
|
||||
sh_readonly (name_cell (var));
|
||||
any_failed++;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
|
@ -535,12 +733,28 @@ declare_internal (list, local_var)
|
|||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if ((making_array_special || (flags_on & (att_array|att_assoc)) || array_p (var) || assoc_p (var)) && offset)
|
||||
/* make declare a[2]=foo as similar to a[2]=foo as possible if
|
||||
a is already an array or assoc variable. */
|
||||
if (array_subscript_assignment && array_exists && creating_array == 0)
|
||||
simple_array_assign = 1;
|
||||
else if ((making_array_special || creating_array || array_exists) && offset)
|
||||
{
|
||||
int vlen;
|
||||
vlen = STRLEN (value);
|
||||
|
||||
if (value[0] == '(' && value[vlen-1] == ')')
|
||||
/*itrace("declare_builtin: name = %s value = %s flags = %d", name, value, wflags);*/
|
||||
if (shell_compatibility_level > 43 && (wflags & W_COMPASSIGN) == 0 &&
|
||||
value[0] == '(' && value[vlen-1] == ')')
|
||||
{
|
||||
/* The warning is only printed when using compound assignment
|
||||
to an array variable that doesn't already exist. We use
|
||||
creating_array to allow things like
|
||||
declare -a foo$bar='(abc)' to work. */
|
||||
if (array_exists == 0 && creating_array == 0)
|
||||
internal_warning (_("%s: quoted compound array assignment deprecated"), list->word->word);
|
||||
compound_array_assign = array_exists || creating_array;
|
||||
simple_array_assign = making_array_special;
|
||||
}
|
||||
else if (value[0] == '(' && value[vlen-1] == ')' && (shell_compatibility_level < 44 || (wflags & W_COMPASSIGN)))
|
||||
compound_array_assign = 1;
|
||||
else
|
||||
simple_array_assign = 1;
|
||||
|
|
@ -604,12 +818,13 @@ declare_internal (list, local_var)
|
|||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (offset && compound_array_assign)
|
||||
assign_array_var_from_string (var, value, aflags);
|
||||
assign_array_var_from_string (var, value, aflags|ASS_FORCE);
|
||||
else if (simple_array_assign && subscript_start)
|
||||
{
|
||||
/* declare [-aA] name[N]=value */
|
||||
*subscript_start = '['; /* ] */
|
||||
var = assign_array_element (name, value, 0); /* XXX - not aflags */
|
||||
/* XXX - problem here with appending */
|
||||
var = assign_array_element (name, value, aflags&ASS_APPEND); /* XXX - not aflags */
|
||||
*subscript_start = '\0';
|
||||
if (var == 0) /* some kind of assignment error */
|
||||
{
|
||||
|
|
@ -623,25 +838,30 @@ declare_internal (list, local_var)
|
|||
{
|
||||
/* let bind_{array,assoc}_variable take care of this. */
|
||||
if (assoc_p (var))
|
||||
bind_assoc_variable (var, name, savestring ("0"), value, aflags);
|
||||
bind_assoc_variable (var, name, savestring ("0"), value, aflags|ASS_FORCE);
|
||||
else
|
||||
bind_array_variable (name, 0, value, aflags);
|
||||
bind_array_variable (name, 0, value, aflags|ASS_FORCE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
/* XXX - no ASS_FORCE here */
|
||||
/* bind_variable_value duplicates the essential internals of
|
||||
bind_variable() */
|
||||
if (offset)
|
||||
{
|
||||
if (onref)
|
||||
if (onref || nameref_p (var))
|
||||
aflags |= ASS_NAMEREF;
|
||||
v = bind_variable_value (var, value, aflags);
|
||||
if (v == 0 && onref)
|
||||
if (v == 0 && (onref || nameref_p (var)))
|
||||
{
|
||||
sh_invalidid (value);
|
||||
if (valid_nameref_value (value, 1) == 0)
|
||||
sh_invalidid (value);
|
||||
assign_error++;
|
||||
/* XXX - unset this variable? or leave it as normal var? */
|
||||
delete_var (var->name, mkglobal ? global_variables : shell_variables);
|
||||
if (created_var)
|
||||
delete_var (var->name, mkglobal ? global_variables : shell_variables);
|
||||
flags_on |= onref; /* undo change from above */
|
||||
flags_off |= offref;
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
}
|
||||
|
|
@ -681,9 +901,16 @@ declare_internal (list, local_var)
|
|||
flags_on |= onref;
|
||||
VUNSETATTR (var, offref);
|
||||
flags_off |= offref;
|
||||
/* Yuck. ksh93 compatibility */
|
||||
/* Yuck. ksh93 compatibility. XXX - need to investigate more but
|
||||
definitely happens when turning off nameref attribute on nameref
|
||||
(see comments above). Under no circumstances allow this to turn
|
||||
off readonly attribute on readonly nameref variable. */
|
||||
if (refvar)
|
||||
VUNSETATTR (refvar, flags_off);
|
||||
{
|
||||
if (flags_off & att_readonly)
|
||||
flags_off &= ~att_readonly;
|
||||
VUNSETATTR (refvar, flags_off);
|
||||
}
|
||||
|
||||
stupidly_hack_special_variables (name);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is echo.def, from which is created echo.c.
|
||||
It implements the builtin "echo" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -59,9 +59,9 @@ Options:
|
|||
\v vertical tab
|
||||
\\ backslash
|
||||
\0nnn the character whose ASCII code is NNN (octal). NNN can be
|
||||
0 to 3 octal digits
|
||||
0 to 3 octal digits
|
||||
\xHH the eight-bit character whose value is HH (hexadecimal). HH
|
||||
can be one or two hex digits
|
||||
can be one or two hex digits
|
||||
|
||||
Exit Status:
|
||||
Returns success unless a write error occurs.
|
||||
|
|
@ -161,7 +161,6 @@ just_echo:
|
|||
|
||||
clearerr (stdout); /* clear error before writing and testing success */
|
||||
|
||||
terminate_immediately++;
|
||||
while (list)
|
||||
{
|
||||
i = len = 0;
|
||||
|
|
@ -180,6 +179,7 @@ just_echo:
|
|||
fflush (stdout); /* Fix for bug in SunOS 5.5 printf(3) */
|
||||
#endif
|
||||
}
|
||||
QUIT;
|
||||
if (do_v9 && temp)
|
||||
free (temp);
|
||||
list = list->next;
|
||||
|
|
@ -190,11 +190,11 @@ just_echo:
|
|||
}
|
||||
if (list)
|
||||
putchar(' ');
|
||||
QUIT;
|
||||
}
|
||||
|
||||
if (display_return)
|
||||
putchar ('\n');
|
||||
|
||||
terminate_immediately--;
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is enable.def, from which is created enable.c.
|
||||
It implements the builtin "enable" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -66,6 +66,7 @@ $END
|
|||
#include "../flags.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
#include "findcmd.h"
|
||||
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
# include "../pcomplete.h"
|
||||
|
|
@ -92,6 +93,11 @@ static void delete_builtin __P((struct builtin *));
|
|||
static int local_dlclose __P((void *));
|
||||
#endif
|
||||
|
||||
#define STRUCT_SUFFIX "_struct"
|
||||
/* for now */
|
||||
#define LOAD_SUFFIX "_builtin_load"
|
||||
#define UNLOAD_SUFFIX "_builtin_unload"
|
||||
|
||||
static void list_some_builtins __P((int));
|
||||
static int enable_shell_command __P((char *, int));
|
||||
|
||||
|
|
@ -145,6 +151,7 @@ enable_builtin (list)
|
|||
builtin_error (_("dynamic loading not available"));
|
||||
return (EX_USAGE);
|
||||
#endif /* HAVE_DLCLOSE */
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -290,9 +297,11 @@ dyn_load_builtin (list, flags, filename)
|
|||
WORD_LIST *l;
|
||||
void *handle;
|
||||
|
||||
int total, size, new, replaced;
|
||||
char *struct_name, *name;
|
||||
int total, size, new, replaced, r;
|
||||
char *struct_name, *name, *funcname;
|
||||
sh_load_func_t *loadfunc;
|
||||
struct builtin **new_builtins, *b, *new_shell_builtins, *old_builtin;
|
||||
char *loadables_path, *load_path;
|
||||
|
||||
if (list == 0)
|
||||
return (EXECUTION_FAILURE);
|
||||
|
|
@ -301,15 +310,39 @@ dyn_load_builtin (list, flags, filename)
|
|||
#define RTLD_LAZY 1
|
||||
#endif
|
||||
|
||||
handle = 0;
|
||||
if (absolute_program (filename) == 0)
|
||||
{
|
||||
loadables_path = get_string_value ("BASH_LOADABLES_PATH");
|
||||
if (loadables_path)
|
||||
{
|
||||
load_path = find_in_path (filename, loadables_path, FS_NODIRS|FS_EXEC_PREFERRED);
|
||||
if (load_path)
|
||||
{
|
||||
#if defined (_AIX)
|
||||
handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen (load_path, RTLD_NOW|RTLD_GLOBAL);
|
||||
#else
|
||||
handle = dlopen (filename, RTLD_LAZY);
|
||||
handle = dlopen (load_path, RTLD_LAZY);
|
||||
#endif /* !_AIX */
|
||||
free (load_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fall back to current directory for now */
|
||||
if (handle == 0)
|
||||
#if defined (_AIX)
|
||||
handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL);
|
||||
#else
|
||||
handle = dlopen (filename, RTLD_LAZY);
|
||||
#endif /* !_AIX */
|
||||
|
||||
if (handle == 0)
|
||||
{
|
||||
builtin_error (_("cannot open shared object %s: %s"), filename, dlerror ());
|
||||
name = printable_filename (filename, 0);
|
||||
builtin_error (_("cannot open shared object %s: %s"), name, dlerror ());
|
||||
if (name != filename)
|
||||
free (name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -327,18 +360,36 @@ dyn_load_builtin (list, flags, filename)
|
|||
size = strlen (name);
|
||||
struct_name = (char *)xmalloc (size + 8);
|
||||
strcpy (struct_name, name);
|
||||
strcpy (struct_name + size, "_struct");
|
||||
strcpy (struct_name + size, STRUCT_SUFFIX);
|
||||
|
||||
b = (struct builtin *)dlsym (handle, struct_name);
|
||||
if (b == 0)
|
||||
{
|
||||
name = printable_filename (filename, 0);
|
||||
builtin_error (_("cannot find %s in shared object %s: %s"),
|
||||
struct_name, filename, dlerror ());
|
||||
struct_name, name, dlerror ());
|
||||
if (name != filename)
|
||||
free (name);
|
||||
free (struct_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
free (struct_name);
|
||||
funcname = xrealloc (struct_name, size + sizeof (LOAD_SUFFIX) + 1);
|
||||
strcpy (funcname, name);
|
||||
strcpy (funcname + size, LOAD_SUFFIX);
|
||||
|
||||
loadfunc = (sh_load_func_t *)dlsym (handle, funcname);
|
||||
if (loadfunc)
|
||||
{
|
||||
r = (*loadfunc) (name);
|
||||
if (r == 0)
|
||||
{
|
||||
builtin_error (_("load function for %s returns failure (%d): not loaded"), name, r);
|
||||
free (funcname);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
free (funcname);
|
||||
|
||||
b->flags &= ~STATIC_BUILTIN;
|
||||
if (flags & SPECIAL)
|
||||
|
|
@ -446,7 +497,9 @@ dyn_unload_builtin (name)
|
|||
{
|
||||
struct builtin *b;
|
||||
void *handle;
|
||||
int ref, i;
|
||||
char *funcname;
|
||||
sh_unload_func_t *unloadfunc;
|
||||
int ref, i, size;
|
||||
|
||||
b = builtin_address_internal (name, 1);
|
||||
if (b == 0)
|
||||
|
|
@ -467,6 +520,17 @@ dyn_unload_builtin (name)
|
|||
ref++;
|
||||
}
|
||||
|
||||
/* Call any unload function */
|
||||
size = strlen (name);
|
||||
funcname = xmalloc (size + sizeof (UNLOAD_SUFFIX) + 1);
|
||||
strcpy (funcname, name);
|
||||
strcpy (funcname + size, UNLOAD_SUFFIX);
|
||||
|
||||
unloadfunc = (sh_unload_func_t *)dlsym (handle, funcname);
|
||||
if (unloadfunc)
|
||||
(*unloadfunc) (name); /* void function */
|
||||
free (funcname);
|
||||
|
||||
/* Don't remove the shared object unless the reference count of builtins
|
||||
using it drops to zero. */
|
||||
if (ref == 1 && local_dlclose (handle) != 0)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is eval.def, from which is created eval.c.
|
||||
It implements the builtin "eval" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* evalfile.c - read and evaluate commands from a file or file descriptor */
|
||||
|
||||
/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -43,6 +43,8 @@
|
|||
#include "../execute_cmd.h"
|
||||
#include "../trap.h"
|
||||
|
||||
#include <y.tab.h>
|
||||
|
||||
#if defined (HISTORY)
|
||||
# include "../bashhist.h"
|
||||
#endif
|
||||
|
|
@ -71,6 +73,7 @@ extern int indirection_level, subshell_environment;
|
|||
extern int return_catch_flag, return_catch_value;
|
||||
extern int last_command_exit_value;
|
||||
extern int executing_command_builtin;
|
||||
extern int current_token; /* parse.y */
|
||||
|
||||
/* How many `levels' of sourced files we have. */
|
||||
int sourcelevel = 0;
|
||||
|
|
@ -91,6 +94,7 @@ _evalfile (filename, flags)
|
|||
#if defined (ARRAY_VARS)
|
||||
SHELL_VAR *funcname_v, *nfv, *bash_source_v, *bash_lineno_v;
|
||||
ARRAY *funcname_a, *bash_source_a, *bash_lineno_a;
|
||||
struct func_array_state *fa;
|
||||
# if defined (DEBUGGER)
|
||||
SHELL_VAR *bash_argv_v, *bash_argc_v;
|
||||
ARRAY *bash_argv_a, *bash_argc_a;
|
||||
|
|
@ -130,7 +134,7 @@ file_error_and_exit:
|
|||
}
|
||||
|
||||
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE
|
||||
: ((errno == ENOENT) ? 0 : -1));
|
||||
: ((errno == ENOENT && (flags & FEVAL_ENOENTOK) != 0) ? 0 : -1));
|
||||
}
|
||||
|
||||
errfunc = ((flags & FEVAL_BUILTIN) ? builtin_error : internal_error);
|
||||
|
|
@ -240,6 +244,17 @@ file_error_and_exit:
|
|||
array_push (bash_lineno_a, t);
|
||||
free (t);
|
||||
array_push (funcname_a, "source"); /* not exactly right */
|
||||
|
||||
fa = (struct func_array_state *)xmalloc (sizeof (struct func_array_state));
|
||||
fa->source_a = bash_source_a;
|
||||
fa->source_v = bash_source_v;
|
||||
fa->lineno_a = bash_lineno_a;
|
||||
fa->lineno_v = bash_lineno_v;
|
||||
fa->funcname_a = funcname_a;
|
||||
fa->funcname_v = funcname_v;
|
||||
if (flags & FEVAL_UNWINDPROT)
|
||||
add_unwind_protect (restore_funcarray_state, fa);
|
||||
|
||||
# if defined (DEBUGGER)
|
||||
/* Have to figure out a better way to do this when `source' is supplied
|
||||
arguments */
|
||||
|
|
@ -248,6 +263,8 @@ file_error_and_exit:
|
|||
array_push (bash_argv_a, (char *)filename);
|
||||
tt[0] = '1'; tt[1] = '\0';
|
||||
array_push (bash_argc_a, tt);
|
||||
if (flags & FEVAL_UNWINDPROT)
|
||||
add_unwind_protect (pop_args, 0);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -277,30 +294,27 @@ file_error_and_exit:
|
|||
{
|
||||
if (flags & FEVAL_NONINT)
|
||||
interactive = old_interactive;
|
||||
#if defined (ARRAY_VARS)
|
||||
restore_funcarray_state (fa);
|
||||
# if defined (DEBUGGER)
|
||||
if ((flags & FEVAL_NOPUSHARGS) == 0)
|
||||
{
|
||||
/* Don't need to call pop_args here until we do something better
|
||||
when source is passed arguments (see above). */
|
||||
array_pop (bash_argc_a);
|
||||
array_pop (bash_argv_a);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
return_catch_flag--;
|
||||
sourcelevel--;
|
||||
COPY_PROCENV (old_return_catch, return_catch);
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
/* These two variables cannot be unset, and cannot be affected by the
|
||||
sourced file. */
|
||||
array_pop (bash_source_a);
|
||||
array_pop (bash_lineno_a);
|
||||
|
||||
/* FUNCNAME can be unset, and so can potentially be changed by the
|
||||
sourced file. */
|
||||
GET_ARRAY_FROM_VAR ("FUNCNAME", nfv, funcname_a);
|
||||
if (nfv == funcname_v)
|
||||
array_pop (funcname_a);
|
||||
# if defined (DEBUGGER)
|
||||
if ((flags & FEVAL_NOPUSHARGS) == 0)
|
||||
{
|
||||
array_pop (bash_argc_a);
|
||||
array_pop (bash_argv_a);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
/* If we end up with EOF after sourcing a file, which can happen when the file
|
||||
doesn't end with a newline, pretend that it did. */
|
||||
if (current_token == yacc_EOF)
|
||||
push_token ('\n'); /* XXX */
|
||||
|
||||
return ((flags & FEVAL_BUILTIN) ? result : 1);
|
||||
}
|
||||
|
|
@ -322,6 +336,23 @@ maybe_execute_file (fname, force_noninteractive)
|
|||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
force_execute_file (fname, force_noninteractive)
|
||||
const char *fname;
|
||||
int force_noninteractive;
|
||||
{
|
||||
char *filename;
|
||||
int result, flags;
|
||||
|
||||
filename = bash_tilde_expand (fname, 0);
|
||||
flags = 0;
|
||||
if (force_noninteractive)
|
||||
flags |= FEVAL_NONINT;
|
||||
result = _evalfile (filename, flags);
|
||||
free (filename);
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined (HISTORY)
|
||||
int
|
||||
fc_execute_file (filename)
|
||||
|
|
@ -330,8 +361,9 @@ fc_execute_file (filename)
|
|||
int flags;
|
||||
|
||||
/* We want these commands to show up in the history list if
|
||||
remember_on_history is set. */
|
||||
flags = FEVAL_ENOENTOK|FEVAL_HISTORY|FEVAL_REGFILE;
|
||||
remember_on_history is set. We use FEVAL_BUILTIN to return
|
||||
the result of parse_and_execute. */
|
||||
flags = FEVAL_ENOENTOK|FEVAL_HISTORY|FEVAL_REGFILE|FEVAL_BUILTIN;
|
||||
return (_evalfile (filename, flags));
|
||||
}
|
||||
#endif /* HISTORY */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* evalstring.c - evaluate a string as one or more shell commands. */
|
||||
|
||||
/* Copyright (C) 1996-2012 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -96,6 +96,38 @@ restore_lastcom (x)
|
|||
the_printed_command_except_trap = x;
|
||||
}
|
||||
|
||||
int
|
||||
should_suppress_fork (command)
|
||||
COMMAND *command;
|
||||
{
|
||||
return (startup_state == 2 && parse_and_execute_level == 1 &&
|
||||
running_trap == 0 &&
|
||||
*bash_input.location.string == '\0' &&
|
||||
command->type == cm_simple &&
|
||||
#if 0
|
||||
signal_is_trapped (EXIT_TRAP) == 0 &&
|
||||
signal_is_trapped (ERROR_TRAP) == 0 &&
|
||||
#else
|
||||
any_signals_trapped () < 0 &&
|
||||
#endif
|
||||
command->redirects == 0 && command->value.Simple->redirects == 0 &&
|
||||
((command->flags & CMD_TIME_PIPELINE) == 0) &&
|
||||
((command->flags & CMD_INVERT_RETURN) == 0));
|
||||
}
|
||||
|
||||
void
|
||||
optimize_fork (command)
|
||||
COMMAND *command;
|
||||
{
|
||||
if (command->type == cm_connection &&
|
||||
(command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR) &&
|
||||
should_suppress_fork (command->value.Connection->second))
|
||||
{
|
||||
command->value.Connection->second->flags |= CMD_NO_FORK;
|
||||
command->value.Connection->second->value.Simple->flags |= CMD_NO_FORK;
|
||||
}
|
||||
}
|
||||
|
||||
/* How to force parse_and_execute () to clean up after itself. */
|
||||
void
|
||||
parse_and_execute_cleanup ()
|
||||
|
|
@ -141,8 +173,7 @@ parse_prologue (string, flags, tag)
|
|||
else
|
||||
unwind_protect_int (remember_on_history); /* can be used in scripts */
|
||||
# if defined (BANG_HISTORY)
|
||||
if (interactive_shell)
|
||||
unwind_protect_int (history_expansion_inhibited);
|
||||
unwind_protect_int (history_expansion_inhibited);
|
||||
# endif /* BANG_HISTORY */
|
||||
#endif /* HISTORY */
|
||||
|
||||
|
|
@ -172,6 +203,10 @@ parse_prologue (string, flags, tag)
|
|||
#if defined (HISTORY)
|
||||
if (flags & SEVAL_NOHIST)
|
||||
bash_history_disable ();
|
||||
# if defined (BANG_HISTORY)
|
||||
if (flags & SEVAL_NOHISTEXP)
|
||||
history_expansion_inhibited = 1;
|
||||
# endif /* BANG_HISTORY */
|
||||
#endif /* HISTORY */
|
||||
}
|
||||
|
||||
|
|
@ -184,6 +219,7 @@ parse_prologue (string, flags, tag)
|
|||
(flags & SEVAL_NOHIST) -> call bash_history_disable ()
|
||||
(flags & SEVAL_NOFREE) -> don't free STRING when finished
|
||||
(flags & SEVAL_RESETLINE) -> reset line_number to 1
|
||||
(flags & SEVAL_NOHISTEXP) -> history_expansion_inhibited -> 1
|
||||
*/
|
||||
|
||||
int
|
||||
|
|
@ -205,8 +241,8 @@ parse_and_execute (string, from_file, flags)
|
|||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
/* If we longjmp and are going to go on, use this to restore signal mask */
|
||||
sigemptyset (&pe_sigmask);
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &pe_sigmask);
|
||||
sigemptyset ((sigset_t *)&pe_sigmask);
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)&pe_sigmask);
|
||||
#endif
|
||||
|
||||
/* Reset the line number if the caller wants us to. If we don't reset the
|
||||
|
|
@ -226,7 +262,12 @@ parse_and_execute (string, from_file, flags)
|
|||
code = should_jump_to_top_level = 0;
|
||||
last_result = EXECUTION_SUCCESS;
|
||||
|
||||
/* We need to reset enough of the token state so we can start fresh. */
|
||||
if (current_token == yacc_EOF)
|
||||
current_token = '\n'; /* reset_parser() ? */
|
||||
|
||||
with_input_from_string (string, from_file);
|
||||
clear_shell_input_line ();
|
||||
while (*(bash_input.location.string))
|
||||
{
|
||||
command = (COMMAND *)NULL;
|
||||
|
|
@ -285,7 +326,7 @@ parse_and_execute (string, from_file, flags)
|
|||
dispose_command (command); /* pe_dispose does this */
|
||||
#endif
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_SETMASK, &pe_sigmask, (sigset_t *)NULL);
|
||||
sigprocmask (SIG_SETMASK, (sigset_t *)&pe_sigmask, (sigset_t *)NULL);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
|
@ -349,22 +390,18 @@ parse_and_execute (string, from_file, flags)
|
|||
* we're not going to run the exit trap AND
|
||||
* we have a simple command without redirections AND
|
||||
* the command is not being timed AND
|
||||
* the command's return status is not being inverted
|
||||
* the command's return status is not being inverted AND
|
||||
* there aren't any traps in effect
|
||||
* THEN
|
||||
* tell the execution code that we don't need to fork
|
||||
*/
|
||||
if (startup_state == 2 && parse_and_execute_level == 1 &&
|
||||
running_trap == 0 &&
|
||||
*bash_input.location.string == '\0' &&
|
||||
command->type == cm_simple &&
|
||||
signal_is_trapped (EXIT_TRAP) == 0 &&
|
||||
command->redirects == 0 && command->value.Simple->redirects == 0 &&
|
||||
((command->flags & CMD_TIME_PIPELINE) == 0) &&
|
||||
((command->flags & CMD_INVERT_RETURN) == 0))
|
||||
if (should_suppress_fork (command))
|
||||
{
|
||||
command->flags |= CMD_NO_FORK;
|
||||
command->value.Simple->flags |= CMD_NO_FORK;
|
||||
}
|
||||
else if (command->type == cm_connection)
|
||||
optimize_fork (command);
|
||||
#endif /* ONESHOT */
|
||||
|
||||
/* See if this is a candidate for $( <file ). */
|
||||
|
|
@ -457,11 +494,11 @@ parse_string (string, from_file, flags, endp)
|
|||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
/* If we longjmp and are going to go on, use this to restore signal mask */
|
||||
sigemptyset (&ps_sigmask);
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &ps_sigmask);
|
||||
sigemptyset ((sigset_t *)&ps_sigmask);
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)&ps_sigmask);
|
||||
#endif
|
||||
|
||||
/* itrace("parse_string: `%s'", string); */
|
||||
/*itrace("parse_string: `%s'", string);*/
|
||||
/* Reset the line number if the caller wants us to. If we don't reset the
|
||||
line number, we have to subtract one, because we will add one just
|
||||
before executing the next command (resetting the line number sets it to
|
||||
|
|
@ -510,7 +547,7 @@ itrace("parse_string: longjmp executed: code = %d", code);
|
|||
|
||||
default:
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_SETMASK, &ps_sigmask, (sigset_t *)NULL);
|
||||
sigprocmask (SIG_SETMASK, (sigset_t *)&ps_sigmask, (sigset_t *)NULL);
|
||||
#endif
|
||||
command_error ("parse_string", CMDERR_BADJUMP, code, 0);
|
||||
break;
|
||||
|
|
@ -547,8 +584,16 @@ itrace("parse_string: longjmp executed: code = %d", code);
|
|||
|
||||
run_unwind_frame (PS_TAG);
|
||||
|
||||
/* If we return < 0, the caller (xparse_dolparen) will jump_to_top_level for
|
||||
us, after doing cleanup */
|
||||
if (should_jump_to_top_level)
|
||||
jump_to_top_level (code);
|
||||
{
|
||||
if (parse_and_execute_level == 0)
|
||||
top_level_cleanup ();
|
||||
if (code == DISCARD)
|
||||
return -DISCARD;
|
||||
jump_to_top_level (code);
|
||||
}
|
||||
|
||||
return (nc);
|
||||
}
|
||||
|
|
@ -634,7 +679,7 @@ evalstring (string, from_file, flags)
|
|||
if (rcatch && return_catch_flag)
|
||||
{
|
||||
return_catch_value = r;
|
||||
longjmp (return_catch, 1);
|
||||
sh_longjmp (return_catch, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is exec.def, from which is created exec.c.
|
||||
It implements the builtin "exec" in Bash.
|
||||
|
||||
Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -31,8 +31,8 @@ any redirections take effect in the current shell.
|
|||
|
||||
Options:
|
||||
-a name pass NAME as the zeroth argument to COMMAND
|
||||
-c execute COMMAND with an empty environment
|
||||
-l place a dash in the zeroth argument to COMMAND
|
||||
-c execute COMMAND with an empty environment
|
||||
-l place a dash in the zeroth argument to COMMAND
|
||||
|
||||
If the command cannot be executed, a non-interactive shell exits, unless
|
||||
the shell option `execfail' is set.
|
||||
|
|
@ -119,6 +119,7 @@ exec_builtin (list)
|
|||
case 'a':
|
||||
argv0 = list_optarg;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -142,6 +143,7 @@ exec_builtin (list)
|
|||
#endif /* RESTRICTED_SHELL */
|
||||
|
||||
args = strvec_from_word_list (list, 1, 0, (int *)NULL);
|
||||
env = (char **)0;
|
||||
|
||||
/* A command with a slash anywhere in its name is not looked up in $PATH. */
|
||||
command = absolute_program (args[0]) ? args[0] : search_for_command (args[0], 1);
|
||||
|
|
@ -193,7 +195,10 @@ exec_builtin (list)
|
|||
adjust_shell_level (-1);
|
||||
|
||||
if (cleanenv)
|
||||
env = (char **)NULL;
|
||||
{
|
||||
env = strvec_create (1);
|
||||
env[0] = (char *)0;
|
||||
}
|
||||
else
|
||||
{
|
||||
maybe_make_export_env ();
|
||||
|
|
@ -210,6 +215,8 @@ exec_builtin (list)
|
|||
#if defined (JOB_CONTROL)
|
||||
if (subshell_environment == 0)
|
||||
end_job_control ();
|
||||
if (interactive || job_control)
|
||||
default_tty_job_signals (); /* undo initialize_job_signals */
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
exit_value = shell_execve (command, args, env);
|
||||
|
|
@ -240,6 +247,9 @@ failed_exec:
|
|||
if (args)
|
||||
strvec_dispose (args);
|
||||
|
||||
if (env && env != export_env)
|
||||
strvec_dispose (env);
|
||||
|
||||
initialize_traps ();
|
||||
initialize_signals (1);
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ int
|
|||
exit_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
if (interactive)
|
||||
{
|
||||
fprintf (stderr, login_shell ? _("logout\n") : "exit\n");
|
||||
|
|
@ -83,6 +85,8 @@ int
|
|||
logout_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
if (login_shell == 0 /* && interactive */)
|
||||
{
|
||||
builtin_error (_("not login shell: use `exit'"));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is fc.def, from which is created fc.c.
|
||||
It implements the builtin "fc" in Bash.
|
||||
|
||||
Copyright (C) 1987-2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -158,6 +158,12 @@ static char *fc_readline __P((FILE *));
|
|||
static void fc_addhist __P((char *));
|
||||
#endif
|
||||
|
||||
static void
|
||||
set_verbose_flag ()
|
||||
{
|
||||
echo_input_at_read = verbose_flag;
|
||||
}
|
||||
|
||||
/* String to execute on a file that we want to edit. */
|
||||
#define FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-vi}}"
|
||||
#if defined (STRICT_POSIX)
|
||||
|
|
@ -212,6 +218,7 @@ fc_builtin (list)
|
|||
ename = list_optarg;
|
||||
break;
|
||||
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -440,6 +447,13 @@ fc_builtin (list)
|
|||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
#if defined (READLINE)
|
||||
/* If we're executing as part of a dispatched readline commnand like
|
||||
{emacs,vi}_edit_and_execute_command, the readline state will indicate it.
|
||||
We could remove the partial command from the history, but ksh93 doesn't
|
||||
so we stay compatible. */
|
||||
#endif
|
||||
|
||||
/* Make sure parse_and_execute doesn't turn this off, even though a
|
||||
call to parse_and_execute farther up the function call stack (e.g.,
|
||||
if this is called by vi_edit_and_execute_command) may have already
|
||||
|
|
@ -451,11 +465,10 @@ fc_builtin (list)
|
|||
begin_unwind_frame ("fc builtin");
|
||||
add_unwind_protect ((Function *)xfree, fn);
|
||||
add_unwind_protect (unlink, fn);
|
||||
unwind_protect_int (echo_input_at_read);
|
||||
add_unwind_protect (set_verbose_flag, (char *)NULL);
|
||||
echo_input_at_read = 1;
|
||||
|
||||
retval = fc_execute_file (fn);
|
||||
|
||||
retval = fc_execute_file (fn);
|
||||
run_unwind_frame ("fc builtin");
|
||||
|
||||
return (retval);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ fg_builtin (list)
|
|||
int fg_bit;
|
||||
register WORD_LIST *t;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
if (job_control == 0)
|
||||
{
|
||||
sh_nojobs ((char *)NULL);
|
||||
|
|
@ -105,6 +107,8 @@ bg_builtin (list)
|
|||
{
|
||||
int r;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
if (job_control == 0)
|
||||
{
|
||||
sh_nojobs ((char *)NULL);
|
||||
|
|
|
|||
|
|
@ -223,6 +223,52 @@ sh_getopt_restore_state (argv)
|
|||
nextchar = argv[sh_curopt] + sh_charindex;
|
||||
}
|
||||
|
||||
sh_getopt_state_t *
|
||||
sh_getopt_alloc_istate ()
|
||||
{
|
||||
sh_getopt_state_t *ret;
|
||||
|
||||
ret = (sh_getopt_state_t *)xmalloc (sizeof (sh_getopt_state_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
sh_getopt_dispose_istate (gs)
|
||||
sh_getopt_state_t *gs;
|
||||
{
|
||||
free (gs);
|
||||
}
|
||||
|
||||
sh_getopt_state_t *
|
||||
sh_getopt_save_istate ()
|
||||
{
|
||||
sh_getopt_state_t *ret;
|
||||
|
||||
ret = sh_getopt_alloc_istate ();
|
||||
|
||||
ret->gs_optarg = sh_optarg;
|
||||
ret->gs_optind = sh_optind;
|
||||
ret->gs_curopt = sh_curopt;
|
||||
ret->gs_nextchar = nextchar; /* XXX */
|
||||
ret->gs_charindex = sh_charindex;
|
||||
ret->gs_flags = 0; /* XXX for later use */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
sh_getopt_restore_istate (state)
|
||||
sh_getopt_state_t *state;
|
||||
{
|
||||
sh_optarg = state->gs_optarg;
|
||||
sh_optind = state->gs_optind;
|
||||
sh_curopt = state->gs_curopt;
|
||||
nextchar = state->gs_nextchar; /* XXX - probably not usable */
|
||||
sh_charindex = state->gs_charindex;
|
||||
|
||||
sh_getopt_dispose_istate (state);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
sh_getopt_debug_restore_state (argv)
|
||||
|
|
|
|||
|
|
@ -60,6 +60,23 @@ extern int sh_optopt;
|
|||
extern int sh_badopt;
|
||||
|
||||
extern int sh_getopt __P((int, char *const *, const char *));
|
||||
|
||||
typedef struct sh_getopt_state
|
||||
{
|
||||
char *gs_optarg;
|
||||
int gs_optind;
|
||||
int gs_curopt;
|
||||
char *gs_nextchar;
|
||||
int gs_charindex;
|
||||
int gs_flags;
|
||||
} sh_getopt_state_t;
|
||||
|
||||
extern void sh_getopt_restore_state __P((char **));
|
||||
|
||||
extern sh_getopt_state_t *sh_getopt_alloc_istate __P((void));
|
||||
extern void sh_getopt_dispose_istate __P((sh_getopt_state_t *));
|
||||
|
||||
extern sh_getopt_state_t *sh_getopt_save_istate __P((void));
|
||||
extern void sh_getopt_restore_istate __P((sh_getopt_state_t *));
|
||||
|
||||
#endif /* _SH_GETOPT_H */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is getopts.def, from which is created getopts.c.
|
||||
It implements the builtin "getopts" in Bash.
|
||||
|
||||
Copyright (C) 1987-2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -74,6 +74,7 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
|
|
@ -86,6 +87,7 @@ $END
|
|||
|
||||
extern char *this_command_name;
|
||||
|
||||
static int getopts_unbind_variable __P((char *));
|
||||
static int getopts_bind_variable __P((char *, char *));
|
||||
static int dogetopts __P((int, char **));
|
||||
|
||||
|
|
@ -99,6 +101,17 @@ getopts_reset (newind)
|
|||
sh_badopt = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
getopts_unbind_variable (name)
|
||||
char *name;
|
||||
{
|
||||
#if 0
|
||||
return (unbind_variable (name));
|
||||
#else
|
||||
return (unbind_variable_noref (name));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
getopts_bind_variable (name, value)
|
||||
char *name, *value;
|
||||
|
|
@ -253,7 +266,7 @@ dogetopts (argc, argv)
|
|||
|
||||
if (ret == G_EOF)
|
||||
{
|
||||
unbind_variable ("OPTARG");
|
||||
getopts_unbind_variable ("OPTARG");
|
||||
getopts_bind_variable (name, "?");
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
|
@ -270,7 +283,7 @@ dogetopts (argc, argv)
|
|||
bind_variable ("OPTARG", strval, 0);
|
||||
}
|
||||
else
|
||||
unbind_variable ("OPTARG");
|
||||
getopts_unbind_variable ("OPTARG");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
|
@ -289,7 +302,7 @@ dogetopts (argc, argv)
|
|||
else
|
||||
{
|
||||
ret = getopts_bind_variable (name, "?");
|
||||
unbind_variable ("OPTARG");
|
||||
getopts_unbind_variable ("OPTARG");
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
|
@ -316,9 +329,12 @@ getopts_builtin (list)
|
|||
}
|
||||
|
||||
reset_internal_getopt ();
|
||||
if (internal_getopt (list, "") != -1)
|
||||
if ((ret = internal_getopt (list, "")) != -1)
|
||||
{
|
||||
builtin_usage ();
|
||||
if (ret == GETOPT_HELP)
|
||||
builtin_help ();
|
||||
else
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
list = loptend;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is hash.def, from which is created hash.c.
|
||||
It implements the builtin "hash" in Bash.
|
||||
|
||||
Copyright (C) 1987-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -29,15 +29,15 @@ Determine and remember the full pathname of each command NAME. If
|
|||
no arguments are given, information about remembered commands is displayed.
|
||||
|
||||
Options:
|
||||
-d forget the remembered location of each NAME
|
||||
-l display in a format that may be reused as input
|
||||
-d forget the remembered location of each NAME
|
||||
-l display in a format that may be reused as input
|
||||
-p pathname use PATHNAME as the full pathname of NAME
|
||||
-r forget all remembered locations
|
||||
-t print the remembered location of each NAME, preceding
|
||||
-r forget all remembered locations
|
||||
-t print the remembered location of each NAME, preceding
|
||||
each location with the corresponding NAME if multiple
|
||||
NAMEs are given
|
||||
Arguments:
|
||||
NAME Each NAME is searched for in $PATH and added to the list
|
||||
NAME Each NAME is searched for in $PATH and added to the list
|
||||
of remembered commands.
|
||||
|
||||
Exit Status:
|
||||
|
|
@ -115,6 +115,7 @@ hash_builtin (list)
|
|||
case 't':
|
||||
list_targets = 1;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -230,7 +231,15 @@ static int
|
|||
print_portable_hash_info (item)
|
||||
BUCKET_CONTENTS *item;
|
||||
{
|
||||
printf ("builtin hash -p %s %s\n", pathdata(item)->path, item->key);
|
||||
char *fp, *fn;
|
||||
|
||||
fp = printable_filename (pathdata(item)->path, 1);
|
||||
fn = printable_filename (item->key, 1);
|
||||
printf ("builtin hash -p %s %s\n", fp, fn);
|
||||
if (fp != pathdata(item)->path)
|
||||
free (fp);
|
||||
if (fn != item->key)
|
||||
free (fn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is help.def, from which is created help.c.
|
||||
It implements the builtin "help" in Bash.
|
||||
|
||||
Copyright (C) 1987-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ Options:
|
|||
-d output short description for each topic
|
||||
-m display usage in pseudo-manpage format
|
||||
-s output only a short usage synopsis for each topic matching
|
||||
PATTERN
|
||||
PATTERN
|
||||
|
||||
Arguments:
|
||||
PATTERN Pattern specifiying a help topic
|
||||
|
|
@ -58,6 +58,7 @@ $END
|
|||
#include <errno.h>
|
||||
|
||||
#include <filecntl.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
|
|
@ -77,6 +78,9 @@ extern int errno;
|
|||
extern const char * const bash_copyright;
|
||||
extern const char * const bash_license;
|
||||
|
||||
extern char *this_command_name;
|
||||
extern struct builtin *current_builtin;
|
||||
|
||||
static void show_builtin_command_help __P((void));
|
||||
static int open_helpfile __P((char *));
|
||||
static void show_desc __P((char *, int));
|
||||
|
|
@ -109,6 +113,7 @@ help_builtin (list)
|
|||
case 's':
|
||||
sflag = 1;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -187,6 +192,28 @@ help_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
builtin_help ()
|
||||
{
|
||||
int ind;
|
||||
ptrdiff_t d;
|
||||
|
||||
current_builtin = builtin_address_internal (this_command_name, 0);
|
||||
if (current_builtin == 0)
|
||||
return;
|
||||
|
||||
d = current_builtin - shell_builtins;
|
||||
|
||||
#if defined (__STDC__)
|
||||
ind = (int)d;
|
||||
#else
|
||||
ind = (int)d / sizeof (struct builtin);
|
||||
#endif
|
||||
|
||||
printf ("%s: %s\n", this_command_name, _(shell_builtins[ind].short_doc));
|
||||
show_longdoc (ind);
|
||||
}
|
||||
|
||||
static int
|
||||
open_helpfile (name)
|
||||
char *name;
|
||||
|
|
@ -348,7 +375,7 @@ dispcolumn (i, buf, bufsize, width, height)
|
|||
int width, height;
|
||||
{
|
||||
int j;
|
||||
int displen;
|
||||
int dispcols;
|
||||
char *helpdoc;
|
||||
|
||||
/* first column */
|
||||
|
|
@ -365,9 +392,9 @@ dispcolumn (i, buf, bufsize, width, height)
|
|||
return;
|
||||
}
|
||||
|
||||
displen = strlen (buf);
|
||||
dispcols = strlen (buf);
|
||||
/* two spaces */
|
||||
for (j = displen; j < width; j++)
|
||||
for (j = dispcols; j < width; j++)
|
||||
putc (' ', stdout);
|
||||
|
||||
/* second column */
|
||||
|
|
@ -390,7 +417,7 @@ wdispcolumn (i, buf, bufsize, width, height)
|
|||
int width, height;
|
||||
{
|
||||
int j;
|
||||
int displen;
|
||||
int dispcols, dispchars;
|
||||
char *helpdoc;
|
||||
wchar_t *wcstr;
|
||||
size_t slen, n;
|
||||
|
|
@ -420,23 +447,29 @@ wdispcolumn (i, buf, bufsize, width, height)
|
|||
if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
|
||||
wcstr[j] = L' ';
|
||||
|
||||
displen = wcsnwidth (wcstr+1, slen, width - 2) + 1; /* +1 for ' ' or '*' */
|
||||
|
||||
/* dispchars == number of characters that will be displayed */
|
||||
dispchars = wcsnwidth (wcstr+1, slen, width - 2);
|
||||
/* dispcols == number of columns required to display DISPCHARS */
|
||||
dispcols = wcswidth (wcstr+1, dispchars) + 1; /* +1 for ' ' or '*' */
|
||||
|
||||
wcstr[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? L' ' : L'*';
|
||||
|
||||
/* This assumes each wide char takes up one column position when displayed */
|
||||
wcstr[width - 2] = L'>'; /* indicate truncation */
|
||||
wcstr[width - 1] = L'\0';
|
||||
if (dispcols >= width-2)
|
||||
{
|
||||
wcstr[dispchars] = L'>'; /* indicate truncation */
|
||||
wcstr[dispchars+1] = L'\0';
|
||||
}
|
||||
|
||||
printf ("%ls", wcstr);
|
||||
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
|
||||
{
|
||||
printf ("\n");
|
||||
free (wcstr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* at least one space */
|
||||
for (j = displen; j < width; j++)
|
||||
for (j = dispcols; j < width; j++)
|
||||
putc (' ', stdout);
|
||||
|
||||
/* second column */
|
||||
|
|
@ -446,6 +479,7 @@ wdispcolumn (i, buf, bufsize, width, height)
|
|||
{
|
||||
/* for now */
|
||||
printf ("%c%s\n", (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*', helpdoc);
|
||||
free (wcstr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -460,13 +494,20 @@ wdispcolumn (i, buf, bufsize, width, height)
|
|||
if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
|
||||
wcstr[j] = L' ';
|
||||
|
||||
displen = wcsnwidth (wcstr+1, slen, width - 2);
|
||||
/* dispchars == number of characters that will be displayed */
|
||||
dispchars = wcsnwidth (wcstr+1, slen, width - 2);
|
||||
dispcols = wcswidth (wcstr+1, dispchars) + 1; /* +1 for ' ' or '*' */
|
||||
|
||||
wcstr[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? L' ' : L'*';
|
||||
|
||||
/* This assumes each wide char takes up one column position when displayed */
|
||||
wcstr[width - 3] = L'>'; /* indicate truncation */
|
||||
wcstr[width - 2] = L'\0';
|
||||
/* The dispchars-1 is there for terminals that behave strangely when you
|
||||
have \n in the nth column for terminal width n; this is what bash-4.3
|
||||
did. */
|
||||
if (dispcols >= width - 2)
|
||||
{
|
||||
wcstr[dispchars-1] = L'>'; /* indicate truncation */
|
||||
wcstr[dispchars] = L'\0';
|
||||
}
|
||||
|
||||
printf ("%ls\n", wcstr);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is history.def, from which is created history.c.
|
||||
It implements the builtin "history" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -31,23 +31,23 @@ entry with a `*'. An argument of N lists only the last N entries.
|
|||
|
||||
Options:
|
||||
-c clear the history list by deleting all of the entries
|
||||
-d offset delete the history entry at offset OFFSET.
|
||||
-d offset delete the history entry at position OFFSET.
|
||||
|
||||
-a append history lines from this session to the history file
|
||||
-n read all history lines not already read from the history file
|
||||
and append them to the history list
|
||||
-r read the history file and append the contents to the history
|
||||
list
|
||||
list
|
||||
-w write the current history to the history file
|
||||
and append them to the history list
|
||||
|
||||
-p perform history expansion on each ARG and display the result
|
||||
without storing it in the history list
|
||||
without storing it in the history list
|
||||
-s append the ARGs to the history list as a single entry
|
||||
|
||||
If FILENAME is given, it is used as the history file. Otherwise,
|
||||
if $HISTFILE has a value, that is used, else ~/.bash_history.
|
||||
if HISTFILE has a value, that is used, else ~/.bash_history.
|
||||
|
||||
If the $HISTTIMEFORMAT variable is set and not null, its value is used
|
||||
If the HISTTIMEFORMAT variable is set and not null, its value is used
|
||||
as a format string for strftime(3) to print the time stamp associated
|
||||
with each displayed history entry. No time stamps are printed otherwise.
|
||||
|
||||
|
|
@ -141,6 +141,7 @@ history_builtin (list)
|
|||
flags |= PFLAG;
|
||||
#endif
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -208,7 +209,11 @@ history_builtin (list)
|
|||
else if (flags & WFLAG) /* Write entire history. */
|
||||
result = write_history (filename);
|
||||
else if (flags & RFLAG) /* Read entire file. */
|
||||
result = read_history (filename);
|
||||
{
|
||||
result = read_history (filename);
|
||||
history_lines_in_file = history_lines_read_from_file;
|
||||
/* history_lines_in_file = where_history () + history_base - 1; */
|
||||
}
|
||||
else if (flags & NFLAG) /* Read `new' history from file. */
|
||||
{
|
||||
/* Read all of the lines in the file that we haven't already read. */
|
||||
|
|
@ -219,7 +224,8 @@ history_builtin (list)
|
|||
result = read_history_range (filename, history_lines_in_file, -1);
|
||||
using_history ();
|
||||
|
||||
history_lines_in_file = where_history ();
|
||||
history_lines_in_file = history_lines_read_from_file;
|
||||
/* history_lines_in_file = where_history () + history_base - 1; */
|
||||
|
||||
/* If we're rewriting the history file at shell exit rather than just
|
||||
appending the lines from this session to it, the question is whether
|
||||
|
|
@ -254,6 +260,9 @@ histtime (hlist, histtimefmt)
|
|||
t = history_get_time (hlist);
|
||||
if (t)
|
||||
strftime (timestr, sizeof (timestr), histtimefmt, localtime (&t));
|
||||
else if (hlist->timestamp && hlist->timestamp[0])
|
||||
snprintf (timestr, sizeof (timestr), _("%s: invalid timestamp"),
|
||||
(hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
|
||||
else
|
||||
strcpy (timestr, "??");
|
||||
return timestr;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is jobs.def, from which is created jobs.c.
|
||||
It implements the builtins "jobs" and "disown" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ Without options, the status of all active jobs is displayed.
|
|||
Options:
|
||||
-l lists process IDs in addition to the normal information
|
||||
-n lists only processes that have changed status since the last
|
||||
notification
|
||||
notification
|
||||
-p lists process IDs only
|
||||
-r restrict output to running jobs
|
||||
-s restrict output to stopped jobs
|
||||
|
|
@ -118,6 +118,7 @@ jobs_builtin (list)
|
|||
state = JSTATE_STOPPED;
|
||||
break;
|
||||
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -212,7 +213,7 @@ execute_list_with_replacements (list)
|
|||
$BUILTIN disown
|
||||
$FUNCTION disown_builtin
|
||||
$DEPENDS_ON JOB_CONTROL
|
||||
$SHORT_DOC disown [-h] [-ar] [jobspec ...]
|
||||
$SHORT_DOC disown [-h] [-ar] [jobspec ... | pid ...]
|
||||
Remove jobs from current shell.
|
||||
|
||||
Removes each JOBSPEC argument from the table of active jobs. Without
|
||||
|
|
@ -221,7 +222,7 @@ any JOBSPECs, the shell uses its notion of the current job.
|
|||
Options:
|
||||
-a remove all jobs if JOBSPEC is not supplied
|
||||
-h mark each JOBSPEC so that SIGHUP is not sent to the job if the
|
||||
shell receives a SIGHUP
|
||||
shell receives a SIGHUP
|
||||
-r remove only running jobs
|
||||
|
||||
Exit Status:
|
||||
|
|
@ -252,6 +253,7 @@ disown_builtin (list)
|
|||
case 'r':
|
||||
running_jobs = 1;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is kill.def, from which is created kill.c.
|
||||
It implements the builtin "kill" in Bash.
|
||||
|
||||
Copyright (C) 1987-2010 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -33,7 +33,8 @@ Options:
|
|||
-s sig SIG is a signal name
|
||||
-n sig SIG is a signal number
|
||||
-l list the signal names; if arguments follow `-l' they are
|
||||
assumed to be signal numbers for which names should be listed
|
||||
assumed to be signal numbers for which names should be listed
|
||||
-L synonym for -l
|
||||
|
||||
Kill is a shell builtin for two reasons: it allows job IDs to be used
|
||||
instead of process IDs, and allows processes to be killed if the limit
|
||||
|
|
@ -96,6 +97,7 @@ kill_builtin (list)
|
|||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
any_succeeded = listing = saw_signal = 0;
|
||||
sig = SIGTERM;
|
||||
|
|
@ -107,7 +109,7 @@ kill_builtin (list)
|
|||
{
|
||||
word = list->word->word;
|
||||
|
||||
if (ISOPTION (word, 'l'))
|
||||
if (ISOPTION (word, 'l') || ISOPTION (word, 'L'))
|
||||
{
|
||||
listing++;
|
||||
list = list->next;
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ let_builtin (list)
|
|||
intmax_t ret;
|
||||
int expok;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
/* Skip over leading `--' argument. */
|
||||
if (list && list->word && ISOPTION (list->word->word, '-'))
|
||||
list = list->next;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ This file is mapfile.def, from which is created mapfile.c.
|
|||
It implements the builtin "mapfile" in Bash.
|
||||
|
||||
Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2012 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ $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]
|
||||
$SHORT_DOC mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
|
||||
Read lines from the standard input into an indexed array variable.
|
||||
|
||||
Read lines from the standard input into the indexed array variable ARRAY, or
|
||||
|
|
@ -31,16 +31,18 @@ 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.
|
||||
-O origin Begin assigning to ARRAY at index ORIGIN. The default index is 0.
|
||||
-s count Discard the first COUNT lines read.
|
||||
-t Remove a trailing newline from each line read.
|
||||
-u fd Read lines from file descriptor FD instead of the standard input.
|
||||
-C callback Evaluate CALLBACK each time QUANTUM lines are read.
|
||||
-c quantum Specify the number of lines read between each call to CALLBACK.
|
||||
-d delim Use DELIM to terminate lines, instead of newline
|
||||
-n count Copy at most COUNT lines. If COUNT is 0, all lines are copied
|
||||
-O origin Begin assigning to ARRAY at index ORIGIN. The default index is 0
|
||||
-s count Discard the first COUNT lines read
|
||||
-t Remove a trailing DELIM from each line read (default newline)
|
||||
-u fd Read lines from file descriptor FD instead of the standard input
|
||||
-C callback Evaluate CALLBACK each time QUANTUM lines are read
|
||||
-c quantum Specify the number of lines read between each call to
|
||||
CALLBACK
|
||||
|
||||
Arguments:
|
||||
ARRAY Array variable name to use for file data.
|
||||
ARRAY Array variable name to use for file data
|
||||
|
||||
If -C is supplied without -c, the default quantum is 5000. When
|
||||
CALLBACK is evaluated, it is supplied the index of the next array
|
||||
|
|
@ -101,6 +103,8 @@ static int run_callback __P((const char *, unsigned int, const char *));
|
|||
#define MAPF_CLEARARRAY 0x01
|
||||
#define MAPF_CHOP 0x02
|
||||
|
||||
static int delim;
|
||||
|
||||
static int
|
||||
run_callback (callback, curindex, curline)
|
||||
const char *callback;
|
||||
|
|
@ -129,21 +133,23 @@ run_callback (callback, curindex, curline)
|
|||
}
|
||||
|
||||
static void
|
||||
do_chop(line)
|
||||
char * line;
|
||||
do_chop(line, delim)
|
||||
char *line;
|
||||
unsigned char delim;
|
||||
{
|
||||
int length;
|
||||
|
||||
length = strlen (line);
|
||||
if (length && line[length-1] == '\n')
|
||||
if (length && line[length-1] == delim)
|
||||
line[length-1] = '\0';
|
||||
}
|
||||
|
||||
static int
|
||||
mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_name, flags)
|
||||
mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_name, delim, flags)
|
||||
int fd;
|
||||
long line_count_goal, origin, nskip, callback_quantum;
|
||||
char *callback, *array_name;
|
||||
int delim;
|
||||
int flags;
|
||||
{
|
||||
char *line;
|
||||
|
|
@ -184,11 +190,14 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
|
|||
unbuffered_read = 1;
|
||||
#endif
|
||||
|
||||
if (delim != '\n')
|
||||
unbuffered_read = 1;
|
||||
|
||||
zreset ();
|
||||
|
||||
/* Skip any lines at beginning of file? */
|
||||
for (line_count = 0; line_count < nskip; line_count++)
|
||||
if (zgetline (fd, &line, &line_length, unbuffered_read) < 0)
|
||||
if (zgetline (fd, &line, &line_length, delim, unbuffered_read) < 0)
|
||||
break;
|
||||
|
||||
line = 0;
|
||||
|
|
@ -196,12 +205,12 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
|
|||
|
||||
/* Reset the buffer for bash own stream */
|
||||
for (array_index = origin, line_count = 1;
|
||||
zgetline (fd, &line, &line_length, unbuffered_read) != -1;
|
||||
zgetline (fd, &line, &line_length, delim, unbuffered_read) != -1;
|
||||
array_index++)
|
||||
{
|
||||
/* Remove trailing newlines? */
|
||||
if (flags & MAPF_CHOP)
|
||||
do_chop (line);
|
||||
do_chop (line, delim);
|
||||
|
||||
/* Has a callback been registered and if so is it time to call it? */
|
||||
if (callback && line_count && (line_count % callback_quantum) == 0)
|
||||
|
|
@ -246,12 +255,16 @@ mapfile_builtin (list)
|
|||
flags = MAPF_CLEARARRAY;
|
||||
callback_quantum = DEFAULT_QUANTUM;
|
||||
callback = 0;
|
||||
delim = '\n';
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "u:n:O:tC:c:s:")) != -1)
|
||||
while ((opt = internal_getopt (list, "d:u:n:O:tC:c:s:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'd':
|
||||
delim = *list_optarg;
|
||||
break;
|
||||
case 'u':
|
||||
code = legal_number (list_optarg, &intval);
|
||||
if (code == 0 || intval < 0 || intval != (int)intval)
|
||||
|
|
@ -317,6 +330,7 @@ mapfile_builtin (list)
|
|||
else
|
||||
nskip = intval;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -339,13 +353,13 @@ mapfile_builtin (list)
|
|||
else
|
||||
array_name = list->word->word;
|
||||
|
||||
if (legal_identifier (array_name) == 0 && valid_array_reference (array_name) == 0)
|
||||
if (legal_identifier (array_name) == 0)
|
||||
{
|
||||
sh_invalidid (array_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
return mapfile (fd, lines, origin, nskip, callback_quantum, callback, array_name, flags);
|
||||
return mapfile (fd, lines, origin, nskip, callback_quantum, callback, array_name, delim, flags);
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* mkbuiltins.c - Create builtins.c, builtext.h, and builtdoc.c from
|
||||
a single source file called builtins.def. */
|
||||
|
||||
/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -71,7 +71,8 @@ extern char *strcpy ();
|
|||
/* Flag values that builtins can have. */
|
||||
#define BUILTIN_FLAG_SPECIAL 0x01
|
||||
#define BUILTIN_FLAG_ASSIGNMENT 0x02
|
||||
#define BUILTIN_FLAG_POSIX_BUILTIN 0x04
|
||||
#define BUILTIN_FLAG_LOCALVAR 0x04
|
||||
#define BUILTIN_FLAG_POSIX_BUILTIN 0x08
|
||||
|
||||
#define BASE_INDENT 4
|
||||
|
||||
|
|
@ -159,6 +160,11 @@ char *assignment_builtins[] =
|
|||
(char *)NULL
|
||||
};
|
||||
|
||||
char *localvar_builtins[] =
|
||||
{
|
||||
"declare", "local", "typeset", (char *)NULL
|
||||
};
|
||||
|
||||
/* The builtin commands that are special to the POSIX search order. */
|
||||
char *posix_builtins[] =
|
||||
{
|
||||
|
|
@ -170,6 +176,7 @@ char *posix_builtins[] =
|
|||
/* Forward declarations. */
|
||||
static int is_special_builtin ();
|
||||
static int is_assignment_builtin ();
|
||||
static int is_localvar_builtin ();
|
||||
static int is_posix_builtin ();
|
||||
|
||||
#if !defined (HAVE_RENAME)
|
||||
|
|
@ -820,6 +827,8 @@ builtin_handler (self, defs, arg)
|
|||
new->flags |= BUILTIN_FLAG_SPECIAL;
|
||||
if (is_assignment_builtin (name))
|
||||
new->flags |= BUILTIN_FLAG_ASSIGNMENT;
|
||||
if (is_localvar_builtin (name))
|
||||
new->flags |= BUILTIN_FLAG_LOCALVAR;
|
||||
if (is_posix_builtin (name))
|
||||
new->flags |= BUILTIN_FLAG_POSIX_BUILTIN;
|
||||
|
||||
|
|
@ -1102,7 +1111,7 @@ char *structfile_header[] = {
|
|||
"/* This file is manufactured by ./mkbuiltins, and should not be",
|
||||
" edited by hand. See the source to mkbuiltins for details. */",
|
||||
"",
|
||||
"/* Copyright (C) 1987-2012 Free Software Foundation, Inc.",
|
||||
"/* Copyright (C) 1987-2015 Free Software Foundation, Inc.",
|
||||
"",
|
||||
" This file is part of GNU Bash, the Bourne Again SHell.",
|
||||
"",
|
||||
|
|
@ -1132,6 +1141,8 @@ char *structfile_header[] = {
|
|||
" the list of shell reserved control structures, like `if' and `while'.",
|
||||
" The end of the list is denoted with a NULL name field. */",
|
||||
"",
|
||||
"/* TRANSLATORS: Please do not translate command names in descriptions */",
|
||||
"",
|
||||
"#include \"../builtins.h\"",
|
||||
(char *)NULL
|
||||
};
|
||||
|
|
@ -1239,23 +1250,36 @@ write_builtins (defs, structfile, externfile)
|
|||
else
|
||||
fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
|
||||
|
||||
fprintf (structfile, "%s%s%s%s, %s_doc,\n",
|
||||
fprintf (structfile, "%s%s%s%s%s, %s_doc,\n",
|
||||
"BUILTIN_ENABLED | STATIC_BUILTIN",
|
||||
(builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
|
||||
(builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
|
||||
(builtin->flags & BUILTIN_FLAG_LOCALVAR) ? " | LOCALVAR_BUILTIN" : "",
|
||||
(builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "",
|
||||
document_name (builtin));
|
||||
|
||||
if (inhibit_functions)
|
||||
fprintf
|
||||
(structfile, " N_(\"%s\"), \"%s\" },\n",
|
||||
builtin->shortdoc ? builtin->shortdoc : builtin->name,
|
||||
document_name (builtin));
|
||||
/* Don't translate short document summaries that are identical
|
||||
to command names */
|
||||
if (builtin->shortdoc && strcmp (builtin->name, builtin->shortdoc) == 0)
|
||||
{
|
||||
if (inhibit_functions)
|
||||
fprintf (structfile, " \"%s\", \"%s\" },\n",
|
||||
builtin->shortdoc ? builtin->shortdoc : builtin->name,
|
||||
document_name (builtin));
|
||||
else
|
||||
fprintf (structfile, " \"%s\", (char *)NULL },\n",
|
||||
builtin->shortdoc ? builtin->shortdoc : builtin->name);
|
||||
}
|
||||
else
|
||||
fprintf
|
||||
(structfile, " N_(\"%s\"), (char *)NULL },\n",
|
||||
builtin->shortdoc ? builtin->shortdoc : builtin->name);
|
||||
|
||||
{
|
||||
if (inhibit_functions)
|
||||
fprintf (structfile, " N_(\"%s\"), \"%s\" },\n",
|
||||
builtin->shortdoc ? builtin->shortdoc : builtin->name,
|
||||
document_name (builtin));
|
||||
else
|
||||
fprintf (structfile, " N_(\"%s\"), (char *)NULL },\n",
|
||||
builtin->shortdoc ? builtin->shortdoc : builtin->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (structfile || separate_helpfiles)
|
||||
|
|
@ -1607,6 +1631,13 @@ is_assignment_builtin (name)
|
|||
return (_find_in_table (name, assignment_builtins));
|
||||
}
|
||||
|
||||
static int
|
||||
is_localvar_builtin (name)
|
||||
char *name;
|
||||
{
|
||||
return (_find_in_table (name, localvar_builtins));
|
||||
}
|
||||
|
||||
static int
|
||||
is_posix_builtin (name)
|
||||
char *name;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is printf.def, from which is created printf.c.
|
||||
It implements the builtin "printf" in Bash.
|
||||
|
||||
Copyright (C) 1997-2010 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -40,8 +40,8 @@ printf interprets:
|
|||
|
||||
%b expand backslash escape sequences in the corresponding argument
|
||||
%q quote the argument in a way that can be reused as shell input
|
||||
%(fmt)T output the date-time string resulting from using FMT as a format
|
||||
string for strftime(3)
|
||||
%(fmt)T output the date-time string resulting from using FMT as a format
|
||||
string for strftime(3)
|
||||
|
||||
The format is re-used as necessary to consume all of the arguments. If
|
||||
there are fewer arguments than the format requires, extra format
|
||||
|
|
@ -116,6 +116,7 @@ extern int errno;
|
|||
vbadd (b, 1); \
|
||||
else \
|
||||
putchar (c); \
|
||||
QUIT; \
|
||||
} while (0)
|
||||
|
||||
#define PF(f, func) \
|
||||
|
|
@ -131,6 +132,7 @@ extern int errno;
|
|||
else \
|
||||
nw = vflag ? vbprintf (f, func) : printf (f, func); \
|
||||
tw += nw; \
|
||||
QUIT; \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
sh_wrerror (); \
|
||||
|
|
@ -143,6 +145,7 @@ extern int errno;
|
|||
#define PRETURN(value) \
|
||||
do \
|
||||
{ \
|
||||
QUIT; \
|
||||
if (vflag) \
|
||||
{ \
|
||||
bind_printf_variable (vname, vbuf, 0); \
|
||||
|
|
@ -162,9 +165,9 @@ extern int errno;
|
|||
} \
|
||||
else if (vbuf) \
|
||||
vbuf[0] = 0; \
|
||||
terminate_immediately--; \
|
||||
if (ferror (stdout) == 0) \
|
||||
fflush (stdout); \
|
||||
QUIT; \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
sh_wrerror (); \
|
||||
|
|
@ -255,7 +258,7 @@ printf_builtin (list)
|
|||
case 'v':
|
||||
vname = list_optarg;
|
||||
#if defined (ARRAY_VARS)
|
||||
if (legal_identifier (vname) || valid_array_reference (vname))
|
||||
if (legal_identifier (vname) || valid_array_reference (vname, 0))
|
||||
#else
|
||||
if (legal_identifier (vname))
|
||||
#endif
|
||||
|
|
@ -273,6 +276,7 @@ printf_builtin (list)
|
|||
return (EX_USAGE);
|
||||
}
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -286,6 +290,14 @@ printf_builtin (list)
|
|||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
/* Allow printf -v var "" to act like var="" */
|
||||
if (vflag && list->word->word && list->word->word[0] == '\0')
|
||||
{
|
||||
bind_printf_variable (vname, "", 0);
|
||||
stupidly_hack_special_variables (vname);
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
if (list->word->word == 0 || list->word->word[0] == '\0')
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
|
|
@ -298,8 +310,6 @@ printf_builtin (list)
|
|||
if (format == 0 || *format == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
terminate_immediately++;
|
||||
|
||||
/* Basic algorithm is to scan the format string for conversion
|
||||
specifications -- once one is found, find out if the field
|
||||
width or precision is a '*'; if it is, gather up value. Note,
|
||||
|
|
@ -409,6 +419,7 @@ printf_builtin (list)
|
|||
modstart[0] = convch;
|
||||
modstart[1] = '\0';
|
||||
|
||||
QUIT;
|
||||
switch(convch)
|
||||
{
|
||||
case 'c':
|
||||
|
|
@ -759,6 +770,8 @@ printstr (fmt, string, len, fieldwidth, precision)
|
|||
/* Error if precision > INT_MAX here? */
|
||||
pr = (mpr < 0 || mpr > INT_MAX) ? INT_MAX : mpr;
|
||||
}
|
||||
else
|
||||
pr = 0; /* "a null digit string is treated as zero" */
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
@ -1045,7 +1058,7 @@ vbprintf (format, va_alist)
|
|||
|
||||
#ifdef DEBUG
|
||||
if (strlen (vbuf) != vblen)
|
||||
internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||
internal_error ("printf:vbprintf: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||
#endif
|
||||
|
||||
return (blen);
|
||||
|
|
@ -1255,7 +1268,7 @@ bind_printf_variable (name, value, flags)
|
|||
SHELL_VAR *v;
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (valid_array_reference (name) == 0)
|
||||
if (valid_array_reference (name, 0) == 0)
|
||||
v = bind_variable (name, value, flags);
|
||||
else
|
||||
v = assign_array_element (name, value, flags);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is pushd.def, from which is created pushd.c. It implements the
|
||||
builtins "pushd", "popd", and "dirs" in Bash.
|
||||
|
||||
Copyright (C) 1987-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -32,19 +32,19 @@ directory. With no arguments, exchanges the top two directories.
|
|||
|
||||
Options:
|
||||
-n Suppresses the normal change of directory when adding
|
||||
directories to the stack, so only the stack is manipulated.
|
||||
directories to the stack, so only the stack is manipulated.
|
||||
|
||||
Arguments:
|
||||
+N Rotates the stack so that the Nth directory (counting
|
||||
from the left of the list shown by `dirs', starting with
|
||||
zero) is at the top.
|
||||
from the left of the list shown by `dirs', starting with
|
||||
zero) is at the top.
|
||||
|
||||
-N Rotates the stack so that the Nth directory (counting
|
||||
from the right of the list shown by `dirs', starting with
|
||||
zero) is at the top.
|
||||
from the right of the list shown by `dirs', starting with
|
||||
zero) is at the top.
|
||||
|
||||
dir Adds DIR to the directory stack at the top, making it the
|
||||
new current working directory.
|
||||
new current working directory.
|
||||
|
||||
The `dirs' builtin displays the directory stack.
|
||||
|
||||
|
|
@ -64,16 +64,16 @@ the top directory from the stack, and changes to the new top directory.
|
|||
|
||||
Options:
|
||||
-n Suppresses the normal change of directory when removing
|
||||
directories from the stack, so only the stack is manipulated.
|
||||
directories from the stack, so only the stack is manipulated.
|
||||
|
||||
Arguments:
|
||||
+N Removes the Nth entry counting from the left of the list
|
||||
shown by `dirs', starting with zero. For example: `popd +0'
|
||||
removes the first directory, `popd +1' the second.
|
||||
shown by `dirs', starting with zero. For example: `popd +0'
|
||||
removes the first directory, `popd +1' the second.
|
||||
|
||||
-N Removes the Nth entry counting from the right of the list
|
||||
shown by `dirs', starting with zero. For example: `popd -0'
|
||||
removes the last directory, `popd -1' the next to last.
|
||||
shown by `dirs', starting with zero. For example: `popd -0'
|
||||
removes the last directory, `popd -1' the next to last.
|
||||
|
||||
The `dirs' builtin displays the directory stack.
|
||||
|
||||
|
|
@ -95,17 +95,19 @@ back up through the list with the `popd' command.
|
|||
Options:
|
||||
-c clear the directory stack by deleting all of the elements
|
||||
-l do not print tilde-prefixed versions of directories relative
|
||||
to your home directory
|
||||
to your home directory
|
||||
-p print the directory stack with one entry per line
|
||||
-v print the directory stack with one entry per line prefixed
|
||||
with its position in the stack
|
||||
with its position in the stack
|
||||
|
||||
Arguments:
|
||||
+N Displays the Nth entry counting from the left of the list shown by
|
||||
dirs when invoked without options, starting with zero.
|
||||
+N Displays the Nth entry counting from the left of the list
|
||||
shown by dirs when invoked without options, starting with
|
||||
zero.
|
||||
|
||||
-N Displays the Nth entry counting from the right of the list shown by
|
||||
dirs when invoked without options, starting with zero.
|
||||
-N Displays the Nth entry counting from the right of the list
|
||||
shown by dirs when invoked without options, starting with
|
||||
zero.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied or an error occurs.
|
||||
|
|
@ -178,6 +180,8 @@ pushd_builtin (list)
|
|||
char direction;
|
||||
|
||||
orig_list = list;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
if (list && list->word && ISOPTION (list->word->word, '-'))
|
||||
{
|
||||
list = list->next;
|
||||
|
|
@ -321,6 +325,8 @@ popd_builtin (list)
|
|||
char direction;
|
||||
char *which_word;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
which_word = (char *)NULL;
|
||||
for (flags = 0, which = 0, direction = '+'; list; list = list->next)
|
||||
{
|
||||
|
|
@ -402,6 +408,7 @@ dirs_builtin (list)
|
|||
intmax_t i;
|
||||
char *temp, *w;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
for (flags = vflag = index_flag = 0, desired_index = -1, w = ""; list; list = list->next)
|
||||
{
|
||||
if (ISOPTION (list->word->word, 'l'))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is read.def, from which is created read.c.
|
||||
It implements the builtin "read" in Bash.
|
||||
|
||||
Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -39,25 +39,27 @@ Options:
|
|||
variable ARRAY, starting at zero
|
||||
-d delim continue until the first character of DELIM is read, rather
|
||||
than newline
|
||||
-e use Readline to obtain the line in an interactive shell
|
||||
-i text Use TEXT as the initial text for Readline
|
||||
-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, but honor a delimiter if fewer than NCHARS
|
||||
characters are read before the delimiter
|
||||
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
|
||||
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
|
||||
-s do not echo input coming from a terminal
|
||||
-t timeout time out and return failure if a complete line of input is
|
||||
not read within TIMEOUT seconds. The value of the TMOUT
|
||||
variable is the default timeout. TIMEOUT may be a
|
||||
fractional number. If TIMEOUT is 0, read returns immediately,
|
||||
without trying to read any data, returning success only if
|
||||
input is available on the specified file descriptor. The
|
||||
exit status is greater than 128 if the timeout is exceeded
|
||||
-u fd read from file descriptor FD instead of the standard input
|
||||
-r do not allow backslashes to escape any characters
|
||||
-s do not echo input coming from a terminal
|
||||
-t timeout time out and return failure if a complete line of
|
||||
input is not read within TIMEOUT seconds. The value of the
|
||||
TMOUT variable is the default timeout. TIMEOUT may be a
|
||||
fractional number. If TIMEOUT is 0, read returns
|
||||
immediately, without trying to read any data, returning
|
||||
success only if input is available on the specified
|
||||
file descriptor. The exit status is greater than 128
|
||||
if the timeout is exceeded
|
||||
-u fd read from file descriptor FD instead of the standard input
|
||||
|
||||
Exit Status:
|
||||
The return code is zero, unless end-of-file is encountered, read times out
|
||||
|
|
@ -163,8 +165,9 @@ sigalrm (s)
|
|||
static void
|
||||
reset_alarm ()
|
||||
{
|
||||
set_signal_handler (SIGALRM, old_alrm);
|
||||
/* Cancel alarm before restoring signal handler. */
|
||||
falarm (0, 0);
|
||||
set_signal_handler (SIGALRM, old_alrm);
|
||||
}
|
||||
|
||||
/* Read the value of the shell variables whose names follow.
|
||||
|
|
@ -314,6 +317,7 @@ read_builtin (list)
|
|||
case 'd':
|
||||
delim = *list_optarg;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -333,7 +337,7 @@ read_builtin (list)
|
|||
/* Convenience: check early whether or not the first of possibly several
|
||||
variable names is a valid identifier, and bail early if so. */
|
||||
#if defined (ARRAY_VARS)
|
||||
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word) == 0)
|
||||
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, 0) == 0)
|
||||
#else
|
||||
if (list && legal_identifier (list->word->word) == 0)
|
||||
#endif
|
||||
|
|
@ -793,7 +797,10 @@ assign_vars:
|
|||
}
|
||||
else
|
||||
var = bind_variable ("REPLY", input_string, 0);
|
||||
VUNSETATTR (var, att_invisible);
|
||||
if (var == 0 || readonly_p (var) || noassign_p (var))
|
||||
retval = EXECUTION_FAILURE;
|
||||
else
|
||||
VUNSETATTR (var, att_invisible);
|
||||
|
||||
xfree (input_string);
|
||||
return (retval);
|
||||
|
|
@ -812,7 +819,7 @@ assign_vars:
|
|||
{
|
||||
varname = list->word->word;
|
||||
#if defined (ARRAY_VARS)
|
||||
if (legal_identifier (varname) == 0 && valid_array_reference (varname) == 0)
|
||||
if (legal_identifier (varname) == 0 && valid_array_reference (varname, 0) == 0)
|
||||
#else
|
||||
if (legal_identifier (varname) == 0)
|
||||
#endif
|
||||
|
|
@ -860,7 +867,7 @@ assign_vars:
|
|||
|
||||
/* Now assign the rest of the line to the last variable argument. */
|
||||
#if defined (ARRAY_VARS)
|
||||
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word) == 0)
|
||||
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, 0) == 0)
|
||||
#else
|
||||
if (legal_identifier (list->word->word) == 0)
|
||||
#endif
|
||||
|
|
@ -923,7 +930,7 @@ bind_read_variable (name, value)
|
|||
SHELL_VAR *v;
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (valid_array_reference (name) == 0)
|
||||
if (valid_array_reference (name, 0) == 0)
|
||||
v = bind_variable (name, value, 0);
|
||||
else
|
||||
v = assign_array_element (name, value, 0);
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ to indices 0 and 1 of an array variable NAME in the executing shell.
|
|||
The default NAME is "COPROC".
|
||||
|
||||
Exit Status:
|
||||
Returns the exit status of COMMAND.
|
||||
The coproc command returns an exit status of 0.
|
||||
$END
|
||||
|
||||
$BUILTIN function
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is return.def, from which is created return.c.
|
||||
It implements the builtin "return" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -60,16 +60,12 @@ int
|
|||
return_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
#if 0
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
list = loptend; /* skip over possible `--' */
|
||||
#endif
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
return_catch_value = get_exitstat (list);
|
||||
|
||||
if (return_catch_flag)
|
||||
longjmp (return_catch, 1);
|
||||
sh_longjmp (return_catch, 1);
|
||||
else
|
||||
{
|
||||
builtin_error (_("can only `return' from a function or sourced script"));
|
||||
|
|
|
|||
128
builtins/set.def
128
builtins/set.def
|
|
@ -1,7 +1,7 @@
|
|||
This file is set.def, from which is created set.c.
|
||||
It implements the "set" and "unset" builtins in Bash.
|
||||
|
||||
Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ Options:
|
|||
#endif /* BANG_HISTORY */
|
||||
-P If set, do not resolve symbolic links when executing commands
|
||||
such as cd which change the current directory.
|
||||
-T If set, the DEBUG trap is inherited by shell functions.
|
||||
-T If set, the DEBUG and RETURN traps are inherited by shell functions.
|
||||
-- Assign any remaining arguments to the positional parameters.
|
||||
If there are no remaining arguments, the positional parameters
|
||||
are unset.
|
||||
|
|
@ -179,9 +179,13 @@ static int bash_set_history __P((int, char *));
|
|||
static const char * const on = "on";
|
||||
static const char * const off = "off";
|
||||
|
||||
static int previous_option_value;
|
||||
|
||||
/* A struct used to match long options for set -o to the corresponding
|
||||
option letter or internal variable. The functions can be called to
|
||||
dynamically generate values. */
|
||||
dynamically generate values. If you add a new variable name here
|
||||
that doesn't have a corresponding single-character option letter, make
|
||||
sure to set the value appropriately in reset_shell_options. */
|
||||
const struct {
|
||||
char *name;
|
||||
int letter;
|
||||
|
|
@ -322,17 +326,52 @@ get_minus_o_opts ()
|
|||
return ret;
|
||||
}
|
||||
|
||||
char *
|
||||
get_current_options ()
|
||||
{
|
||||
char *temp;
|
||||
int i;
|
||||
|
||||
temp = (char *)xmalloc (1 + N_O_OPTIONS);
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
{
|
||||
if (o_options[i].letter)
|
||||
temp[i] = *(find_flag (o_options[i].letter));
|
||||
else
|
||||
temp[i] = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
|
||||
}
|
||||
temp[i] = '\0';
|
||||
return (temp);
|
||||
}
|
||||
|
||||
void
|
||||
set_current_options (bitmap)
|
||||
const char *bitmap;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (bitmap == 0)
|
||||
return;
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
{
|
||||
if (o_options[i].letter)
|
||||
change_flag (o_options[i].letter, bitmap[i] ? FLAG_ON : FLAG_OFF);
|
||||
else
|
||||
SET_BINARY_O_OPTION_VALUE (i, bitmap[i] ? FLAG_ON : FLAG_OFF, o_options[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
set_ignoreeof (on_or_off, option_name)
|
||||
int on_or_off;
|
||||
char *option_name;
|
||||
{
|
||||
ignoreeof = on_or_off == FLAG_ON;
|
||||
unbind_variable ("ignoreeof");
|
||||
unbind_variable_noref ("ignoreeof");
|
||||
if (ignoreeof)
|
||||
bind_variable ("IGNOREEOF", "10", 0);
|
||||
else
|
||||
unbind_variable ("IGNOREEOF");
|
||||
unbind_variable_noref ("IGNOREEOF");
|
||||
sv_ignoreeof ("IGNOREEOF");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -344,7 +383,7 @@ set_posix_mode (on_or_off, option_name)
|
|||
{
|
||||
posixly_correct = on_or_off == FLAG_ON;
|
||||
if (posixly_correct == 0)
|
||||
unbind_variable ("POSIXLY_CORRECT");
|
||||
unbind_variable_noref ("POSIXLY_CORRECT");
|
||||
else
|
||||
bind_variable ("POSIXLY_CORRECT", "y", 0);
|
||||
sv_strict_posix ("POSIXLY_CORRECT");
|
||||
|
|
@ -425,12 +464,13 @@ set_minus_o_option (on_or_off, option_name)
|
|||
{
|
||||
if (o_options[i].letter == 0)
|
||||
{
|
||||
previous_option_value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
|
||||
SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (change_flag (o_options[i].letter, on_or_off) == FLAG_ERROR)
|
||||
if ((previous_option_value = change_flag (o_options[i].letter, on_or_off)) == FLAG_ERROR)
|
||||
{
|
||||
sh_invalidoptname (option_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
|
|
@ -585,10 +625,18 @@ initialize_shell_options (no_shellopts)
|
|||
void
|
||||
reset_shell_options ()
|
||||
{
|
||||
pipefail_opt = 0;
|
||||
ignoreeof = 0;
|
||||
|
||||
#if defined (STRICT_POSIX)
|
||||
posixly_correct = 1;
|
||||
#else
|
||||
posixly_correct = 0;
|
||||
#endif
|
||||
#if defined (HISTORY)
|
||||
dont_save_function_defs = 0;
|
||||
remember_on_history = enable_history_list = 1;
|
||||
#endif
|
||||
ignoreeof = 0;
|
||||
}
|
||||
|
||||
/* Set some flags from the word values in the input list. If LIST is empty,
|
||||
|
|
@ -615,6 +663,14 @@ set_builtin (list)
|
|||
{
|
||||
switch (flag_name)
|
||||
{
|
||||
case 'i': /* don't allow set -i */
|
||||
s[0] = list_opttype;
|
||||
s[1] = 'i';
|
||||
s[2] = '\0';
|
||||
sh_invalidopt (s);
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
CASE_HELPOPT;
|
||||
case '?':
|
||||
builtin_usage ();
|
||||
return (list_optopt == '?' ? EXECUTION_SUCCESS : EX_USAGE);
|
||||
|
|
@ -733,7 +789,7 @@ Options:
|
|||
-f treat each NAME as a shell function
|
||||
-v treat each NAME as a shell variable
|
||||
-n treat each NAME as a name reference and unset the variable itself
|
||||
rather than the variable it references
|
||||
rather than the variable it references
|
||||
|
||||
Without options, unset first tries to unset a variable, and if that fails,
|
||||
tries to unset a function.
|
||||
|
|
@ -752,7 +808,7 @@ unset_builtin (list)
|
|||
{
|
||||
int unset_function, unset_variable, unset_array, opt, nameref, any_failed;
|
||||
int global_unset_func, global_unset_var;
|
||||
char *name;
|
||||
char *name, *tname;
|
||||
|
||||
unset_function = unset_variable = unset_array = nameref = any_failed = 0;
|
||||
global_unset_func = global_unset_var = 0;
|
||||
|
|
@ -771,6 +827,7 @@ unset_builtin (list)
|
|||
case 'n':
|
||||
nameref = 1;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -802,7 +859,7 @@ unset_builtin (list)
|
|||
|
||||
#if defined (ARRAY_VARS)
|
||||
unset_array = 0;
|
||||
if (!unset_function && valid_array_reference (name))
|
||||
if (!unset_function && nameref == 0 && valid_array_reference (name, 0))
|
||||
{
|
||||
t = strchr (name, '[');
|
||||
*t++ = '\0';
|
||||
|
|
@ -823,7 +880,7 @@ unset_builtin (list)
|
|||
|
||||
/* Only search for functions here if -f supplied. */
|
||||
var = unset_function ? find_function (name)
|
||||
: (nameref ? find_variable_last_nameref (name) : find_variable (name));
|
||||
: (nameref ? find_variable_last_nameref (name, 0) : find_variable (name));
|
||||
|
||||
/* Some variables (but not functions yet) cannot be unset, period. */
|
||||
if (var && unset_function == 0 && non_unsettable_p (var))
|
||||
|
|
@ -832,11 +889,15 @@ unset_builtin (list)
|
|||
NEXT_VARIABLE ();
|
||||
}
|
||||
|
||||
/* if we have a nameref we want to use it */
|
||||
if (var && unset_function == 0 && nameref == 0 && STREQ (name, name_cell(var)) == 0)
|
||||
name = name_cell (var);
|
||||
|
||||
/* Posix.2 says try variables first, then functions. If we would
|
||||
find a function after unsuccessfully searching for a variable,
|
||||
note that we're acting on a function now as if -f were
|
||||
supplied. The readonly check below takes care of it. */
|
||||
if (var == 0 && unset_variable == 0 && unset_function == 0)
|
||||
if (var == 0 && nameref == 0 && unset_variable == 0 && unset_function == 0)
|
||||
{
|
||||
if (var = find_function (name))
|
||||
unset_function = 1;
|
||||
|
|
@ -854,29 +915,52 @@ unset_builtin (list)
|
|||
#if defined (ARRAY_VARS)
|
||||
if (var && unset_array)
|
||||
{
|
||||
if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
/* Let unbind_array_element decide what to do with non-array vars */
|
||||
tem = unbind_array_element (var, t);
|
||||
if (tem == -2 && array_p (var) == 0 && assoc_p (var) == 0)
|
||||
{
|
||||
builtin_error (_("%s: not an array variable"), var->name);
|
||||
NEXT_VARIABLE ();
|
||||
}
|
||||
else
|
||||
{
|
||||
tem = unbind_array_element (var, t);
|
||||
if (tem == -1)
|
||||
any_failed++;
|
||||
}
|
||||
else if (tem < 0)
|
||||
any_failed++;
|
||||
}
|
||||
else
|
||||
#endif /* ARRAY_VARS */
|
||||
tem = unset_function ? unbind_func (name) : (nameref ? unbind_nameref (name) : unbind_variable (name));
|
||||
/* If we're trying to unset a nameref variable whose value isn't a set
|
||||
variable, make sure we still try to unset the nameref's value */
|
||||
if (var == 0 && nameref == 0 && unset_function == 0)
|
||||
{
|
||||
var = find_variable_last_nameref (name, 0);
|
||||
if (var && nameref_p (var))
|
||||
{
|
||||
#if defined (ARRAY_VARS)
|
||||
if (valid_array_reference (nameref_cell (var), 0))
|
||||
{
|
||||
tname = savestring (nameref_cell (var));
|
||||
if (var = array_variable_part (tname, &t, 0))
|
||||
tem = unbind_array_element (var, t);
|
||||
free (tname);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
tem = unbind_variable (nameref_cell (var));
|
||||
}
|
||||
else
|
||||
tem = unbind_variable (name);
|
||||
}
|
||||
else
|
||||
tem = unset_function ? unbind_func (name) : (nameref ? unbind_nameref (name) : unbind_variable (name));
|
||||
|
||||
/* This is what Posix.2 says: ``If neither -f nor -v
|
||||
is specified, the name refers to a variable; if a variable by
|
||||
that name does not exist, a function by that name, if any,
|
||||
shall be unset.'' */
|
||||
if (tem == -1 && unset_function == 0 && unset_variable == 0)
|
||||
if (tem == -1 && nameref == 0 && unset_function == 0 && unset_variable == 0)
|
||||
tem = unbind_func (name);
|
||||
|
||||
name = list->word->word; /* reset above for namerefs */
|
||||
|
||||
/* SUSv3, POSIX.1-2001 say: ``Unsetting a variable or function that
|
||||
was not previously set shall not be considered an error.'' */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is setattr.def, from which is created setattr.c.
|
||||
It implements the builtins "export" and "readonly", in Bash.
|
||||
|
||||
Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -34,6 +34,7 @@ $PRODUCES setattr.c
|
|||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../flags.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
|
|
@ -93,8 +94,8 @@ Options:
|
|||
-a refer to indexed array variables
|
||||
-A refer to associative array variables
|
||||
-f refer to shell functions
|
||||
-p display a list of all readonly variables or functions, depending on
|
||||
whether or not the -f option is given
|
||||
-p display a list of all readonly variables or functions,
|
||||
depending on whether or not the -f option is given
|
||||
|
||||
An argument of `--' disables further option processing.
|
||||
|
||||
|
|
@ -133,6 +134,8 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
#if defined (ARRAY_VARS)
|
||||
WORD_LIST *nlist, *tlist;
|
||||
WORD_DESC *w;
|
||||
char optw[8];
|
||||
int opti;
|
||||
#endif
|
||||
|
||||
functions_only = arrays_only = assoc_only = 0;
|
||||
|
|
@ -159,6 +162,7 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
#endif
|
||||
case 'p':
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -187,6 +191,11 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
builtin_error (_("%s: not a function"), name);
|
||||
any_failed++;
|
||||
}
|
||||
else if ((attribute & att_exported) && undo == 0 && exportable_function_name (name) == 0)
|
||||
{
|
||||
builtin_error (_("%s: cannot export"), name);
|
||||
any_failed++;
|
||||
}
|
||||
else
|
||||
SETVARATTR (var, attribute, undo);
|
||||
|
||||
|
|
@ -231,8 +240,24 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
{
|
||||
tlist = list->next;
|
||||
list->next = (WORD_LIST *)NULL;
|
||||
w = arrays_only ? make_word ("-ra") : make_word ("-rA");
|
||||
/* Add -g to avoid readonly/export creating local variables:
|
||||
only local/declare/typeset create local variables */
|
||||
opti = 0;
|
||||
optw[opti++] = '-';
|
||||
optw[opti++] = 'g';
|
||||
if (attribute & att_readonly)
|
||||
optw[opti++] = 'r';
|
||||
if (attribute & att_exported)
|
||||
optw[opti++] = 'x';
|
||||
if (arrays_only)
|
||||
optw[opti++] = 'a';
|
||||
else
|
||||
optw[opti++] = 'A';
|
||||
optw[opti] = '\0';
|
||||
|
||||
w = make_word (optw);
|
||||
nlist = make_word_list (w, list);
|
||||
|
||||
opt = declare_builtin (nlist);
|
||||
if (opt != EXECUTION_SUCCESS)
|
||||
assign_error++;
|
||||
|
|
@ -296,6 +321,12 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
else if (assoc_only && assoc_p (var) == 0)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
/* If we imported a variable that's not a valid identifier, don't
|
||||
show it in any lists. */
|
||||
if ((var->attributes & (att_invisible|att_imported)) == (att_invisible|att_imported))
|
||||
continue;
|
||||
|
||||
if ((var->attributes & attribute))
|
||||
{
|
||||
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
|
||||
|
|
@ -336,18 +367,12 @@ show_all_var_attributes (v, nodefs)
|
|||
return (any_failed == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
/* Show the attributes for shell variable VAR. If NODEFS is non-zero,
|
||||
don't show function definitions along with the name. If PATTR is
|
||||
non-zero, it indicates we're being called from `export' or `readonly'.
|
||||
In POSIX mode, this prints the name of the calling builtin (`export'
|
||||
or `readonly') instead of `declare', and doesn't print function defs
|
||||
when called by `export' or `readonly'. */
|
||||
int
|
||||
show_var_attributes (var, pattr, nodefs)
|
||||
var_attribute_string (var, pattr, flags)
|
||||
SHELL_VAR *var;
|
||||
int pattr, nodefs;
|
||||
int pattr;
|
||||
char *flags; /* filled in with attributes */
|
||||
{
|
||||
char flags[16], *x;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
|
|
@ -405,6 +430,24 @@ show_var_attributes (var, pattr, nodefs)
|
|||
}
|
||||
|
||||
flags[i] = '\0';
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Show the attributes for shell variable VAR. If NODEFS is non-zero,
|
||||
don't show function definitions along with the name. If PATTR is
|
||||
non-zero, it indicates we're being called from `export' or `readonly'.
|
||||
In POSIX mode, this prints the name of the calling builtin (`export'
|
||||
or `readonly') instead of `declare', and doesn't print function defs
|
||||
when called by `export' or `readonly'. */
|
||||
int
|
||||
show_var_attributes (var, pattr, nodefs)
|
||||
SHELL_VAR *var;
|
||||
int pattr, nodefs;
|
||||
{
|
||||
char flags[MAX_ATTRIBUTES], *x;
|
||||
int i;
|
||||
|
||||
i = var_attribute_string (var, pattr, flags);
|
||||
|
||||
/* If we're printing functions with definitions, print the function def
|
||||
first, then the attributes, instead of printing output that can't be
|
||||
|
|
@ -425,10 +468,12 @@ show_var_attributes (var, pattr, nodefs)
|
|||
printf ("%s ", this_command_name);
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (array_p (var))
|
||||
print_array_assignment (var, 1);
|
||||
if (invisible_p (var) && (array_p (var) || assoc_p (var)))
|
||||
printf ("%s\n", var->name);
|
||||
else if (array_p (var))
|
||||
print_array_assignment (var, 0);
|
||||
else if (assoc_p (var))
|
||||
print_assoc_assignment (var, 1);
|
||||
print_assoc_assignment (var, 0);
|
||||
else
|
||||
#endif
|
||||
/* force `readonly' and `export' to not print out function definitions
|
||||
|
|
@ -461,7 +506,7 @@ show_name_attributes (name, nodefs)
|
|||
var = find_variable_noref (name);
|
||||
#endif
|
||||
|
||||
if (var && invisible_p (var) == 0)
|
||||
if (var /* && invisible_p (var) == 0 */) /* XXX bash-4.4/bash-5.0 */
|
||||
{
|
||||
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
|
||||
return (0);
|
||||
|
|
@ -493,8 +538,8 @@ set_var_attribute (name, attribute, undo)
|
|||
char *name;
|
||||
int attribute, undo;
|
||||
{
|
||||
SHELL_VAR *var, *tv, *v;
|
||||
char *tvalue;
|
||||
SHELL_VAR *var, *tv, *v, *refvar;
|
||||
char *tvalue, *refname;
|
||||
|
||||
if (undo)
|
||||
var = find_variable (name);
|
||||
|
|
@ -509,6 +554,11 @@ set_var_attribute (name, attribute, undo)
|
|||
tvalue = var_isset (tv) ? savestring (value_cell (tv)) : savestring ("");
|
||||
|
||||
var = bind_variable (tv->name, tvalue, 0);
|
||||
if (var == 0)
|
||||
{
|
||||
free (tvalue);
|
||||
return; /* XXX - no error message here */
|
||||
}
|
||||
var->attributes |= tv->attributes & ~att_tempvar;
|
||||
/* This avoids an error message when propagating a read-only var
|
||||
later on. */
|
||||
|
|
@ -533,10 +583,23 @@ set_var_attribute (name, attribute, undo)
|
|||
else
|
||||
{
|
||||
var = find_variable_notempenv (name);
|
||||
if (var == 0)
|
||||
{
|
||||
/* We might have a nameref pointing to something that we can't
|
||||
resolve to a shell variable. If we do, skip it. We do a little
|
||||
checking just so we can print an error message. */
|
||||
refvar = find_variable_nameref_for_create (name, 0);
|
||||
if (refvar == INVALID_NAMEREF_VALUE)
|
||||
return;
|
||||
/* Otherwise we probably have a nameref pointing to a variable
|
||||
that hasn't been created yet. bind_variable will take care
|
||||
of that. */
|
||||
}
|
||||
if (var == 0)
|
||||
{
|
||||
var = bind_variable (name, (char *)NULL, 0);
|
||||
VSETATTR (var, att_invisible);
|
||||
if (var && no_invisible_vars == 0)
|
||||
VSETATTR (var, att_invisible);
|
||||
}
|
||||
else if (var->context != 0)
|
||||
VSETATTR (var, att_propagate);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ shift_builtin (list)
|
|||
register int count;
|
||||
WORD_LIST *temp;
|
||||
|
||||
CHECK_HELPOPT (list);
|
||||
|
||||
if (get_numeric_arg (list, 0, ×) == 0)
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
|
|
@ -97,5 +99,8 @@ shift_builtin (list)
|
|||
else
|
||||
dollar_vars[9] = (char *)NULL;
|
||||
}
|
||||
|
||||
invalidate_cached_quoted_dollar_at ();
|
||||
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is shopt.def, from which is created shopt.c.
|
||||
It implements the Bash `shopt' builtin.
|
||||
|
||||
Copyright (C) 1994-2012 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -90,6 +90,7 @@ extern int autocd;
|
|||
extern int glob_star;
|
||||
extern int glob_asciirange;
|
||||
extern int lastpipe_opt;
|
||||
extern int inherit_errexit;
|
||||
|
||||
#if defined (EXTENDED_GLOB)
|
||||
extern int extended_glob;
|
||||
|
|
@ -131,15 +132,21 @@ static int set_restricted_shell __P((char *, int));
|
|||
static int shopt_set_complete_direxpand __P((char *, int));
|
||||
#endif
|
||||
|
||||
static int shopt_set_debug_mode __P((char *, int));
|
||||
|
||||
static int shopt_login_shell;
|
||||
static int shopt_compat31;
|
||||
static int shopt_compat32;
|
||||
static int shopt_compat40;
|
||||
static int shopt_compat41;
|
||||
static int shopt_compat42;
|
||||
static int shopt_compat43;
|
||||
|
||||
typedef int shopt_set_func_t __P((char *, int));
|
||||
|
||||
/* If you add a new variable name here, make sure to set the default value
|
||||
appropriately in reset_shopt_options. */
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
int *value;
|
||||
|
|
@ -161,6 +168,7 @@ static struct {
|
|||
{ "compat40", &shopt_compat40, set_compatibility_level },
|
||||
{ "compat41", &shopt_compat41, set_compatibility_level },
|
||||
{ "compat42", &shopt_compat42, set_compatibility_level },
|
||||
{ "compat43", &shopt_compat43, set_compatibility_level },
|
||||
#if defined (READLINE)
|
||||
{ "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
|
||||
{ "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
|
||||
|
|
@ -170,7 +178,7 @@ static struct {
|
|||
{ "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
|
||||
{ "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
|
||||
#if defined (DEBUGGER)
|
||||
{ "extdebug", &debugging_mode, (shopt_set_func_t *)NULL },
|
||||
{ "extdebug", &debugging_mode, shopt_set_debug_mode },
|
||||
#endif
|
||||
#if defined (EXTENDED_GLOB)
|
||||
{ "extglob", &extended_glob, (shopt_set_func_t *)NULL },
|
||||
|
|
@ -180,8 +188,8 @@ static struct {
|
|||
#if defined (READLINE)
|
||||
{ "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "globstar", &glob_star, (shopt_set_func_t *)NULL },
|
||||
{ "globasciiranges", &glob_asciirange, (shopt_set_func_t *)NULL },
|
||||
{ "globstar", &glob_star, (shopt_set_func_t *)NULL },
|
||||
{ "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL },
|
||||
#if defined (HISTORY)
|
||||
{ "histappend", &force_append_history, (shopt_set_func_t *)NULL },
|
||||
|
|
@ -192,6 +200,7 @@ static struct {
|
|||
{ "hostcomplete", &perform_hostname_completion, shopt_enable_hostname_completion },
|
||||
#endif
|
||||
{ "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL },
|
||||
{ "inherit_errexit", &inherit_errexit, (shopt_set_func_t *)NULL },
|
||||
{ "interactive_comments", &interactive_comments, set_shellopts_after_change },
|
||||
{ "lastpipe", &lastpipe_opt, (shopt_set_func_t *)NULL },
|
||||
#if defined (HISTORY)
|
||||
|
|
@ -267,6 +276,7 @@ shopt_builtin (list)
|
|||
case 'p':
|
||||
flags |= PFLAG;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -297,32 +307,67 @@ shopt_builtin (list)
|
|||
}
|
||||
|
||||
/* Reset the options managed by `shopt' to the values they would have at
|
||||
shell startup. */
|
||||
shell startup. Variables from shopt_vars. */
|
||||
void
|
||||
reset_shopt_options ()
|
||||
{
|
||||
autocd = cdable_vars = cdspelling = 0;
|
||||
check_hashed_filenames = CHECKHASH_DEFAULT;
|
||||
check_window_size = CHECKWINSIZE_DEFAULT;
|
||||
allow_null_glob_expansion = glob_dot_filenames = 0;
|
||||
cdable_vars = mail_warning = 0;
|
||||
no_exit_on_failed_exec = print_shift_error = 0;
|
||||
check_hashed_filenames = cdspelling = expand_aliases = 0;
|
||||
|
||||
no_exit_on_failed_exec = 0;
|
||||
expand_aliases = 0;
|
||||
extended_quote = 1;
|
||||
fail_glob_expansion = 0;
|
||||
glob_asciirange = GLOBASCII_DEFAULT;
|
||||
glob_star = 0;
|
||||
gnu_error_format = 0;
|
||||
hup_on_exit = 0;
|
||||
inherit_errexit = 0;
|
||||
interactive_comments = 1;
|
||||
lastpipe_opt = 0;
|
||||
mail_warning = 0;
|
||||
glob_ignore_case = match_ignore_case = 0;
|
||||
print_shift_error = 0;
|
||||
source_uses_path = promptvars = 1;
|
||||
|
||||
check_window_size = CHECKWINSIZE_DEFAULT;
|
||||
#if defined (JOB_CONTROL)
|
||||
check_jobs_at_exit = 0;
|
||||
#endif
|
||||
|
||||
#if defined (EXTENDED_GLOB)
|
||||
extended_glob = 0;
|
||||
extended_glob = EXTGLOB_DEFAULT;
|
||||
#endif
|
||||
|
||||
#if defined (HISTORY)
|
||||
literal_history = force_append_history = 0;
|
||||
literal_history = 0;
|
||||
force_append_history = 0;
|
||||
command_oriented_history = 1;
|
||||
#endif
|
||||
|
||||
#if defined (READLINE)
|
||||
complete_fullquote = 1;
|
||||
force_fignore = 1;
|
||||
hist_verify = history_reediting = 0;
|
||||
perform_hostname_completion = 1;
|
||||
# if DIRCOMPLETE_EXPAND_DEFAULT
|
||||
dircomplete_expand = 1;
|
||||
# else
|
||||
dircomplete_expand = 0;
|
||||
#endif
|
||||
dircomplete_spelling = 0;
|
||||
no_empty_command_completion = 0;
|
||||
#endif
|
||||
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
prog_completion_enabled = 1;
|
||||
#endif
|
||||
|
||||
#if defined (DEFAULT_ECHO_TO_XPG) || defined (STRICT_POSIX)
|
||||
xpg_echo = 1;
|
||||
#else
|
||||
xpg_echo = 0;
|
||||
#endif /* DEFAULT_ECHO_TO_XPG */
|
||||
|
||||
shopt_login_shell = login_shell;
|
||||
}
|
||||
|
|
@ -354,6 +399,7 @@ toggle_shopts (mode, list, quiet)
|
|||
{
|
||||
WORD_LIST *l;
|
||||
int ind, rval;
|
||||
SHELL_VAR *v;
|
||||
|
||||
for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
|
||||
{
|
||||
|
|
@ -371,7 +417,9 @@ toggle_shopts (mode, list, quiet)
|
|||
}
|
||||
}
|
||||
|
||||
set_bashopts ();
|
||||
/* Don't set $BASHOPTS here if it hasn't already been initialized */
|
||||
if (v = find_variable ("BASHOPTS"))
|
||||
set_bashopts ();
|
||||
return (rval);
|
||||
}
|
||||
|
||||
|
|
@ -516,6 +564,18 @@ set_shellopts_after_change (option_name, mode)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
shopt_set_debug_mode (option_name, mode)
|
||||
char *option_name;
|
||||
int mode;
|
||||
{
|
||||
#if defined (DEBUGGER)
|
||||
error_trace_mode = function_trace_mode = debugging_mode;
|
||||
set_shellopts ();
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
shopt_enable_hostname_completion (option_name, mode)
|
||||
char *option_name;
|
||||
|
|
@ -537,7 +597,7 @@ set_compatibility_level (option_name, mode)
|
|||
if (mode)
|
||||
{
|
||||
shopt_compat31 = shopt_compat32 = 0;
|
||||
shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
|
||||
shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0;
|
||||
ind = find_shopt (option_name);
|
||||
*shopt_vars[ind].value = mode;
|
||||
}
|
||||
|
|
@ -553,6 +613,8 @@ set_compatibility_level (option_name, mode)
|
|||
shell_compatibility_level = 41;
|
||||
else if (shopt_compat42)
|
||||
shell_compatibility_level = 42;
|
||||
else if (shopt_compat43)
|
||||
shell_compatibility_level = 43;
|
||||
else
|
||||
shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
|
||||
|
||||
|
|
@ -564,11 +626,14 @@ set_compatibility_level (option_name, mode)
|
|||
void
|
||||
set_compatibility_opts ()
|
||||
{
|
||||
shopt_compat31 = shopt_compat32 = shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
|
||||
shopt_compat31 = shopt_compat32 = 0;
|
||||
shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0;
|
||||
switch (shell_compatibility_level)
|
||||
{
|
||||
case DEFAULT_COMPAT_LEVEL:
|
||||
break;
|
||||
case 43:
|
||||
shopt_compat43 = 1; break;
|
||||
case 42:
|
||||
shopt_compat42 = 1; break;
|
||||
case 41:
|
||||
|
|
@ -745,7 +810,11 @@ parse_bashopts (value)
|
|||
{
|
||||
ind = find_shopt (vname);
|
||||
if (ind >= 0)
|
||||
*shopt_vars[ind].value = 1;
|
||||
{
|
||||
*shopt_vars[ind].value = 1;
|
||||
if (shopt_vars[ind].set_func)
|
||||
(*shopt_vars[ind].set_func) (shopt_vars[ind].name, 1);
|
||||
}
|
||||
free (vname);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is source.def, from which is created source.c.
|
||||
It implements the builtins "." and "source" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -108,6 +108,7 @@ maybe_pop_dollar_vars ()
|
|||
if (debugging_mode)
|
||||
pop_args (); /* restore BASH_ARGC and BASH_ARGV */
|
||||
set_dollar_vars_unchanged ();
|
||||
invalidate_cached_quoted_dollar_at (); /* just invalidate to be safe */
|
||||
}
|
||||
|
||||
/* Read and execute commands from the file passed as argument. Guess what.
|
||||
|
|
@ -119,7 +120,7 @@ source_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
int result;
|
||||
char *filename, *debug_trap;
|
||||
char *filename, *debug_trap, *x;
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
|
|
@ -152,7 +153,10 @@ source_builtin (list)
|
|||
{
|
||||
if (source_searches_cwd == 0)
|
||||
{
|
||||
builtin_error (_("%s: file not found"), list->word->word);
|
||||
x = printable_filename (list->word->word, 0);
|
||||
builtin_error (_("%s: file not found"), x);
|
||||
if (x != list->word->word)
|
||||
free (x);
|
||||
if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0)
|
||||
{
|
||||
last_command_exit_value = 1;
|
||||
|
|
@ -185,7 +189,7 @@ source_builtin (list)
|
|||
{
|
||||
debug_trap = savestring (debug_trap);
|
||||
add_unwind_protect (xfree, debug_trap);
|
||||
add_unwind_protect (set_debug_trap, debug_trap);
|
||||
add_unwind_protect (maybe_set_debug_trap, debug_trap);
|
||||
restore_default_signal (DEBUG_TRAP);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is suspend.def, from which is created suspend.c.
|
||||
It implements the builtin "suspend" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -89,6 +89,7 @@ suspend_builtin (list)
|
|||
case 'f':
|
||||
force++;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is test.def, from which is created test.c.
|
||||
It implements the builtin "test" in Bash.
|
||||
|
||||
Copyright (C) 1987-2010 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -83,8 +83,9 @@ String operators:
|
|||
Other operators:
|
||||
|
||||
-o OPTION True if the shell option OPTION is enabled.
|
||||
-v VAR True if the shell variable VAR is set
|
||||
-R VAR True if the shell variable VAR is set and is a name reference.
|
||||
-v VAR True if the shell variable VAR is set.
|
||||
-R VAR True if the shell variable VAR is set and is a name
|
||||
reference.
|
||||
! EXPR True if expr is false.
|
||||
EXPR1 -a EXPR2 True if both expr1 AND expr2 are true.
|
||||
EXPR1 -o EXPR2 True if either expr1 OR expr2 is true.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is trap.def, from which is created trap.c.
|
||||
It implements the builtin "trap" in Bash.
|
||||
|
||||
Copyright (C) 1987-2010 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ static int display_traps __P((WORD_LIST *));
|
|||
trap -p [sigspec ...]
|
||||
trap [--]
|
||||
|
||||
Set things up so that ARG is executed when SIGNAL(s) N is recieved.
|
||||
Set things up so that ARG is executed when SIGNAL(s) N is received.
|
||||
If ARG is the empty string, then ignore the SIGNAL(s). If there is
|
||||
no ARG, then set the trap for SIGNAL(s) to its original value. Just
|
||||
plain "trap" means to print out the list of commands associated with
|
||||
|
|
@ -119,6 +119,7 @@ trap_builtin (list)
|
|||
case 'p':
|
||||
display++;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is type.def, from which is created type.c.
|
||||
It implements the builtin "type" in Bash.
|
||||
|
||||
Copyright (C) 1987-2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -30,18 +30,18 @@ command name.
|
|||
|
||||
Options:
|
||||
-a display all locations containing an executable named NAME;
|
||||
includes aliases, builtins, and functions, if and only if
|
||||
the `-p' option is not also used
|
||||
includes aliases, builtins, and functions, if and only if
|
||||
the `-p' option is not also used
|
||||
-f suppress shell function lookup
|
||||
-P force a PATH search for each NAME, even if it is an alias,
|
||||
builtin, or function, and returns the name of the disk file
|
||||
that would be executed
|
||||
builtin, or function, and returns the name of the disk file
|
||||
that would be executed
|
||||
-p returns either the name of the disk file that would be executed,
|
||||
or nothing if `type -t NAME' would not return `file'.
|
||||
or nothing if `type -t NAME' would not return `file'
|
||||
-t output a single word which is one of `alias', `keyword',
|
||||
`function', `builtin', `file' or `', if NAME is an alias, shell
|
||||
reserved word, shell function, shell builtin, disk file, or not
|
||||
found, respectively
|
||||
`function', `builtin', `file' or `', if NAME is an alias,
|
||||
shell reserved word, shell function, shell builtin, disk file,
|
||||
or not found, respectively
|
||||
|
||||
Arguments:
|
||||
NAME Command name to be interpreted.
|
||||
|
|
@ -168,6 +168,7 @@ type_builtin (list)
|
|||
dflags |= (CDESC_PATH_ONLY|CDESC_FORCE_PATH);
|
||||
dflags &= ~(CDESC_TYPE|CDESC_SHORTDESC);
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -204,6 +205,7 @@ type_builtin (list)
|
|||
* CDESC_FORCE_PATH force a path search for type -P
|
||||
* CDESC_NOFUNCS skip function lookup for type -f
|
||||
* CDESC_ABSPATH convert to absolute path, no ./ prefix
|
||||
* CDESC_STDPATH command -p standard path list
|
||||
*
|
||||
* CDESC_ALL says whether or not to look for all occurrences of COMMAND, or
|
||||
* return after finding it once.
|
||||
|
|
@ -214,7 +216,7 @@ describe_command (command, dflags)
|
|||
int dflags;
|
||||
{
|
||||
int found, i, found_file, f, all;
|
||||
char *full_path, *x;
|
||||
char *full_path, *x, *pathlist;
|
||||
SHELL_VAR *func;
|
||||
#if defined (ALIAS)
|
||||
alias_t *alias;
|
||||
|
|
@ -293,7 +295,12 @@ describe_command (command, dflags)
|
|||
if (dflags & CDESC_TYPE)
|
||||
puts ("builtin");
|
||||
else if (dflags & CDESC_SHORTDESC)
|
||||
printf (_("%s is a shell builtin\n"), command);
|
||||
{
|
||||
if (posixly_correct && find_special_builtin (command) != 0)
|
||||
printf (_("%s is a special shell builtin\n"), command);
|
||||
else
|
||||
printf (_("%s is a shell builtin\n"), command);
|
||||
}
|
||||
else if (dflags & CDESC_REUSABLE)
|
||||
printf ("%s\n", command);
|
||||
|
||||
|
|
@ -346,12 +353,17 @@ describe_command (command, dflags)
|
|||
/* Now search through $PATH. */
|
||||
while (1)
|
||||
{
|
||||
if (all == 0)
|
||||
if (dflags & CDESC_STDPATH) /* command -p, all cannot be non-zero */
|
||||
{
|
||||
pathlist = conf_standard_path ();
|
||||
full_path = find_in_path (command, pathlist, FS_EXEC_PREFERRED|FS_NODIRS);
|
||||
free (pathlist);
|
||||
/* Will only go through this once, since all == 0 if STDPATH set */
|
||||
}
|
||||
else if (all == 0)
|
||||
full_path = find_user_command (command);
|
||||
else
|
||||
full_path =
|
||||
user_command_matches (command, FS_EXEC_ONLY, found_file);
|
||||
/* XXX - should that be FS_EXEC_PREFERRED? */
|
||||
full_path = user_command_matches (command, FS_EXEC_ONLY, found_file); /* XXX - should that be FS_EXEC_PREFERRED? */
|
||||
|
||||
if (full_path == 0)
|
||||
break;
|
||||
|
|
@ -382,7 +394,11 @@ describe_command (command, dflags)
|
|||
}
|
||||
/* If we require a full path and don't have one, make one */
|
||||
else if ((dflags & CDESC_ABSPATH) && ABSPATH (full_path) == 0)
|
||||
full_path = sh_makepath ((char *)NULL, full_path, MP_DOCWD|MP_RMDOT);
|
||||
{
|
||||
x = sh_makepath ((char *)NULL, full_path, MP_DOCWD|MP_RMDOT);
|
||||
free (full_path);
|
||||
full_path = x;
|
||||
}
|
||||
|
||||
found_file++;
|
||||
found = 1;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is ulimit.def, from which is created ulimit.c.
|
||||
It implements the builtin "ulimit" in Bash.
|
||||
|
||||
Copyright (C) 1987-2010 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ $PRODUCES ulimit.c
|
|||
$BUILTIN ulimit
|
||||
$FUNCTION ulimit_builtin
|
||||
$DEPENDS_ON !_MINIX
|
||||
$SHORT_DOC ulimit [-SHabcdefilmnpqrstuvxT] [limit]
|
||||
$SHORT_DOC ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
|
||||
Modify shell resource limits.
|
||||
|
||||
Provides control over the resources available to the shell and processes
|
||||
|
|
@ -39,6 +39,7 @@ Options:
|
|||
-e the maximum scheduling priority (`nice')
|
||||
-f the maximum size of files written by the shell and its children
|
||||
-i the maximum number of pending signals
|
||||
-k the maximum number of kqueues allocated for this process
|
||||
-l the maximum size a process may lock into memory
|
||||
-m the maximum resident set size
|
||||
-n the maximum number of open file descriptors
|
||||
|
|
@ -50,7 +51,8 @@ Options:
|
|||
-u the maximum number of user processes
|
||||
-v the size of virtual memory
|
||||
-x the maximum number of file locks
|
||||
-T the maximum number of threads
|
||||
-P the maximum number of pseudoterminals
|
||||
-T the maximum number of threads
|
||||
|
||||
Not all options are available on all platforms.
|
||||
|
||||
|
|
@ -131,11 +133,17 @@ extern int errno;
|
|||
# define print_rlimtype(num, nl) printf ("%ld%s", num, nl ? "\n" : "")
|
||||
#endif
|
||||
|
||||
/* Alternate names */
|
||||
|
||||
/* Some systems use RLIMIT_NOFILE, others use RLIMIT_OFILE */
|
||||
#if defined (HAVE_RESOURCE) && defined (RLIMIT_OFILE) && !defined (RLIMIT_NOFILE)
|
||||
# define RLIMIT_NOFILE RLIMIT_OFILE
|
||||
#endif /* HAVE_RESOURCE && RLIMIT_OFILE && !RLIMIT_NOFILE */
|
||||
|
||||
#if defined (HAVE_RESOURCE) && defined (RLIMIT_POSIXLOCKS) && !defined (RLIMIT_LOCKS)
|
||||
# define RLIMIT_LOCKS RLIMIT_POSIXLOCKS
|
||||
#endif /* HAVE_RESOURCE && RLIMIT_POSIXLOCKS && !RLIMIT_LOCKS */
|
||||
|
||||
/* Some systems have these, some do not. */
|
||||
#ifdef RLIMIT_FSIZE
|
||||
# define RLIMIT_FILESIZE RLIMIT_FSIZE
|
||||
|
|
@ -223,6 +231,9 @@ typedef struct {
|
|||
} RESOURCE_LIMITS;
|
||||
|
||||
static RESOURCE_LIMITS limits[] = {
|
||||
#ifdef RLIMIT_NPTS
|
||||
{ 'P', RLIMIT_NPTS, 1, "number of pseudoterminals", (char *)NULL },
|
||||
#endif
|
||||
#ifdef RLIMIT_PTHREAD
|
||||
{ 'T', RLIMIT_PTHREAD, 1, "number of threads", (char *)NULL },
|
||||
#endif
|
||||
|
|
@ -242,6 +253,9 @@ static RESOURCE_LIMITS limits[] = {
|
|||
#ifdef RLIMIT_SIGPENDING
|
||||
{ 'i', RLIMIT_SIGPENDING, 1, "pending signals", (char *)NULL },
|
||||
#endif
|
||||
#ifdef RLIMIT_KQUEUES
|
||||
{ 'k', RLIMIT_KQUEUES, 1, "max kqueues", (char *)NULL },
|
||||
#endif
|
||||
#ifdef RLIMIT_MEMLOCK
|
||||
{ 'l', RLIMIT_MEMLOCK, 1024, "max locked memory", "kbytes" },
|
||||
#endif
|
||||
|
|
@ -359,6 +373,7 @@ ulimit_builtin (list)
|
|||
mode |= LIMIT_HARD;
|
||||
break;
|
||||
|
||||
CASE_HELPOPT;
|
||||
case '?':
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is umask.def, from which is created umask.c.
|
||||
It implements the builtin "umask" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -91,6 +91,7 @@ umask_builtin (list)
|
|||
case 'p':
|
||||
pflag++;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -145,8 +146,12 @@ umask_builtin (list)
|
|||
/* Print the umask in a symbolic form. In the output, a letter is
|
||||
printed if the corresponding bit is clear in the umask. */
|
||||
static void
|
||||
#if defined (__STDC__)
|
||||
print_symbolic_umask (mode_t um)
|
||||
#else
|
||||
print_symbolic_umask (um)
|
||||
mode_t um;
|
||||
#endif
|
||||
{
|
||||
char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
This file is wait.def, from which is created wait.c.
|
||||
It implements the builtin "wait" in Bash.
|
||||
|
||||
Copyright (C) 1987-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -73,8 +73,10 @@ $END
|
|||
#include "bashgetopt.h"
|
||||
|
||||
extern int wait_signal_received;
|
||||
extern int last_command_exit_signal;
|
||||
|
||||
procenv_t wait_intr_buf;
|
||||
int wait_intr_flag;
|
||||
|
||||
/* Wait for the pid in LIST to stop or die. If no arguments are given, then
|
||||
wait for all of the active background processes of the shell and return
|
||||
|
|
@ -86,6 +88,7 @@ procenv_t wait_intr_buf;
|
|||
{ \
|
||||
interrupt_immediately = old_interrupt_immediately;\
|
||||
wait_signal_received = 0; \
|
||||
wait_intr_flag = 0; \
|
||||
return (s);\
|
||||
} \
|
||||
while (0)
|
||||
|
|
@ -110,6 +113,7 @@ wait_builtin (list)
|
|||
nflag = 1;
|
||||
break;
|
||||
#endif
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -130,10 +134,14 @@ wait_builtin (list)
|
|||
|
||||
We handle SIGINT here; it's the only one that needs to be treated
|
||||
specially (I think), since it's handled specially in {no,}jobs.c. */
|
||||
code = setjmp (wait_intr_buf);
|
||||
wait_intr_flag = 1;
|
||||
code = setjmp_sigs (wait_intr_buf);
|
||||
|
||||
if (code)
|
||||
{
|
||||
last_command_exit_signal = wait_signal_received;
|
||||
status = 128 + wait_signal_received;
|
||||
wait_sigint_cleanup ();
|
||||
WAIT_RETURN (status);
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +179,7 @@ wait_builtin (list)
|
|||
if (legal_number (w, &pid_value) && pid_value == (pid_t)pid_value)
|
||||
{
|
||||
pid = (pid_t)pid_value;
|
||||
status = wait_for_single_pid (pid);
|
||||
status = wait_for_single_pid (pid, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue