Imported from ../bash-2.04.tar.gz.

This commit is contained in:
Jari Aalto 2000-03-17 21:46:59 +00:00
commit bb70624e96
387 changed files with 28522 additions and 9334 deletions

View file

@ -1,4 +1,21 @@
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
#
# Copyright (C) 1996 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
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
#
SHELL = @MAKE_SHELL@
RANLIB = @RANLIB@
@ -9,6 +26,8 @@ ARFLAGS = @ARFLAGS@
RM = rm -f
CP = cp
EXEEXT = @EXEEXT@
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
@ -25,12 +44,14 @@ LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS)
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
LIBS = @LIBS@
INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(topdir)/lib -I$(srcdir)
BASHINCDIR = ${topdir}/include
INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir)
CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) $(CPPFLAGS) \
${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
MKBUILTINS = mkbuiltins
MKBUILTINS = mkbuiltins$(EXEEXT)
DIRECTDEFINE = -D $(srcdir)
# xxx this is bad style
@ -68,7 +89,7 @@ DEFSRC = $(srcdir)/alias.def $(srcdir)/bind.def $(srcdir)/break.def \
$(srcdir)/times.def $(srcdir)/trap.def $(srcdir)/type.def \
$(srcdir)/ulimit.def $(srcdir)/umask.def $(srcdir)/wait.def \
$(srcdir)/reserved.def $(srcdir)/pushd.def $(srcdir)/shopt.def \
$(srcdir)/printf.def
$(srcdir)/printf.def $(srcdir)/complete.def
STATIC_SOURCE = common.c evalstring.c evalfile.c getopt.c bashgetopt.c \
getopt.h
@ -80,7 +101,7 @@ OFILES = builtins.o \
exit.o fc.o fg_bg.o hash.o help.o history.o jobs.o kill.o let.o \
pushd.o read.o return.o set.o setattr.o shift.o source.o \
suspend.o test.o times.o trap.o type.o ulimit.o umask.o \
wait.o getopts.o shopt.o printf.o getopt.o bashgetopt.o
wait.o getopts.o shopt.o printf.o getopt.o bashgetopt.o complete.o
CREATED_FILES = builtext.h builtins.c psize.aux pipesize.h
@ -112,7 +133,7 @@ mkbuiltins.o: mkbuiltins.c
$(RM) $@
$(CC_FOR_BUILD) -c $(CCFLAGS) $<
mkbuiltins: mkbuiltins.o
mkbuiltins$(EXEEXT): mkbuiltins.o
$(CC_FOR_BUILD) $(PROFILE_FLAGS) $(LDFLAGS) -o $(MKBUILTINS) mkbuiltins.o $(LIBS)
# rules for deficient makes, like SunOS
@ -188,274 +209,286 @@ umask.o: umask.def
wait.o: wait.def
getopts.o: getopts.def
reserved.o: reserved.def
complete.o: complete.def
# C files
bashgetopt.o: ../config.h $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
bashgetopt.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
bashgetopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h
bashgetopt.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
bashgetopt.o: $(topdir)/variables.h $(topdir)/quit.h $(topdir)/maxpath.h
bashgetopt.o: $(topdir)/variables.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
bashgetopt.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
bashgetopt.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
bashgetopt.o: $(topdir)/pathnames.h $(topdir)/externs.h $(srcdir)/common.h
common.o: $(topdir)/bashtypes.h $(topdir)/posixstat.h $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
common.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h $(topdir)/posixjmp.h
common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
common.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
common.o: $(topdir)/sig.h $(topdir)/command.h
common.o: $(topdir)/general.h $(topdir)/stdc.h $(topdir)/memalloc.h
common.o: $(topdir)/general.h $(BASHINCDIR)/stdc.h $(BASHINCDIR)/memalloc.h
common.o: $(topdir)/variables.h $(topdir)/input.h
common.o: $(topdir)/siglist.h $(topdir)/bashhist.h $(topdir)/quit.h
common.o: $(topdir)/unwind_prot.h $(topdir)/maxpath.h $(topdir)/jobs.h
common.o: $(topdir)/unwind_prot.h $(BASHINCDIR)/maxpath.h $(topdir)/jobs.h
common.o: $(topdir)/builtins.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
common.o: $(topdir)/subst.h $(topdir)/execute_cmd.h $(topdir)/error.h
common.o: $(topdir)/externs.h $(topdir)/pathnames.h ./builtext.h
evalfile.o: $(topdir)/bashtypes.h $(topdir)/posixstat.h $(topdir)/filecntl.h
evalfile.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
evalfile.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h ${BASHINCDIR}/filecntl.h
evalfile.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
evalfile.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h
evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
evalfile.o: $(topdir)/variables.h $(topdir)/quit.h $(topdir)/maxpath.h
evalfile.o: $(topdir)/variables.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
evalfile.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
evalfile.o: $(topdir)/pathnames.h $(topdir)/externs.h
evalfile.o: $(topdir)/jobs.h $(topdir)/builtins.h $(topdir)/flags.h
evalfile.o: $(topdir)/input.h $(topdir)/execute_cmd.h
evalfile.o: $(topdir)/bashhist.h $(srcdir)/common.h
evalstring.o: ../config.h $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
evalstring.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(topdir)/posixjmp.h
evalstring.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
evalstring.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
evalstring.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/siglist.h
evalstring.o: $(topdir)/memalloc.h $(topdir)/variables.h $(topdir)/input.h
evalstring.o: $(BASHINCDIR)/memalloc.h $(topdir)/variables.h $(topdir)/input.h
evalstring.o: $(topdir)/quit.h $(topdir)/unwind_prot.h
evalstring.o: $(topdir)/maxpath.h $(topdir)/jobs.h $(topdir)/builtins.h
evalstring.o: $(BASHINCDIR)/maxpath.h $(topdir)/jobs.h $(topdir)/builtins.h
evalstring.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
evalstring.o: $(topdir)/externs.h $(topdir)/jobs.h $(topdir)/builtins.h
evalstring.o: $(topdir)/flags.h $(topdir)/input.h $(topdir)/execute_cmd.h
evalstring.o: $(topdir)/bashhist.h $(srcdir)/common.h
getopt.o: ../config.h $(topdir)/memalloc.h
getopt.o: ../config.h $(BASHINCDIR)/memalloc.h
getopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(topdir)/command.h
getopt.o: $(topdir)/general.h $(topdir)/error.h $(topdir)/variables.h
getopt.o: $(topdir)/quit.h $(topdir)/maxpath.h $(topdir)/unwind_prot.h
getopt.o: $(topdir)/quit.h $(BASHINCDIR)/maxpath.h $(topdir)/unwind_prot.h
getopt.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
getopt.o: $(topdir)/sig.h $(topdir)/pathnames.h $(topdir)/externs.h
getopt.o: $(srcdir)/getopt.h
mkbuiltins.o: ../config.h $(topdir)/bashtypes.h $(topdir)/posixstat.h
mkbuiltins.o: $(topdir)/filecntl.h
mkbuiltins.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
mkbuiltins.o: ../config.h $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
mkbuiltins.o: ${BASHINCDIR}/filecntl.h
mkbuiltins.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
# def files
alias.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
alias.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/maxpath.h
alias.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
alias.o: $(topdir)/error.h $(topdir)/general.h $(BASHINCDIR)/maxpath.h
alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
alias.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/common.h
alias.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
bind.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
bind.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
bind.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/bashgetopt.h
bind.o: $(topdir)/general.h $(topdir)/maxpath.h $(topdir)/bashline.h
bind.o: $(topdir)/general.h $(BASHINCDIR)/maxpath.h $(topdir)/bashline.h
bind.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
break.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
break.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
break.o: $(topdir)/error.h $(topdir)/general.h
break.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
break.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
break.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
break.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
builtin.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
builtin.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
builtin.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/externs.h
builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(topdir)/maxpath.h
builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
builtin.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
cd.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
cd.o: $(topdir)/general.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
cd.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
cd.o: $(srcdir)/common.h $(topdir)/maxpath.h
command.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
command.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
command.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/externs.h
command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(topdir)/maxpath.h
command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(BASHINCDIR)/maxpath.h
command.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
command.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
declare.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
declare.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
declare.o: $(topdir)/error.h $(topdir)/general.h
declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
declare.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
declare.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
declare.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
echo.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
echo.o: $(topdir)/general.h $(topdir)/subst.h $(topdir)/externs.h
echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
echo.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
echo.o: $(topdir)/maxpath.h
enable.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
echo.o: $(BASHINCDIR)/maxpath.h
enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
enable.o: $(topdir)/error.h $(topdir)/general.h
enable.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
enable.o: $(topdir)/subst.h $(topdir)/externs.h
enable.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
enable.o: $(topdir)/maxpath.h
eval.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
enable.o: $(BASHINCDIR)/maxpath.h
enable.o: $(topdir)/pcomplete.h
eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
eval.o: $(topdir)/error.h $(topdir)/general.h
eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
eval.o: $(topdir)/subst.h $(topdir)/externs.h
eval.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
eval.o: $(topdir)/maxpath.h
eval.o: $(BASHINCDIR)/maxpath.h
exec.o: $(topdir)/bashtypes.h
exec.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
exec.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exec.o: $(topdir)/error.h $(topdir)/general.h
exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exec.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/flags.h
exec.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(topdir)/maxpath.h
exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(BASHINCDIR)/maxpath.h
exec.o: $(topdir)/findcmd.h
exit.o: $(topdir)/bashtypes.h
exit.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exit.o: $(topdir)/error.h $(topdir)/general.h
exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exit.o: $(topdir)/subst.h $(topdir)/externs.h
exit.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
exit.o: $(topdir)/maxpath.h ./builtext.h
fc.o: $(topdir)/bashtypes.h $(topdir)/posixstat.h
exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h
fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h
fc.o: $(topdir)/bashhist.h
fc.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
fc.o: $(topdir)/general.h $(topdir)/maxpath.h
fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
fc.o: $(topdir)/general.h $(BASHINCDIR)/maxpath.h
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.h
fc.o: $(topdir)/flags.h $(topdir)/unwind_prot.h $(topdir)/variables.h
fc.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
fg_bg.o: $(topdir)/bashtypes.h
fg_bg.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
fg_bg.o: $(topdir)/error.h $(topdir)/general.h
fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
fg_bg.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
getopts.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
getopts.o: $(topdir)/error.h $(topdir)/general.h
getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
getopts.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h
hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h
hash.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
hash.o: $(topdir)/error.h $(topdir)/general.h
hash.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
hash.o: $(srcdir)/common.h $(topdir)/maxpath.h
help.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
hash.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
help.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
help.o: $(topdir)/error.h $(topdir)/general.h
help.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
help.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
help.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
help.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
history.o: $(topdir)/bashtypes.h
history.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
history.o: $(topdir)/error.h $(topdir)/general.h
history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
history.o: $(topdir)/subst.h $(topdir)/externs.h
history.o: $(topdir)/filecntl.h $(topdir)/shell.h $(topdir)/unwind_prot.h
history.o: $(topdir)/variables.h $(topdir)/bashhist.h $(topdir)/maxpath.h
inlib.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/unwind_prot.h
history.o: $(topdir)/variables.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h
inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
inlib.o: $(topdir)/error.h $(topdir)/general.h
inlib.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
inlib.o: $(topdir)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h
inlib.o: $(BASHINCDIR)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h
inlib.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
jobs.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
jobs.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
jobs.o: $(topdir)/general.h $(topdir)/quit.h $(srcdir)/bashgetopt.h
jobs.o: $(topdir)/maxpath.h $(topdir)/externs.h
jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h
jobs.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
jobs.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
kill.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
kill.o: $(topdir)/general.h $(topdir)/subst.h $(topdir)/externs.h
kill.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
kill.o: $(topdir)/shell.h $(topdir)/trap.h $(topdir)/unwind_prot.h
kill.o: $(topdir)/variables.h $(topdir)/maxpath.h
let.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
kill.o: $(topdir)/variables.h $(BASHINCDIR)/maxpath.h
let.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
let.o: $(topdir)/error.h $(topdir)/general.h
let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
let.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
let.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
let.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
printf.o: ../config.h $(topdir)/memalloc.h $(topdir)/bashjmp.h
printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h
printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h
printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
printf.o: $(topdir)/pathnames.h $(topdir)/shell.h $(topdir)/unwind_prot.h
printf.o: $(topdir)/variables.h $(topdir)/stdc.h $(srcdir)/bashgetopt.h
pushd.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
printf.o: $(topdir)/variables.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h
pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
pushd.o: $(topdir)/error.h $(topdir)/general.h
pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
pushd.o: $(topdir)/subst.h $(topdir)/externs.h
pushd.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
pushd.o: $(topdir)/maxpath.h $(srcdir)/common.h ./builtext.h
read.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h
read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
read.o: $(topdir)/error.h $(topdir)/general.h
read.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
read.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
read.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
read.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
return.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
read.o: $(BASHINCDIR)/shtty.h
return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
return.o: $(topdir)/error.h $(topdir)/general.h
return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
return.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
return.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
return.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
set.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
set.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
set.o: $(topdir)/general.h $(topdir)/subst.h $(topdir)/externs.h
set.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
set.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
set.o: $(topdir)/maxpath.h $(topdir)/error.h
setattr.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
setattr.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/maxpath.h
set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h
setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
setattr.o: $(topdir)/error.h $(topdir)/general.h $(BASHINCDIR)/maxpath.h
setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h
setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
setattr.o: $(topdir)/externs.h
setattr.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shift.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shift.o: $(topdir)/error.h $(topdir)/general.h
shift.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
shift.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
shift.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
shift.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
source.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
source.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/findcmd.h
source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
source.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
source.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
suspend.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
suspend.o: $(topdir)/error.h $(topdir)/general.h
suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
suspend.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
test.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
test.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
test.o: $(topdir)/error.h $(topdir)/general.h
test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
test.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
test.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
test.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
test.o: $(topdir)/test.h
times.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
times.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
times.o: $(topdir)/error.h $(topdir)/general.h
times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
times.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
times.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
times.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
trap.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
times.o: $(BASHINCDIR)/posixtime.h
trap.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
trap.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/externs.h
trap.o: $(topdir)/quit.h $(srcdir)/common.h $(topdir)/maxpath.h
trap.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
trap.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
trap.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
trap.o: $(topdir)/findcmd.h
type.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
type.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
type.o: $(topdir)/error.h $(topdir)/general.h
type.o: $(topdir)/quit.h $(srcdir)/common.h $(topdir)/maxpath.h
type.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
type.o: $(topdir)/externs.h $(topdir)/hashcmd.h
type.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
ulimit.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
ulimit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
ulimit.o: $(topdir)/error.h $(topdir)/general.h
ulimit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
ulimit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
ulimit.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
ulimit.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
umask.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
umask.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
umask.o: $(topdir)/error.h $(topdir)/general.h
umask.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
umask.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
umask.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
umask.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
wait.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
wait.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
wait.o: $(topdir)/error.h $(topdir)/general.h
wait.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
wait.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
wait.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
wait.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shopt.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
shopt.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shopt.o: $(topdir)/error.h $(topdir)/general.h
shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
shopt.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h
complete.o: ../config.h
complete.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h
complete.o: ${topdir}/unwind_prot.h ${topdir}/variables.h
complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
complete.o: ${topdir}/builtins.h
complete.o: ${topdir}/pcomplete.h
complete.o: ${srcdir}/common.h ${srcdir}/bashgetopt.h
#bind.o: $(RL_LIBSRC)chardefs.h $(RL_LIBSRC)readline.h $(RL_LIBSRC)keymaps.h

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$BUILTIN alias
$FUNCTION alias_builtin

View file

@ -6,7 +6,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>

View file

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* See getopt.h for the explanation of these variables. */

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES bind.c
@ -26,7 +26,7 @@ $PRODUCES bind.c
$BUILTIN bind
$DEPENDS_ON READLINE
$FUNCTION bind_builtin
$SHORT_DOC bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [keyseq:readline-function]
$SHORT_DOC bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function]
Bind a key sequence to a Readline function, or to a macro. The
syntax is equivalent to that found in ~/.inputrc, but must be
passed as a single argument: bind '"\C-x\C-r": re-read-init-file'.
@ -40,6 +40,8 @@ Arguments we accept:
-p List functions and bindings in a form that can be
reused as input.
-r keyseq Remove the binding for KEYSEQ.
-x keyseq:shell-command Cause SHELL-COMMAND to be executed when KEYSEQ
is entered.
-f filename Read key bindings from FILENAME.
-q function-name Query about which keys invoke the named function.
-u function-name Unbind all keys which are bound to the named function.
@ -93,6 +95,7 @@ extern int no_line_editing;
#define SFLAG 0x0200
#define SSFLAG 0x0400
#define UFLAG 0x0800
#define XFLAG 0x1000
int
bind_builtin (list)
@ -102,7 +105,7 @@ bind_builtin (list)
FILE *old_rl_outstream;
Keymap kmap, saved_keymap;
int flags, opt;
char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq;
char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq;
if (no_line_editing)
return (EXECUTION_FAILURE);
@ -122,7 +125,7 @@ bind_builtin (list)
rl_outstream = stdout;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "lvpVPsSf:q:u:m:r:")) != EOF)
while ((opt = internal_getopt (list, "lvpVPsSf:q:u:m:r:x:")) != EOF)
{
switch (opt)
{
@ -167,6 +170,10 @@ bind_builtin (list)
case 'S':
flags |= SSFLAG;
break;
case 'x':
flags |= XFLAG;
cmd_seq = list_optarg;
break;
default:
builtin_usage ();
BIND_RETURN (EX_USAGE);
@ -242,6 +249,9 @@ bind_builtin (list)
}
}
if (flags & XFLAG)
return_code = bind_keyseq_to_unix_command (cmd_seq);
/* Process the rest of the arguments as binding specifications. */
while (list)
{

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES break.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES builtin.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES cd.c
#include <config.h>
@ -30,8 +30,8 @@ $PRODUCES cd.c
#endif
#include "../bashtypes.h"
#include "../posixdir.h"
#include "../posixstat.h"
#include "posixdir.h"
#include "posixstat.h"
#ifndef _MINIX
#include <sys/param.h>
#endif
@ -45,7 +45,7 @@ $PRODUCES cd.c
#include "../shell.h"
#include "../flags.h"
#include "../maxpath.h"
#include "maxpath.h"
#include "common.h"
#include "bashgetopt.h"
@ -83,45 +83,6 @@ instead of following symbolic links; the -L option forces symbolic links
to be followed.
$END
/* Take PATH, an element from $CDPATH, and DIR, a directory name, and paste
them together into PATH/DIR. Tilde expansion is performed on PATH if
DOTILDE is non-zero. If PATH is the empty string, it is converted to
`./', since a null element in $CDPATH means the current directory. */
static char *
mkpath (path, dir, dotilde)
char *path, *dir;
int dotilde;
{
int dirlen, pathlen;
char *ret, *xpath;
if (*path == '\0')
{
xpath = xmalloc (2);
xpath[0] = '.';
xpath[1] = '\0';
pathlen = 1;
}
else
{
xpath = (dotilde && *path == '~') ? bash_tilde_expand (path) : path;
pathlen = strlen (xpath);
}
dirlen = strlen (dir);
ret = xmalloc (2 + dirlen + pathlen);
strcpy (ret, xpath);
if (xpath[pathlen - 1] != '/')
{
ret[pathlen++] = '/';
ret[pathlen] = '\0';
}
strcpy (ret + pathlen, dir);
if (xpath != path)
free (xpath);
return (ret);
}
static int
bindpwd (no_symlinks)
int no_symlinks;
@ -245,7 +206,7 @@ cd_builtin (list)
{
/* OPT is 1 if the path element is non-empty */
opt = path[0] != '\0';
temp = mkpath (path, dirname, 1);
temp = sh_makepath (path, dirname, MP_DOTILDE);
free (path);
if (stat (temp, &sb) < 0 || S_ISDIR (sb.st_mode) == 0)

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES colon.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES command.c

View file

@ -4,7 +4,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@ -27,7 +27,7 @@
#include <stdio.h>
#include "../bashtypes.h"
#include "../posixstat.h"
#include "posixstat.h"
#include <signal.h>
#include <errno.h>
@ -43,7 +43,7 @@
#include "../bashansi.h"
#include "../shell.h"
#include "../maxpath.h"
#include "maxpath.h"
#include "../flags.h"
#include "../jobs.h"
#include "../builtins.h"
@ -63,6 +63,12 @@
extern int errno;
#endif /* !errno */
#ifdef __STDC__
typedef int QSFUNC (const void *, const void *);
#else
typedef int QSFUNC ();
#endif
extern int no_symbolic_links, interactive, interactive_shell;
extern int indirection_level, startup_state, subshell_environment;
extern int line_number;
@ -462,7 +468,7 @@ get_job_spec (list)
if (digit (*word) && all_digits (word))
{
job = atoi (word);
return (job - 1);
return (job >= job_slots ? NO_JOB : job - 1);
}
substring = 0;
@ -701,13 +707,8 @@ shell_builtin_compare (sbp1, sbp2)
void
initialize_shell_builtins ()
{
#ifdef _MINIX
qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
(int (*)(const void *, const void *))shell_builtin_compare);
#else
qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
shell_builtin_compare);
#endif
(QSFUNC *)shell_builtin_compare);
}
/* **************************************************************** */
@ -767,6 +768,7 @@ double_quote (string)
case '$':
case '`':
case '\\':
case '\n': /* XXX */
*r++ = '\\';
default:
*r++ = c;
@ -780,6 +782,37 @@ double_quote (string)
return (result);
}
/* Remove backslashes that are quoting characters that are special between
double quotes. Return a new string. */
char *
un_double_quote (string)
char *string;
{
register int c, pass_next;
char *result, *r, *s;
r = result = xmalloc (strlen (string) + 1);
for (pass_next = 0, s = string; s && (c = *s); s++)
{
if (pass_next)
{
*r++ = c;
pass_next = 0;
continue;
}
if (c == '\\' && strchr (slashify_in_quotes, s[1]))
{
pass_next = 1;
continue;
}
*r++ = c;
}
*r = '\0';
return result;
}
/* Quote special characters in STRING using backslashes. Return a new
string. */
char *
@ -827,6 +860,41 @@ backslash_quote (string)
return (result);
}
#if defined (PROMPT_STRING_DECODE)
/* Quote characters that get special treatment when in double quotes in STRING
using backslashes. Return a new string. */
char *
backslash_quote_for_double_quotes (string)
char *string;
{
int c;
char *result, *r, *s;
result = xmalloc (2 * strlen (string) + 1);
for (r = result, s = string; s && (c = *s); s++)
{
switch (c)
{
case '"':
case '$':
case '`':
case '\\':
case '\n':
*r++ = '\\';
*r++ = c;
break;
default:
*r++ = c;
break;
}
}
*r = '\0';
return (result);
}
#endif /* PROMPT_STRING_DECODE */
int
contains_shell_metas (string)
char *string;

View file

@ -16,12 +16,12 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (__COMMON_H)
# define __COMMON_H
#include "../stdc.h"
#include "stdc.h"
#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c)
@ -72,7 +72,9 @@ extern void initialize_shell_builtins __P((void));
extern char *single_quote __P((char *));
extern char *double_quote __P((char *));
extern char *un_double_quote __P((char *));
extern char *backslash_quote __P((char *));
extern char *backslash_quote_for_double_quotes __P((char *));
extern int contains_shell_metas __P((char *));
/* Functions from set.def */
@ -81,9 +83,11 @@ extern void list_minus_o_opts __P((int, int));
extern int set_minus_o_option __P((int, char *));
extern int minus_o_option_value __P((char *));
extern void reset_shell_options __P((void));
extern char **get_minus_o_opts __P((void));
/* Functions from shopt.def */
extern void reset_shopt_options __P((void));
extern char **get_shopt_options __P((void));
/* Functions from type.def */
extern int describe_command __P((char *, int, int));

512
builtins/complete.def Normal file
View file

@ -0,0 +1,512 @@
This file is complete.def, from which is created complete.c.
It implements the builtins "complete" and "compgen" in Bash.
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES complete.c
$BUILTIN complete
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION complete_builtin
$SHORT_DOC complete [-abcdefjkvu] [-pr] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
For each NAME, specify how arguments are to be completed.
If the -p option is supplied, or if no options are supplied, existing
completion specifications are printed in a way that allows them to be
reused as input. The -r option removes a completion specification for
each NAME, or, if no NAMEs are supplied, all completion specifications.
$END
#include <config.h>
#include <stdio.h>
#include "../bashtypes.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "../bashansi.h"
#include "../shell.h"
#include "../builtins.h"
#include "../pcomplete.h"
#include "common.h"
#include "bashgetopt.h"
#define STRDUP(x) ((x) ? savestring (x) : (char *)NULL)
static int remove_cmd_completions ();
static void print_all_completions ();
static int print_cmd_completions ();
static char *Aarg, *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
static struct _compacts {
char *actname;
int actflag;
int actopt;
} compacts[] = {
{ "alias", CA_ALIAS, 'a' },
{ "arrayvar", CA_ARRAYVAR, 0 },
{ "binding", CA_BINDING, 0 },
{ "builtin", CA_BUILTIN, 'b' },
{ "command", CA_COMMAND, 'c' },
{ "directory", CA_DIRECTORY, 'd' },
{ "disabled", CA_DISABLED, 0 },
{ "enabled", CA_ENABLED, 0 },
{ "export", CA_EXPORT, 'e' },
{ "file", CA_FILE, 'f' },
{ "function", CA_FUNCTION, 0 },
{ "helptopic", CA_BUILTIN, 0 }, /* for now */
{ "hostname", CA_HOSTNAME, 0 },
{ "job", CA_JOB, 'j' },
{ "keyword", CA_KEYWORD, 'k' },
{ "running", CA_RUNNING, 0 },
{ "setopt", CA_SETOPT, 0 },
{ "shopt", CA_SHOPT, 0 },
{ "signal", CA_SIGNAL, 0 },
{ "stopped", CA_STOPPED, 0 },
{ "user", CA_USER, 'u' },
{ "variable", CA_VARIABLE, 'v' },
{ (char *)NULL, 0, 0 },
};
static int
find_compact (name)
char *name;
{
register int i;
for (i = 0; compacts[i].actname; i++)
if (STREQ (name, compacts[i].actname))
return i;
return -1;
}
/* Build the actions from the options specified in LIST. ACTP is a pointer
to an unsigned long in which to place the bitmap of actions. PP, if
non-null, gets 1 if -p is supplied; RP, if non-null, gets 1 if -r is
supplied. If either is null, the corresponding option generates an
error. This also sets variables corresponding to options that take
arguments as a side effect; the caller should ensure that those variables
are set to NULL before calling build_actions. Return value:
EX_USAGE = bad option
EXECUTION_SUCCESS = some options supplied
EXECUTION_FAILURE = no options supplied
*/
static int
build_actions (list, pp, rp, actp)
WORD_LIST *list;
int *pp, *rp;
unsigned long *actp;
{
int opt, ind, pflag, rflag, opt_given;
unsigned long acts;
acts = (unsigned long)0L;
opt_given = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "abcdefjkpruvA:G:W:P:S:X:F:C:")) != -1)
{
opt_given = 1;
switch (opt)
{
case 'r':
if (rp)
{
*rp = 1;
break;
}
else
{
builtin_error ("illegal option: -r");
builtin_usage ();
return (EX_USAGE);
}
case 'p':
if (pp)
{
*pp = 1;
break;
}
else
{
builtin_error ("illegal option: -p");
builtin_usage ();
return (EX_USAGE);
}
case 'a':
acts |= CA_ALIAS;
break;
case 'b':
acts |= CA_BUILTIN;
break;
case 'c':
acts |= CA_COMMAND;
break;
case 'd':
acts |= CA_DIRECTORY;
break;
case 'e':
acts |= CA_EXPORT;
break;
case 'f':
acts |= CA_FILE;
break;
case 'j':
acts |= CA_JOB;
break;
case 'k':
acts |= CA_KEYWORD;
break;
case 'u':
acts |= CA_USER;
break;
case 'v':
acts |= CA_VARIABLE;
break;
case 'A':
ind = find_compact (list_optarg);
if (ind < 0)
{
builtin_error ("%s: invalid action name", list_optarg);
return (EX_USAGE);
}
acts |= compacts[ind].actflag;
break;
case 'C':
Carg = list_optarg;
break;
case 'F':
Farg = list_optarg;
break;
case 'G':
Garg = list_optarg;
break;
case 'P':
Parg = list_optarg;
break;
case 'S':
Sarg = list_optarg;
break;
case 'W':
Warg = list_optarg;
break;
case 'X':
Xarg = list_optarg;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
*actp = acts;
return (opt_given ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
/* Add, remove, and display completion specifiers. */
int
complete_builtin (list)
WORD_LIST *list;
{
int opt_given, pflag, rflag, rval;
unsigned long acts;
char *cmd;
COMPSPEC *cs;
if (list == 0)
{
print_all_completions ();
return (EXECUTION_SUCCESS);
}
opt_given = pflag = rflag = 0;
acts = (unsigned long)0L;
Aarg = Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
cs = (COMPSPEC *)NULL;
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
as a side effect if they are supplied as options. */
rval = build_actions (list, &pflag, &rflag, &acts);
if (rval == EX_USAGE)
return (rval);
opt_given = rval != EXECUTION_FAILURE;
list = loptend;
/* -p overrides everything else */
if (pflag || (list == 0 && opt_given == 0))
{
if (list == 0)
{
print_all_completions ();
return (EXECUTION_SUCCESS);
}
return (print_cmd_completions (list));
}
/* next, -r overrides everything else. */
if (rflag)
{
if (list == 0)
{
clear_progcomps ();
return (EXECUTION_SUCCESS);
}
return (remove_cmd_completions (list));
}
if (list == 0 && opt_given)
{
builtin_usage ();
return (EX_USAGE);
}
/* If we get here, we need to build a compspec and add it for each
remaining argument. */
cs = alloc_compspec ();
cs->actions = acts;
cs->globpat = STRDUP (Garg);
cs->words = STRDUP (Warg);
cs->prefix = STRDUP (Parg);
cs->suffix = STRDUP (Sarg);
cs->funcname = STRDUP (Farg);
cs->command = STRDUP (Carg);
cs->filterpat = STRDUP (Xarg);
for (rval = EXECUTION_SUCCESS ; list; list = list->next)
{
/* Add CS as the compspec for the specified commands. */
cmd = list->word->word;
if (add_progcomp (cmd, cs) == 0)
rval = EXECUTION_FAILURE;
}
return (rval);
}
static int
remove_cmd_completions (list)
WORD_LIST *list;
{
WORD_LIST *l;
int ret;
for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next)
{
if (remove_progcomp (l->word->word) == 0)
{
builtin_error ("%s: no completion specification", l->word->word);
ret = EXECUTION_FAILURE;
}
}
return ret;
}
#define SQPRINTARG(a, f) \
do { \
if (a) \
{ \
x = single_quote (a); \
printf ("%s %s ", f, x); \
free (x); \
} \
} while (0)
#define PRINTARG(a, f) \
do { \
if (a) \
printf ("%s %s ", f, a); \
} while (0)
#define PRINTOPT(a, f) \
do { \
if (acts & a) \
printf ("%s ", f); \
} while (0)
#define PRINTACT(a, f) \
do { \
if (acts & a) \
printf ("-A %s ", f); \
} while (0)
static void
print_one_completion (cmd, cs)
char *cmd;
COMPSPEC *cs;
{
unsigned long acts;
char *x;
printf ("complete ");
acts = cs->actions;
/* simple flags first */
PRINTOPT (CA_ALIAS, "-a");
PRINTOPT (CA_BUILTIN, "-b");
PRINTOPT (CA_COMMAND, "-c");
PRINTOPT (CA_DIRECTORY, "-d");
PRINTOPT (CA_EXPORT, "-e");
PRINTOPT (CA_FILE, "-f");
PRINTOPT (CA_KEYWORD, "-k");
PRINTOPT (CA_JOB, "-j");
PRINTOPT (CA_USER, "-u");
PRINTOPT (CA_VARIABLE, "-v");
/* now the rest of the actions */
PRINTACT (CA_ARRAYVAR, "arrayvar");
PRINTACT (CA_BINDING, "binding");
PRINTACT (CA_DISABLED, "disabled");
PRINTACT (CA_ENABLED, "enabled");
PRINTACT (CA_FUNCTION, "function");
PRINTACT (CA_HELPTOPIC, "helptopic");
PRINTACT (CA_HOSTNAME, "hostname");
PRINTACT (CA_RUNNING, "running");
PRINTACT (CA_SETOPT, "setopt");
PRINTACT (CA_SHOPT, "shopt");
PRINTACT (CA_SIGNAL, "signal");
PRINTACT (CA_STOPPED, "stopped");
/* now the rest of the arguments */
/* arguments that require quoting */
SQPRINTARG (cs->globpat, "-G");
SQPRINTARG (cs->words, "-W");
SQPRINTARG (cs->prefix, "-P");
SQPRINTARG (cs->suffix, "-S");
SQPRINTARG (cs->filterpat, "-X");
/* simple arguments that don't require quoting */
PRINTARG (cs->funcname, "-F");
PRINTARG (cs->command, "-C");
printf ("%s\n", cmd);
}
static void
print_all_completions ()
{
print_all_compspecs (print_one_completion);
}
static int
print_cmd_completions (list)
WORD_LIST *list;
{
WORD_LIST *l;
COMPSPEC *cs;
int ret;
for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next)
{
cs = find_compspec (l->word->word);
if (cs)
print_one_completion (l->word->word, cs);
else
{
builtin_error ("%s: no completion specification", l->word->word);
ret = EXECUTION_FAILURE;
}
}
return (ret);
}
$BUILTIN compgen
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION compgen_builtin
$SHORT_DOC compgen [-abcdefjkvu] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
Display the possible completions depending on the options. Intended
to be used from within a shell function generating possible completions.
If the optional WORD argument is supplied, matches against WORD are
generated.
$END
int
compgen_builtin (list)
WORD_LIST *list;
{
int rval;
unsigned long acts;
COMPSPEC *cs;
STRINGLIST *sl;
char *word;
if (list == 0)
return (EXECUTION_SUCCESS);
acts = (unsigned long)0L;
Aarg = Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
cs = (COMPSPEC *)NULL;
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
as a side effect if they are supplied as options. */
rval = build_actions (list, (int *)NULL, (int *)NULL, &acts);
if (rval == EX_USAGE)
return (rval);
if (rval == EXECUTION_FAILURE)
return (EXECUTION_SUCCESS);
list = loptend;
word = (list && list->word) ? list->word->word : "";
if (Farg)
internal_warning ("compgen: -F option may not work as you expect");
if (Carg)
internal_warning ("compgen: -C option may not work as you expect");
/* If we get here, we need to build a compspec and evaluate it. */
cs = alloc_compspec ();
cs->actions = acts;
cs->refcount = 1;
cs->globpat = STRDUP (Garg);
cs->words = STRDUP (Warg);
cs->prefix = STRDUP (Parg);
cs->suffix = STRDUP (Sarg);
cs->funcname = STRDUP (Farg);
cs->command = STRDUP (Carg);
cs->filterpat = STRDUP (Xarg);
rval = EXECUTION_FAILURE;
sl = gen_compspec_completions (cs, "compgen", word, 0, 0);
if (sl)
{
if (sl->list)
{
rval = EXECUTION_SUCCESS;
print_stringlist (sl, (char *)NULL);
}
free_stringlist (sl);
}
free_compspec (cs);
return (rval);
}

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES declare.c
@ -255,10 +255,15 @@ declare_internal (list, local_var)
{
#if defined (ARRAY_VARS)
if ((flags_on & att_array) || making_array_special)
make_local_array_variable (name);
var = make_local_array_variable (name);
else
#endif
make_local_variable (name);
var = make_local_variable (name);
if (var == 0)
{
any_failed++;
NEXT_VARIABLE ();
}
}
/* If we are declaring a function, then complain about it in some way.
@ -297,8 +302,8 @@ declare_internal (list, local_var)
}
else /* declare -[fF] -[rx] name [name...] */
{
var->attributes |= flags_on;
var->attributes &= ~flags_off;
VSETATTR (var, flags_on);
VUNSETATTR (var, flags_off);
}
}
else
@ -364,22 +369,18 @@ declare_internal (list, local_var)
var = convert_var_to_array (var);
#endif /* ARRAY_VARS */
var->attributes |= flags_on;
var->attributes &= ~flags_off;
VSETATTR (var, flags_on);
VUNSETATTR (var, flags_off);
#if defined (ARRAY_VARS)
if (offset && assigning_array_special)
assign_array_var_from_string (var, value);
else
#endif
/* This essentially duplicates the internals of bind_variable() */
/* bind_variable_value duplicates the essential internals of
bind_variable() */
if (offset)
{
var->attributes &= ~att_invisible;
t = make_variable_value (var, value);
FREE (var->value);
var->value = t;
}
bind_variable_value (var, value);
/* If we found this variable in the temporary environment, as with
`var=value declare -x var', make sure it is treated identically

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES echo.c
#include <config.h>
@ -67,6 +67,17 @@ $END
# define VALID_ECHO_OPTIONS "n"
#endif /* !V9_ECHO */
/* System V machines already have a /bin/sh with a v9 behaviour. We
give Bash the identical behaviour for these machines so that the
existing system shells won't barf. Regrettably, the SUS v2 has
standardized the Sys V echo behavior. This variable is external
so that we can have a `shopt' variable to control it at runtime. */
#if defined (DEFAULT_ECHO_TO_XPG)
int xpg_echo = 1;
#else
int xpg_echo = 0;
#endif /* DEFAULT_ECHO_TO_XPG */
/* Print the words in LIST to standard output. If the first word is
`-n', then don't print a trailing newline. We also support the
echo syntax from Version 9 Unix systems. */
@ -77,15 +88,7 @@ echo_builtin (list)
int display_return, do_v9, i, len;
char *temp, *s;
#if defined (DEFAULT_ECHO_TO_USG)
/* System V machines already have a /bin/sh with a v9 behaviour. We
give Bash the identical behaviour for these machines so that the
existing system shells won't barf. */
do_v9 = 1;
#else
do_v9 = 0;
#endif /* DEFAULT_ECHO_TO_USG */
do_v9 = xpg_echo;
display_return = 1;
for (; list && (temp = list->word->word) && *temp == '-'; list = list->next)
@ -133,7 +136,7 @@ just_echo:
while (list)
{
i = len = 0;
temp = do_v9 ? ansicstr (list->word->word, STRLEN (list->word->word), &i, &len)
temp = do_v9 ? ansicstr (list->word->word, STRLEN (list->word->word), 1, &i, &len)
: list->word->word;
if (temp)
{
@ -163,5 +166,10 @@ just_echo:
if (display_return)
putchar ('\n');
fflush (stdout);
if (ferror (stdout))
{
clearerr (stdout);
return (EXECUTION_FAILURE);
}
return (EXECUTION_SUCCESS);
}

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES enable.c
@ -56,6 +56,10 @@ $END
#include "common.h"
#include "bashgetopt.h"
#if defined (PROGRAMMABLE_COMPLETION)
# include "../pcomplete.h"
#endif
#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
static int dyn_load_builtin ();
#endif
@ -163,6 +167,9 @@ enable_builtin (list)
filter |= SPECIAL;
result = dyn_load_builtin (list, filter, filename);
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_builtins);
#endif
}
#endif
#if defined (HAVE_DLCLOSE)
@ -175,6 +182,9 @@ enable_builtin (list)
result = EXECUTION_FAILURE;
list = list->next;
}
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_builtins);
#endif
}
#endif
else
@ -237,6 +247,11 @@ enable_shell_command (name, disable_p)
else
b->flags |= BUILTIN_ENABLED;
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_enabled);
set_itemlist_dirty (&it_disabled);
#endif
return (EXECUTION_SUCCESS);
}

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES eval.c

View file

@ -4,7 +4,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@ -23,8 +23,8 @@
#endif
#include "../bashtypes.h"
#include "../posixstat.h"
#include "../filecntl.h"
#include "posixstat.h"
#include "filecntl.h"
#include <stdio.h>
#include <signal.h>

View file

@ -4,7 +4,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@ -30,7 +30,7 @@
#include <errno.h>
#include "../filecntl.h"
#include "filecntl.h"
#include "../bashansi.h"
#include "../shell.h"
@ -54,6 +54,7 @@ extern int errno;
#define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL)
extern void run_trap_cleanup ();
extern int zwrite ();
extern int interactive, interactive_shell;
extern int indirection_level, startup_state, subshell_environment;
@ -94,7 +95,7 @@ parse_and_execute (string, from_file, flags)
char *from_file;
int flags;
{
int code;
int code, x;
volatile int should_jump_to_top_level, last_result;
char *orig_string;
COMMAND *volatile command;
@ -119,6 +120,12 @@ parse_and_execute (string, from_file, flags)
# endif /* BANG_HISTORY */
#endif /* HISTORY */
if (interactive_shell)
{
x = get_current_prompt_level ();
add_unwind_protect (set_current_prompt_level, x);
}
add_unwind_protect (pop_stream, (char *)NULL);
if (orig_string)
add_unwind_protect (xfree, orig_string);
@ -282,36 +289,6 @@ parse_and_execute (string, from_file, flags)
return (last_result);
}
/* Write NB bytes from BUF to file descriptor FD, retrying the write if
it is interrupted. We retry three times if we get a zero-length
write. Any other signal causes this function to return prematurely. */
static int
zwrite (fd, buf, nb)
int fd;
unsigned char *buf;
int nb;
{
int n, i, nt;
for (n = nb, nt = 0;;)
{
i = write (fd, buf, n);
if (i > 0)
{
n -= i;
if (n <= 0)
return nb;
}
else if (i == 0)
{
if (++nt > 3)
return (nb - n);
}
else if (errno != EINTR)
return -1;
}
}
/* Handle a $( < file ) command substitution. This expands the filename,
returning errors as appropriate, then just cats the file to the standard
output. */
@ -349,10 +326,7 @@ cat_file (r)
rval = 0;
while (1)
{
/* Retry the reads on EINTR. Any other error causes a break from the
loop. */
while ((nr = read (fd, lbuf, sizeof(lbuf))) < 0 && errno == EINTR)
;
nr = zread (fd, lbuf, sizeof(lbuf));
if (nr == 0)
break;
else if (nr < 0)

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES exec.c
@ -37,7 +37,7 @@ $END
#include <config.h>
#include "../bashtypes.h"
#include "../posixstat.h"
#include "posixstat.h"
#include <signal.h>
#include <errno.h>

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES exit.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES fc.c
@ -53,7 +53,7 @@ $END
# include <sys/param.h>
#endif
#include "../bashtypes.h"
#include "../posixstat.h"
#include "posixstat.h"
#ifndef _MINIX
# include <sys/file.h>
#endif
@ -70,8 +70,8 @@ $END
#include "../shell.h"
#include "../builtins.h"
#include "../flags.h"
#include "../maxpath.h"
#include "../bashhist.h"
#include "maxpath.h"
#include <readline/history.h>
#include "bashgetopt.h"
#include "common.h"

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES fg_bg.c

View file

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@ -27,7 +27,7 @@
#endif
#include <stdio.h>
#include "../memalloc.h"
#include "memalloc.h"
#include "../shell.h"
#include "getopt.h"

View file

@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* XXX THIS HAS BEEN MODIFIED FOR INCORPORATION INTO BASH XXX */

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES getopts.c
@ -194,7 +194,7 @@ dogetopts (argc, argv)
;
for (words = rest_of_args; words; words = words->next, i++)
;
v = (char **)xmalloc ((i + 1) * sizeof (char *));
v = alloc_array (i + 1);
for (i = 0; i < 10 && dollar_vars[i]; i++)
v[i] = dollar_vars[i];
for (words = rest_of_args; words; words = words->next, i++)

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES hash.c
@ -106,6 +106,14 @@ hash_builtin (list)
if (expunge_hash_table)
flush_hashed_filenames ();
#if defined (RESTRICTED_SHELL)
if (restricted && pathname && strchr (pathname, '/'))
{
builtin_error ("%s: restricted", pathname);
return (EXECUTION_FAILURE);
}
#endif
for (opt = EXECUTION_SUCCESS; list; list = list->next)
{
/* Add or rehash the specified commands. */

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,17 +17,19 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES help.c
$BUILTIN help
$FUNCTION help_builtin
$DEPENDS_ON HELP_BUILTIN
$SHORT_DOC help [pattern ...]
$SHORT_DOC help [-s] [pattern ...]
Display helpful information about builtin commands. If PATTERN is
specified, gives detailed help on all commands matching PATTERN,
otherwise a list of the builtins is printed.
otherwise a list of the builtins is printed. The -s option
restricts the output for each builtin command matching PATTERN to
a short usage synopsis.
$END
#include <config.h>
@ -64,14 +66,17 @@ help_builtin (list)
{
register int i, j;
char *pattern, *name;
int plen, match_found;
int plen, match_found, sflag;
/* Placeholder for future options. */
sflag = 0;
reset_internal_getopt ();
while ((i = internal_getopt (list, "")) != -1)
while ((i = internal_getopt (list, "s")) != -1)
{
switch (i)
{
case 's':
sflag = 1;
break;
default:
builtin_usage ();
return (EX_USAGE);
@ -108,8 +113,9 @@ help_builtin (list)
{
printf ("%s: %s\n", name, shell_builtins[i].short_doc);
for (j = 0; shell_builtins[i].long_doc[j]; j++)
printf (" %s\n", shell_builtins[i].long_doc[j]);
if (sflag == 0)
for (j = 0; shell_builtins[i].long_doc[j]; j++)
printf (" %s\n", shell_builtins[i].long_doc[j]);
match_found++;
}

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,18 +17,19 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES history.c
$BUILTIN history
$FUNCTION history_builtin
$DEPENDS_ON HISTORY
$SHORT_DOC history [-c] [n] or history -awrn [filename] or history -ps arg [arg...]
$SHORT_DOC history [-c] [-d offset] [n] or history -awrn [filename] or history -ps arg [arg...]
Display the history list with line numbers. Lines listed with
with a `*' have been modified. Argument of N says to list only
the last N lines. The -c option causes the history list to be
cleared by deleting all of the entries. The `-w' option writes out the
the last N lines. The `-c' option causes the history list to be
cleared by deleting all of the entries. The `-d' option deletes
the history entry at offset OFFSET. The `-w' option writes out the
current history to the history file; `-r' means to read the file and
append the contents to the history list instead. `-a' means
to append history lines from this session to the history file.
@ -49,8 +50,8 @@ $END
#ifndef _MINIX
# include <sys/file.h>
#endif
#include "../posixstat.h"
#include "../filecntl.h"
#include "posixstat.h"
#include "filecntl.h"
#include <errno.h>
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
@ -72,6 +73,7 @@ extern int errno;
static void display_history ();
static void push_history ();
static int expand_and_print_history ();
static int delete_histent ();
#define AFLAG 0x01
#define RFLAG 0x02
@ -80,17 +82,19 @@ static int expand_and_print_history ();
#define SFLAG 0x10
#define PFLAG 0x20
#define CFLAG 0x40
#define DFLAG 0x80
int
history_builtin (list)
WORD_LIST *list;
{
int flags, opt, result;
char *filename;
char *filename, *delete_arg;
long delete_offset;
flags = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "acnpsrw")) != -1)
while ((opt = internal_getopt (list, "acd:npsrw")) != -1)
{
switch (opt)
{
@ -112,6 +116,10 @@ history_builtin (list)
case 's':
flags |= SFLAG;
break;
case 'd':
flags |= DFLAG;
delete_arg = list_optarg;
break;
case 'p':
#if defined (BANG_HISTORY)
flags |= PFLAG;
@ -153,6 +161,26 @@ history_builtin (list)
return (EXECUTION_SUCCESS);
}
#endif
else if (flags & DFLAG)
{
if (legal_number (delete_arg, &delete_offset) == 0)
{
builtin_error ("%s: not a valid history position", delete_arg);
return (EXECUTION_FAILURE);
}
opt = delete_offset;
if (opt < history_base || opt < 0 || opt > (history_base + history_length))
{
builtin_error ("%d: not a valid history position", opt);
return (EXECUTION_FAILURE);
}
result = delete_histent (opt - history_base);
/* Since remove_history changes history_length, this can happen if
we delete the last history entry. */
if (where_history () > history_length)
history_set_pos (history_length);
return (result ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
else if ((flags & (AFLAG|RFLAG|NFLAG|WFLAG|CFLAG)) == 0)
{
display_history (list);
@ -224,11 +252,28 @@ display_history (list)
}
}
/* Delete and free the history list entry at offset I. */
static int
delete_histent (i)
int i;
{
HIST_ENTRY *discard;
discard = remove_history (i);
if (discard)
{
if (discard->line)
free (discard->line);
free ((char *) discard);
}
return 1;
}
static int
delete_last_history ()
{
register int i;
HIST_ENTRY **hlist, *histent, *discard;
HIST_ENTRY **hlist, *histent;
hlist = history_list ();
if (hlist == NULL)
@ -243,14 +288,7 @@ delete_last_history ()
if (histent == NULL)
return 0;
discard = remove_history (i);
if (discard)
{
if (discard->line)
free (discard->line);
free ((char *) discard);
}
return (1);
return (delete_histent (i));
}
/* Remove the last entry in the history list and add each argument in

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES inlib.c
#include <config.h>

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES jobs.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES kill.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$BUILTIN let
$FUNCTION let_builtin

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@ -33,8 +33,8 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <sys/file.h>
#endif
#include "../posixstat.h"
#include "../filecntl.h"
#include "posixstat.h"
#include "filecntl.h"
#include "../bashansi.h"
#include <stdio.h>
@ -1036,7 +1036,7 @@ char *structfile_header[] = {
"",
" Bash is free software; you can redistribute it and/or modify it",
" under the terms of the GNU General Public License as published by",
" the Free Software Foundation; either version 1, or (at your option)",
" the Free Software Foundation; either version 2, or (at your option)",
" any later version.",
"",
" Bash is distributed in the hope that it will be useful, but WITHOUT",
@ -1046,7 +1046,7 @@ char *structfile_header[] = {
"",
" You should have received a copy of the GNU General Public License",
" along with Bash; see the file COPYING. If not, write to the Free",
" Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */",
" Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */",
"",
"/* The list of shell builtins. Each element is name, function, flags,",
" long-doc, short-doc. The long-doc field contains a pointer to an array",

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -54,7 +54,7 @@ $END
#include "../bashansi.h"
#include "../shell.h"
#include "../stdc.h"
#include "stdc.h"
#include "bashgetopt.h"
#if !defined (errno)
@ -74,12 +74,13 @@ extern int errno;
} while (0)
#define PRETURN(value) \
do { free (format); fflush (stdout); return (value); } while (0)
do { /* free (format); */ fflush (stdout); return (value); } while (0)
#define SKIP1 "#-+ 0"
#define SKIP2 "*0123456789"
static void printstr __P((char *, char *, int, int, int));
static int tescape __P((char *, int, char *, int *));
static char *bexpand __P((char *, int, int *, int *));
static char *mklong __P((char *, int));
static int getchr __P((void));
@ -125,12 +126,12 @@ printf_builtin (list)
if (list->word->word == 0 || list->word->word[0] == '\0')
return (EXECUTION_SUCCESS);
format = ansicstr (list->word->word, strlen (list->word->word), (int *)NULL, &fmtlen);
format = list->word->word;
garglist = list->next;
/* If the format string is empty after preprocessing, return immediately. */
if ((format == 0 || *format == 0) && fmtlen == 0)
if (format == 0 || *format == 0)
return (EXECUTION_SUCCESS);
/* Basic algorithm is to scan the format string for conversion
@ -139,15 +140,25 @@ printf_builtin (list)
format strings are reused as necessary to use up the provided
arguments, arguments of zero/null string are provided to use
up the format string. */
#define FMTIND (fmt - format)
do
{
/* find next format specification */
for (fmt = format; FMTIND < fmtlen; fmt++)
for (fmt = format; *fmt; fmt++)
{
precision = fieldwidth = foundmod = 0;
if (*fmt == '\\')
{
fmt++;
/* A NULL third argument to tescape means to not do special
processing for \c. */
fmt += tescape (fmt, 1, &nextch, (int *)NULL);
putchar (nextch);
fmt--; /* for loop will increment it for us again */
continue;
}
if (*fmt != '%')
{
putchar (*fmt);
@ -301,10 +312,10 @@ printf_builtin (list)
break;
}
/* We output unrecognized format characters, but we print a
warning message and return a failure exit status. */
/* We don't output unrecognized format characters; we print an
error message and return a failure exit status. */
default:
builtin_error ("`%c': illegal format character", convch);
builtin_error ("`%c': invalid format character", convch);
PRETURN (EXECUTION_FAILURE);
}
@ -430,14 +441,114 @@ printstr (fmt, string, len, fieldwidth, precision)
#define HEXVALUE(c) \
((c) >= 'a' && (c) <= 'f' ? (c)-'a'+10 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
/* Translate a single backslash-escape sequence starting at ESTART (the
character after the backslash) and return the number of characters
consumed by the sequence. CP is the place to return the translated
value. *SAWC is set to 1 if the escape sequence was \c, since that means
to short-circuit the rest of the processing. If SAWC is null, we don't
do the \c short-circuiting, and \c is treated as an unrecognized escape
sequence. */
static int
tescape (estart, trans_squote, cp, sawc)
char *estart;
int trans_squote;
char *cp;
int *sawc;
{
register char *p;
int temp, c, evalue;
p = estart;
switch (c = *p++)
{
#if defined (__STDC__)
case 'a': *cp = '\a'; break;
#else
case 'a': *cp = '\007'; break;
#endif
case 'b': *cp = '\b'; break;
case 'e': *cp = '\033'; break; /* ESC -- non-ANSI */
case 'f': *cp = '\f'; break;
case 'n': *cp = '\n'; break;
case 'r': *cp = '\r'; break;
case 't': *cp = '\t'; break;
case 'v': *cp = '\v'; break;
/* %b octal constants are `\0' followed by one, two, or three
octal digits... */
case '0':
for (temp = 3, evalue = 0; isoctal (*p) && temp--; p++)
evalue = (evalue * 8) + OCTVALUE (*p);
*cp = evalue;
break;
/* but, as an extension, the other echo-like octal escape
sequences are supported as well. */
case '1': case '2': case '3': case '4':
case '5': case '6': case '7':
for (temp = 2, evalue = c - '0'; isoctal (*p) && temp--; p++)
evalue = (evalue * 8) + OCTVALUE (*p);
*cp = evalue;
break;
/* And, as another extension, we allow \xNNN, where each N is a
hex digit. */
case 'x':
for (temp = 3, evalue = 0; isxdigit (*p) && temp--; p++)
evalue = (evalue * 16) + HEXVALUE (*p);
if (temp == 3)
{
builtin_error ("missing hex digit for \\x");
*cp = '\\';
return 0;
}
*cp = evalue;
break;
case '\\': /* \\ -> \ */
*cp = c;
break;
case '\'': /* TRANS_SQUOTE != 0 means \' -> ' */
if (trans_squote)
*cp = c;
else
{
*cp = '\\';
return 0;
}
break;
case 'c':
if (sawc)
{
*sawc = 1;
break;
}
/* other backslash escapes are passed through unaltered */
default:
*cp = '\\';
return 0;
}
return (p - estart);
}
static char *
bexpand (string, len, sawc, lenp)
char *string;
int len, *sawc, *lenp;
{
int c, temp;
char *ret, *r, *s;
int temp;
char *ret, *r, *s, c;
if (string == 0 || *string == '\0')
{
@ -457,74 +568,13 @@ bexpand (string, len, sawc, lenp)
*r++ = c;
continue;
}
switch (c = *s++)
temp = 0;
s += tescape (s, 0, &c, &temp);
if (temp)
{
#if defined (__STDC__)
case 'a': c = '\a'; break;
#else
case 'a': c = '\007'; break;
#endif
case 'b': c = '\b'; break;
case 'e': c = '\033'; break; /* ESC -- non-ANSI */
case 'f': c = '\f'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
case 't': c = '\t'; break;
case 'v': c = '\v'; break;
/* %b octal constants are `\0' followed by one, two, or three
octal digits... */
case '0':
for (temp = 3, c = 0; isoctal (*s) && temp--; s++)
c = (c * 8) + OCTVALUE (*s);
break;
/* but, as an extension, the other echo-like octal escape
sequences are supported as well. */
case '1': case '2': case '3': case '4':
case '5': case '6': case '7':
for (temp = 2, c -= '0'; isoctal (*s) && temp--; s++)
c = (c * 8) + OCTVALUE (*s);
break;
/* And, as another extension, we allow \xNNN, where each N is a
hex digit. */
case 'x':
for (temp = 3, c = 0; isxdigit (*s) && temp--; s++)
c = (c * 16) + HEXVALUE (*s);
if (temp == 3)
{
builtin_error ("missing hex digit for \\x");
*r++ = '\\';
c = 'x';
}
break;
case '\\':
#if 0
case '\'': /* XXX */
case '"': /* XXX */
#endif
break;
case 'c':
if (sawc)
*sawc = 1;
*r = '\0';
if (lenp)
*lenp = r - ret;
return ret;
/* other backslash escapes are passed through unaltered */
default: *r++ = '\\'; break;
break;
}
*r++ = c;
@ -600,6 +650,7 @@ getlong (lp)
long *lp;
{
long ret;
char *ep;
if (garglist == 0)
{
@ -614,11 +665,14 @@ getlong (lp)
}
errno = 0;
/* legal_number does not currently detect overflow, but it should.
Someday it will. */
if (legal_number (garglist->word->word, &ret) == 0)
/* If we use 0 as the third argument, we can handle octal and hex, which
legal_number does not. (This was
if (legal_number (garglist->word->word, &ret) == 0)
) */
ret = strtol (garglist->word->word, &ep, 0);
if (*ep != '\0')
{
builtin_error ("%s: illegal number", garglist->word->word);
builtin_error ("%s: invalid number", garglist->word->word);
return (1);
}
else if (errno == ERANGE)
@ -656,7 +710,7 @@ getulong (ulp)
if (*ep)
{
builtin_error ("%s: illegal number", garglist->word->word);
builtin_error ("%s: invalid number", garglist->word->word);
return (1);
}
else if (errno == ERANGE)

View file

@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Write output in 128-byte chunks until we get a sigpipe or write gets an
EPIPE. Then report how many bytes we wrote. We assume that this is the

View file

@ -3,7 +3,7 @@
# psize.sh -- determine this system's pipe size, and write a define to
# pipesize.h so ulimit.c can use it.
TMPDIR=/tmp
: ${TMPDIR:=/tmp}
TMPNAME=pipsize.$$
TMPFILE=$TMPDIR/$TMPNAME

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES pushd.c
@ -113,7 +113,7 @@ $END
#include <tilde/tilde.h>
#include "../shell.h"
#include "../maxpath.h"
#include "maxpath.h"
#include "common.h"
#include "builtext.h"

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,44 +17,53 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES read.c
$BUILTIN read
$FUNCTION read_builtin
$SHORT_DOC read [-r] [-p prompt] [-a array] [-e] [name ...]
$SHORT_DOC read [-ers] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...]
One line is read from the standard input, and the first word is
assigned to the first NAME, the second word to the second NAME, and so
on, with leftover words assigned to the last NAME. Only the characters
found in $IFS are recognized as word delimiters. The return code is
zero, unless end-of-file is encountered. If no NAMEs are supplied, the
line read is stored in the REPLY variable. If the -r option is given,
this signifies `raw' input, and backslash escaping is disabled. If
the `-p' option is supplied, the string supplied as an argument is
output without a trailing newline before attempting to read. If -a is
supplied, the words read are assigned to sequential indices of ARRAY,
starting at zero. If -e is supplied and the shell is interactive,
readline is used to obtain the line.
found in $IFS are recognized as word delimiters. If no NAMEs are supplied,
the line read is stored in the REPLY variable. If the -r option is given,
this signifies `raw' input, and backslash escaping is disabled. The
-d option causes read to continue until the first character of DELIM is
read, rather than newline. If the `-p' option is supplied, the string
PROMPT is output without a trailing newline before attempting to read.
If -a is supplied, the words read are assigned to sequential indices of
ARRAY, starting at zero. If -e is supplied and the shell is interactive,
readline is used to obtain the line. If -n is supplied with a non-zero
NCHARS argument, read returns after NCHARS characters have been read.
The -s option causes input coming from a terminal to not be echoed.
The -t option causes read to time out and return failure if a complete line
of input is not read within TIMEOUT seconds. The return code is zero,
unless end-of-file is encountered or read times out.
$END
#include <config.h>
#include "bashtypes.h"
#include "posixstat.h"
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include <signal.h>
#include <errno.h>
#include "../shell.h"
#include "common.h"
#include "bashgetopt.h"
#include <shtty.h>
#if defined (READLINE)
#include "../bashline.h"
#include <readline/readline.h>
@ -70,9 +79,29 @@ extern int interrupt_immediately;
#if defined (READLINE)
static char *edit_line ();
static void set_eol_delim ();
static void reset_eol_delim ();
#endif
static SHELL_VAR *bind_read_variable ();
static procenv_t alrmbuf;
static SigHandler *old_alrm;
static int delim;
static sighandler
sigalrm (s)
int s;
{
longjmp (alrmbuf, 1);
}
static void
reset_alarm ()
{
set_signal_handler (SIGALRM, old_alrm);
alarm (0);
}
/* Read the value of the shell variables whose names follow.
The reading is done from the current input stream, whatever
that may be. Successive words of the input line are assigned
@ -84,10 +113,14 @@ read_builtin (list)
WORD_LIST *list;
{
register char *varname;
int size, i, raw, pass_next, saw_escape, eof, opt, retval, edit;
int size, i, pass_next, saw_escape, eof, opt, retval, code;
int input_is_tty, input_is_pipe, unbuffered_read;
int raw, edit, tmout, nchars, silent;
long timeoutval, ncharsval;
char c;
char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
char *e, *t, *t1;
struct stat tsb;
SHELL_VAR *var;
#if defined (ARRAY_VARS)
WORD_LIST *alist;
@ -99,6 +132,7 @@ read_builtin (list)
i = 0; /* Index into the string that we are reading. */
raw = edit = 0; /* Not reading raw input by default. */
silent = 0;
arrayname = prompt = (char *)NULL;
#if defined (READLINE)
@ -106,8 +140,12 @@ read_builtin (list)
rlind = 0;
#endif
tmout = -1; /* no timeout */
nchars = input_is_tty = input_is_pipe = unbuffered_read = 0;
delim = '\n'; /* read until newline */
reset_internal_getopt ();
while ((opt = internal_getopt (list, "erp:a:")) != -1)
while ((opt = internal_getopt (list, "erp:a:d:t:n:s")) != -1)
{
switch (opt)
{
@ -117,6 +155,9 @@ read_builtin (list)
case 'p':
prompt = list_optarg;
break;
case 's':
silent = 1;
break;
case 'e':
#if defined (READLINE)
edit = 1;
@ -127,6 +168,29 @@ read_builtin (list)
arrayname = list_optarg;
break;
#endif
case 't':
code = legal_number (list_optarg, &timeoutval);
if (code == 0 || timeoutval < 0)
{
builtin_error ("%s: invalid timeout specification", list_optarg);
return (EXECUTION_FAILURE);
}
else
tmout = timeoutval;
break;
case 'n':
code = legal_number (list_optarg, &ncharsval);
if (code == 0 || ncharsval < 0)
{
builtin_error ("%s: invalid number specification", list_optarg);
return (EXECUTION_FAILURE);
}
else
nchars = ncharsval;
break;
case 'd':
delim = *list_optarg;
break;
default:
builtin_usage ();
return (EX_USAGE);
@ -134,6 +198,10 @@ read_builtin (list)
}
list = loptend;
/* `read -t 0 var' returns failure immediately. */
if (tmout == 0)
return (EXECUTION_FAILURE);
/* IF IFS is unset, we use the default of " \t\n". */
var = find_variable ("IFS");
ifs_chars = var ? value_cell (var) : " \t\n";
@ -149,12 +217,20 @@ read_builtin (list)
#endif
interrupt_immediately++;
/* If the -p or -e flags were given, but input is not coming from the
input_is_tty = isatty (0);
if (input_is_tty == 0)
#ifndef __CYGWIN32__
input_is_pipe = (lseek (0, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
#else
input_is_pipe = 1;
#endif
/* If the -p, -e or -s flags were given, but input is not coming from the
terminal, turn them off. */
if ((prompt || edit) && (isatty (0) == 0))
if ((prompt || edit || silent) && input_is_tty == 0)
{
prompt = (char *)NULL;
edit = 0;
edit = silent = 0;
}
if (prompt && edit == 0)
@ -166,6 +242,67 @@ read_builtin (list)
pass_next = 0; /* Non-zero signifies last char was backslash. */
saw_escape = 0; /* Non-zero signifies that we saw an escape char */
if (tmout > 0)
{
/* Turn off the timeout if stdin is a regular file (e.g. from
input redirection). */
if ((fstat (0, &tsb) < 0) || S_ISREG (tsb.st_mode))
tmout = -1;
}
if (tmout > 0)
{
code = setjmp (alrmbuf);
if (code)
{
run_unwind_frame ("read_builtin");
return (EXECUTION_FAILURE);
}
old_alrm = set_signal_handler (SIGALRM, sigalrm);
add_unwind_protect (reset_alarm, (char *)NULL);
alarm (tmout);
}
/* If we've been asked to read only NCHARS chars, or we're using some
character other than newline to terminate the line, do the right
thing to readline or the tty. */
if (nchars > 0 || delim != '\n')
{
#if defined (READLINE)
if (edit)
{
if (nchars > 0)
{
unwind_protect_int (rl_num_chars_to_read);
rl_num_chars_to_read = nchars;
}
if (delim != '\n')
{
set_eol_delim (delim);
add_unwind_protect (reset_eol_delim, (char *)NULL);
}
}
else
#endif
if (input_is_tty)
{
ttsave ();
if (silent)
ttcbreak ();
else
ttonechar ();
add_unwind_protect ((Function *)ttrestore, (char *)NULL);
}
}
else if (silent) /* turn off echo but leave term in canonical mode */
{
ttsave ();
ttnoecho ();
add_unwind_protect ((Function *)ttrestore, (char *)NULL);
}
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
for (eof = 0;;)
{
#if defined (READLINE)
@ -192,8 +329,11 @@ read_builtin (list)
{
#endif
while (((retval = read (0, &c, 1)) < 0) && errno == EINTR)
;
if (unbuffered_read)
retval = zread (0, &c, 1);
else
retval = zreadc (0, &c);
if (retval <= 0)
{
eof = 1;
@ -227,7 +367,7 @@ read_builtin (list)
continue;
}
if (c == '\n')
if (c == delim)
break;
if (c == CTLESC || c == CTLNUL)
@ -237,9 +377,36 @@ read_builtin (list)
}
input_string[i++] = c;
if (nchars > 0 && i >= nchars)
break;
}
input_string[i] = '\0';
if (tmout > 0)
reset_alarm ();
if (nchars > 0 || delim != '\n')
{
#if defined (READLINE)
if (edit)
{
if (nchars > 0)
rl_num_chars_to_read = 0;
if (delim != '\n')
reset_eol_delim ();
}
else
#endif
if (input_is_tty)
ttrestore ();
}
else if (silent)
ttrestore ();
if (unbuffered_read == 0)
zsyncfd (0);
interrupt_immediately--;
discard_unwind_frame ("read_builtin");
@ -294,7 +461,7 @@ read_builtin (list)
}
else
var = bind_variable ("REPLY", input_string);
var->attributes &= ~att_invisible;
VUNSETATTR (var, att_invisible);
#if 0
free (orig_input_string);
#else
@ -360,7 +527,7 @@ read_builtin (list)
}
stupidly_hack_special_variables (varname);
var->attributes &= ~att_invisible;
VUNSETATTR (var, att_invisible);
}
/* Now assign the rest of the line to the last variable argument. */
@ -390,7 +557,7 @@ read_builtin (list)
var = bind_read_variable (list->word->word, input_string);
stupidly_hack_special_variables (list->word->word);
if (var)
var->attributes &= ~att_invisible;
VUNSETATTR (var, att_invisible);
free (orig_input_string);
return (retval);
@ -434,8 +601,55 @@ edit_line (p)
return ret;
len = strlen (ret);
ret = xrealloc (ret, len + 2);
ret[len++] = '\n';
ret[len++] = delim;
ret[len] = '\0';
return ret;
}
static int old_delim_ctype;
static Function *old_delim_func;
static int old_newline_ctype;
static Function *old_newline_func;
static int delim_char;
static void
set_eol_delim (c)
int c;
{
Keymap cmap;
if (bash_readline_initialized == 0)
initialize_readline ();
cmap = rl_get_keymap ();
/* Change newline to self-insert */
old_newline_ctype = cmap[RETURN].type;
old_newline_func = cmap[RETURN].function;
cmap[RETURN].type = ISFUNC;
cmap[RETURN].function = rl_insert;
/* Bind the delimiter character to accept-line. */
old_delim_ctype = cmap[c].type;
old_delim_func = cmap[c].function;
cmap[c].type = ISFUNC;
cmap[c].function = rl_newline;
delim_char = c;
}
static void
reset_eol_delim (c)
int c;
{
Keymap cmap;
cmap = rl_get_keymap ();
cmap[RETURN].type = old_newline_ctype;
cmap[RETURN].function = old_newline_func;
cmap[delim_char].type = old_delim_ctype;
cmap[delim_char].function = old_delim_func;
}
#endif

View file

@ -8,7 +8,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -18,7 +18,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$BUILTIN for
$SHORT_DOC for NAME [in WORDS ... ;] do COMMANDS; done

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES return.c
@ -42,6 +42,7 @@ $END
#include "common.h"
extern int last_command_exit_value;
extern int subshell_environment;
extern int return_catch_flag, return_catch_value;
/* If we are executing a user-defined function then exit with the value

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES set.c
@ -266,6 +266,23 @@ list_minus_o_opts (mode, reusable)
}
}
char **
get_minus_o_opts ()
{
char **ret;
int n, i, ind;
n = (sizeof (o_options) / sizeof (o_options[0])) +
(sizeof (binary_o_options) / sizeof (binary_o_options[0]));
ret = alloc_array (n + 1);
for (i = ind = 0; o_options[i].name; i++)
ret[ind++] = o_options[i].name;
for (i = 0; binary_o_options[i].name; i++)
ret[ind++] = binary_o_options[i].name;
ret[ind] = (char *)NULL;
return ret;
}
static int
set_ignoreeof (on_or_off, option_name)
int on_or_off;
@ -457,7 +474,7 @@ set_shellopts ()
note whether or not the variable was exported. */
if (v)
{
v->attributes &= ~att_readonly;
VUNSETATTR (v, att_readonly);
exported = exported_p (v);
}
else
@ -468,9 +485,9 @@ set_shellopts ()
/* Turn the read-only attribute back on, and turn off the export attribute
if it was set implicitly by mark_modified_vars and SHELLOPTS was not
exported before we bound the new value. */
v->attributes |= att_readonly;
VSETATTR (v, att_readonly);
if (mark_modified_vars && exported == 0 && exported_p (v))
v->attributes &= ~att_exported;
VUNSETATTR (v, att_exported);
free (value);
}

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES setattr.c
@ -381,13 +381,13 @@ set_var_attribute (name, attribute, undo)
if (var == 0)
{
var = bind_variable (name, (char *)NULL);
var->attributes |= att_invisible;
VSETATTR (var, att_invisible);
}
}
if (var)
SETVARATTR (var, attribute, undo);
if (var && ((var->attributes & att_exported) || (attribute & att_exported)))
if (var && (exported_p (var) || (attribute & att_exported)))
array_needs_making++; /* XXX */
}

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES shift.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES shopt.c
@ -64,6 +64,7 @@ extern int cdspelling, expand_aliases;
extern int check_window_size;
extern int glob_ignore_case;
extern int hup_on_exit;
extern int xpg_echo;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
@ -76,9 +77,14 @@ extern int force_append_history;
#if defined (READLINE)
extern int hist_verify, history_reediting, perform_hostname_completion;
extern int no_empty_command_completion;
extern void enable_hostname_completion ();
#endif
#if defined (PROGRAMMABLE_COMPLETION)
extern int prog_completion_enabled;
#endif
#if defined (RESTRICTED_SHELL)
extern int restricted_shell;
extern char *shell_name;
@ -126,14 +132,21 @@ static struct {
{ "lithist", &literal_history, (Function *)NULL },
#endif
{ "mailwarn", &mail_warning, (Function *)NULL },
#if defined (READLINE)
{ "no_empty_cmd_completion", &no_empty_command_completion, (Function *)NULL },
#endif
{ "nocaseglob", &glob_ignore_case, (Function *)NULL },
{ "nullglob", &allow_null_glob_expansion, (Function *)NULL },
#if defined (PROGRAMMABLE_COMPLETION)
{ "progcomp", &prog_completion_enabled, (Function *)NULL },
#endif
{ "promptvars", &promptvars, (Function *)NULL },
#if defined (RESTRICTED_SHELL)
{ "restricted_shell", &restricted_shell, set_restricted_shell },
#endif
{ "shift_verbose", &print_shift_error, (Function *)NULL },
{ "sourcepath", &source_uses_path, (Function *)NULL },
{ "xpg_echo", &xpg_echo, (Function *)NULL },
{ (char *)0, (int *)0, (Function *)NULL }
};
@ -429,3 +442,17 @@ set_restricted_shell (mode)
return (0);
}
#endif /* RESTRICTED_SHELL */
char **
get_shopt_options ()
{
char **ret;
int n, i;
n = sizeof (shopt_vars) / sizeof (shopt_vars[0]);
ret = alloc_array (n + 1);
for (i = 0; shopt_vars[i].name; i++)
ret[i] = savestring (shopt_vars[i].name);
ret[i] = (char *)NULL;
return ret;
}

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES source.c
@ -39,8 +39,8 @@ $END
#include <config.h>
#include "../bashtypes.h"
#include "../posixstat.h"
#include "../filecntl.h"
#include "posixstat.h"
#include "filecntl.h"
#ifndef _MINIX
# include <sys/file.h>
#endif

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES suspend.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES test.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES times.c
@ -41,16 +41,7 @@ $END
#include "../bashtypes.h"
#include "../shell.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if defined (HAVE_SYS_TIME_H)
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <posixtime.h>
#if defined (HAVE_SYS_TIMES_H)
# include <sys/times.h>
@ -84,21 +75,19 @@ times_builtin (list)
#else
# if defined (HAVE_TIMES)
/* As of System V.3, HP-UX 6.5, and other ATT-like systems, this stuff is
returned in terms of clock ticks (HZ from sys/param.h). C'mon, guys.
This kind of stupid clock-dependent stuff is exactly the reason 4.2BSD
introduced the `timeval' struct. */
/* This uses the POSIX.1/XPG5 times(2) interface, which fills in a
`struct tms' with values of type clock_t. */
struct tms t;
times (&t);
print_time_in_hz (stdout, t.tms_utime);
print_clock_t (stdout, t.tms_utime);
putchar (' ');
print_time_in_hz (stdout, t.tms_stime);
print_clock_t (stdout, t.tms_stime);
putchar ('\n');
print_time_in_hz (stdout, t.tms_cutime);
print_clock_t (stdout, t.tms_cutime);
putchar (' ');
print_time_in_hz (stdout, t.tms_cstime);
print_clock_t (stdout, t.tms_cstime);
putchar ('\n');
# else /* !HAVE_TIMES */
printf ("0.00 0.00\n0.00 0.00\n");

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES trap.c

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES type.c
@ -44,7 +44,7 @@ $END
#include <config.h>
#include "../bashtypes.h"
#include "../posixstat.h"
#include "posixstat.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
@ -66,6 +66,8 @@ $END
extern int find_reserved_word ();
extern char *this_command_name;
/* For each word in LIST, find out what the shell is going to do with
it as a simple command. i.e., which file would this shell use to
execve, or if it is a builtin command, or an alias. Possible flag
@ -210,8 +212,8 @@ describe_command (command, verbose, all)
char *command;
int verbose, all;
{
int found, i, found_file;
char *full_path;
int found, i, found_file, f;
char *full_path, *x, *cwd;
SHELL_VAR *func;
#if defined (ALIAS)
alias_t *alias;
@ -232,7 +234,7 @@ describe_command (command, verbose, all)
printf ("%s is aliased to `%s'\n", command, alias->value);
else if (verbose == 4)
{
char *x = single_quote (alias->value);
x = single_quote (alias->value);
printf ("alias %s=%s\n", command, x);
free (x);
}
@ -313,7 +315,7 @@ describe_command (command, verbose, all)
check to see if it is executable. */
if (absolute_program (command))
{
int f = file_status (command);
f = file_status (command);
if (f & FS_EXECABLE)
{
if (verbose == 1)
@ -361,6 +363,23 @@ describe_command (command, verbose, all)
if (!full_path)
break;
/* If we found the command as itself by looking through $PATH, it
probably doesn't exist. Check whether or not the command is an
executable file. If it's not, don't report a match. */
if (STREQ (full_path, command))
{
f = file_status (full_path);
if ((f & FS_EXECABLE) == 0)
{
free (full_path);
full_path = (char *)NULL;
if (all == 0)
break;
}
else if (verbose >= 2)
full_path = sh_makepath ((char *)NULL, full_path, MP_DOCWD);
}
found_file++;
found = 1;

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES ulimit.c
@ -547,7 +547,11 @@ filesize(valuep)
if ((result = ulimit (1, 0L)) < 0)
return -1;
else
# if 0
*valuep = (RLIMTYPE) result;
# else
*valuep = (RLIMTYPE) result * 512L;
# endif
return 0;
#else
errno = EINVAL;

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES umask.c
@ -36,7 +36,7 @@ $END
#include <config.h>
#include "../bashtypes.h"
#include "../filecntl.h"
#include "filecntl.h"
#ifndef _MINIX
# include <sys/file.h>
#endif
@ -48,7 +48,7 @@ $END
#include <stdio.h>
#include "../shell.h"
#include "../posixstat.h"
#include "posixstat.h"
#include "common.h"
#include "bashgetopt.h"
@ -295,6 +295,8 @@ symbolic_umask (list)
more intuitive and easier to deal with. It is complemented
again before being returned. */
bits = parse_symbolic_mode (list->word->word, ~um);
if (bits == -1)
return (-1);
um = ~bits & 0777;
return (um);

View file

@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$BUILTIN wait
$FUNCTION wait_builtin
@ -59,6 +59,8 @@ $END
extern int interrupt_immediately;
procenv_t wait_intr_buf;
/* 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
0. If a list of pids or job specs are given, return the exit status of
@ -70,7 +72,7 @@ int
wait_builtin (list)
WORD_LIST *list;
{
int status;
int status, code;
if (no_options (list))
return (EX_USAGE);
@ -81,6 +83,21 @@ wait_builtin (list)
unwind_protect_int (interrupt_immediately);
interrupt_immediately++;
/* POSIX.2 says: When the shell is waiting (by means of the wait utility)
for asynchronous commands to complete, the reception of a signal for
which a trap has been set shall cause the wait utility to return
immediately with an exit status greater than 128, after which the trap
associated with the signal shall be taken.
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);
if (code)
{
status = 128 + SIGINT;
WAIT_RETURN (status);
}
/* We support jobs or pids.
wait <pid-or-job> [pid-or-job ...] */