diff options
author | Jari Aalto <jari.aalto@cante.net> | 2004-07-27 13:29:18 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:56 +0000 |
commit | b80f6443b6b7b620c7272664c66ecb0b120a0998 (patch) | |
tree | 9f71c98d8fe8fa0f41d95e1eb4227f32a09d43ca /builtins | |
parent | 7117c2d221b2aed4ede8600f6a36b7c1454b4f55 (diff) | |
download | android_external_bash-b80f6443b6b7b620c7272664c66ecb0b120a0998.tar.gz android_external_bash-b80f6443b6b7b620c7272664c66ecb0b120a0998.tar.bz2 android_external_bash-b80f6443b6b7b620c7272664c66ecb0b120a0998.zip |
Imported from ../bash-3.0.tar.gz.
Diffstat (limited to 'builtins')
43 files changed, 971 insertions, 398 deletions
diff --git a/builtins/Makefile.in b/builtins/Makefile.in index 53ae75a..4bb4ea5 100644 --- a/builtins/Makefile.in +++ b/builtins/Makefile.in @@ -1,6 +1,6 @@ # This Makefile for building libbuiltins.a is in -*- text -*- for Emacs. # -# Copyright (C) 1996 Free Software Foundation, Inc. +# Copyright (C) 1996-2003 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 @@ -16,6 +16,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_VERSION = @PACKAGE_VERSION@ + # SHELL = @MAKE_SHELL@ RANLIB = @RANLIB@ @@ -35,6 +41,7 @@ VPATH = .:@srcdir@ topdir = @top_srcdir@ includedir = @includedir@ datadir = @datadir@ +localedir = $(datadir)/locale # Support an alternate destination root directory for package building DESTDIR = @@ -43,6 +50,8 @@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ BUILD_DIR = @BUILD_DIR@ +LIBBUILD = ${BUILD_DIR}/lib + PROFILE_FLAGS = @PROFILE_FLAGS@ CFLAGS = @CFLAGS@ CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ @@ -63,10 +72,15 @@ BASHINCDIR = ${topdir}/include RL_INCLUDEDIR = @RL_INCLUDEDIR@ +INTL_LIBSRC = ${topdir}/lib/intl +INTL_BUILDDIR = ${LIBBUILD}/intl +INTL_INC = @INTL_INC@ +LIBINTL_H = @LIBINTL_H@ + HELPDIR = @HELPDIR@ MKDIRS = ${topdir}/support/mkdirs -INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir) +INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir) ${INTL_INC} BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \ ${INCLUDES} $(LOCAL_CFLAGS) @@ -106,7 +120,8 @@ RL_LIBSRC = $(topdir)/lib/readline $(CC) -c $(CCFLAGS) $< DEFSRC = $(srcdir)/alias.def $(srcdir)/bind.def $(srcdir)/break.def \ - $(srcdir)/builtin.def $(srcdir)/cd.def $(srcdir)/colon.def \ + $(srcdir)/builtin.def $(srcdir)/caller.def \ + $(srcdir)/cd.def $(srcdir)/colon.def \ $(srcdir)/command.def $(srcdir)/declare.def $(srcdir)/echo.def \ $(srcdir)/enable.def $(srcdir)/eval.def $(srcdir)/getopts.def \ $(srcdir)/exec.def $(srcdir)/exit.def $(srcdir)/fc.def \ @@ -124,7 +139,7 @@ STATIC_SOURCE = common.c evalstring.c evalfile.c getopt.c bashgetopt.c \ getopt.h OFILES = builtins.o \ - alias.o bind.o break.o builtin.o cd.o colon.o command.o \ + alias.o bind.o break.o builtin.o caller.o cd.o colon.o command.o \ common.o declare.o echo.o enable.o eval.o evalfile.o \ evalstring.o exec.o \ exit.o fc.o fg_bg.o hash.o help.o history.o jobs.o kill.o let.o \ @@ -214,10 +229,20 @@ distclean maintainer-clean: clean $(OFILES): $(MKBUILTINS) ../config.h +../version.h: ../config.h ../Makefile Makefile + -( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} version.h ) + +# maintainer special - for now +po: builtins.c + xgettext -L C -o $(topdir)/po/builtins.pot --keyword='N_' builtins.c 2>/dev/null + +# dependencies + alias.o: alias.def bind.o: bind.def break.o: break.def builtin.o: builtin.def +caller.o: caller.def cd.o: cd.def colon.o: colon.def command.o: command.def @@ -263,7 +288,7 @@ bashgetopt.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topd bashgetopt.o: $(topdir)/variables.h $(topdir)/conftypes.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 +bashgetopt.o: ../pathnames.h $(topdir)/externs.h $(srcdir)/common.h bashgetopt.o: $(BASHINCDIR)/chartypes.h common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h common.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h @@ -274,7 +299,7 @@ common.o: $(topdir)/siglist.h $(topdir)/bashhist.h $(topdir)/quit.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 +common.o: $(topdir)/externs.h ../pathnames.h ./builtext.h common.o: $(BASHINCDIR)/chartypes.h evalfile.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h ${BASHINCDIR}/filecntl.h evalfile.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h @@ -283,7 +308,7 @@ evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir evalfile.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h evalfile.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h -evalfile.o: $(topdir)/pathnames.h $(topdir)/externs.h +evalfile.o: ../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 @@ -303,8 +328,8 @@ getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/com getopt.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/error.h $(topdir)/variables.h $(topdir)/conftypes.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 +getopt.o: $(topdir)/sig.h ../pathnames.h $(topdir)/externs.h +getopt.o: $(srcdir)/getopt.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 @@ -331,6 +356,12 @@ builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h builtin.o: $(srcdir)/bashgetopt.h +caller.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h +caller.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h +caller.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h +caller.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +caller.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ./builtext.h +caller.o: ${BASHINCDIR}/chartypes.h $(topdir)/bashtypes.h cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h cd.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h @@ -347,6 +378,7 @@ declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h declare.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h declare.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h declare.o: $(topdir)/arrayfunc.h $(srcdir)/bashgetopt.h +declare.o: ./builtext.h echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h echo.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h @@ -362,7 +394,7 @@ enable.o: $(topdir)/pcomplete.h eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h eval.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h -eval.o: $(topdir)/subst.h $(topdir)/externs.h +eval.o: $(topdir)/subst.h $(topdir)/externs.h eval.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h eval.o: $(BASHINCDIR)/maxpath.h exec.o: $(topdir)/bashtypes.h @@ -377,7 +409,7 @@ exit.o: $(topdir)/bashtypes.h exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h exit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h -exit.o: $(topdir)/subst.h $(topdir)/externs.h +exit.o: $(topdir)/subst.h $(topdir)/externs.h exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h @@ -416,7 +448,7 @@ history.o: $(topdir)/bashtypes.h history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h -history.o: $(topdir)/subst.h $(topdir)/externs.h +history.o: $(topdir)/subst.h $(topdir)/externs.h history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h history.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h @@ -426,7 +458,7 @@ inlib.o: $(BASHINCDIR)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h inlib.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h jobs.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h jobs.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(srcdir)/bashgetopt.h -jobs.o: $(BASHINCDIR)/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)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h @@ -443,13 +475,13 @@ printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h -printf.o: $(topdir)/pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h +printf.o: ../pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h printf.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h printf.o: $(topdir)/bashtypes.h ${srcdir}/common.h $(BASHINCDIR)/chartypes.h pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h pushd.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h -pushd.o: $(topdir)/subst.h $(topdir)/externs.h +pushd.o: $(topdir)/subst.h $(topdir)/externs.h pushd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h @@ -474,7 +506,7 @@ setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h setattr.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h -setattr.o: $(topdir)/externs.h +setattr.o: $(topdir)/externs.h setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h setattr.o: $(topdir)/arrayfunc.h shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h @@ -487,7 +519,7 @@ source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/fi source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h -source.o: $(srcdir)/bashgetopt.h +source.o: $(srcdir)/bashgetopt.h $(topdir)/flags.h $(topdir)/trap.h suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h suspend.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h @@ -541,7 +573,7 @@ shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h -complete.o: ../config.h +complete.o: ../config.h complete.o: ${topdir}/shell.h $(topdir)/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h complete.o: ${topdir}/unwind_prot.h ${topdir}/variables.h complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h @@ -550,3 +582,40 @@ 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 + +# libintl dependencies +bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +break.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +caller.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +cd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +common.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +complete.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +declare.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +enable.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +evalfile.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +exec.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +exit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +fc.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +fg_bg.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +getopt.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +hash.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +help.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +history.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +inlib.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +jobs.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +kill.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +let.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +mkbuiltins.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +printf.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +pushd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +read.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +return.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +set.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +setattr.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +shift.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +shopt.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +source.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h diff --git a/builtins/alias.def b/builtins/alias.def index f51df94..572910b 100644 --- a/builtins/alias.def +++ b/builtins/alias.def @@ -1,7 +1,7 @@ This file is alias.def, from which is created alias.c It implements the builtins "alias" and "unalias" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -44,6 +44,7 @@ $END #endif # include "../bashansi.h" +# include "../bashintl.h" # include <stdio.h> # include "../shell.h" @@ -51,17 +52,23 @@ $END # include "common.h" # include "bashgetopt.h" -static void print_alias __P((alias_t *)); +/* Flags for print_alias */ +#define AL_REUSABLE 0x01 + +static void print_alias __P((alias_t *, int)); + +extern int posixly_correct; /* Hack the alias command in a Korn shell way. */ int alias_builtin (list) WORD_LIST *list; { - int any_failed, offset, pflag; + int any_failed, offset, pflag, dflags; alias_t **alias_list, *t; char *name, *value; + dflags = posixly_correct ? 0 : AL_REUSABLE; pflag = 0; reset_internal_getopt (); while ((offset = internal_getopt (list, "p")) != -1) @@ -70,6 +77,7 @@ alias_builtin (list) { case 'p': pflag = 1; + dflags |= AL_REUSABLE; break; default: builtin_usage (); @@ -90,7 +98,7 @@ alias_builtin (list) return (EXECUTION_SUCCESS); for (offset = 0; alias_list[offset]; offset++) - print_alias (alias_list[offset]); + print_alias (alias_list[offset], dflags); free (alias_list); /* XXX - Do not free the strings. */ @@ -111,13 +119,19 @@ alias_builtin (list) name[offset] = '\0'; value = name + offset + 1; - add_alias (name, value); + if (legal_alias_name (name, 0) == 0) + { + builtin_error (_("`%s': invalid alias name"), name); + any_failed++; + } + else + add_alias (name, value); } else { t = find_alias (name); if (t) - print_alias (t); + print_alias (t, dflags); else { sh_notfound (name); @@ -134,7 +148,7 @@ alias_builtin (list) $BUILTIN unalias $FUNCTION unalias_builtin $DEPENDS_ON ALIAS -$SHORT_DOC unalias [-a] [name ...] +$SHORT_DOC unalias [-a] name [name ...] Remove NAMEs from the list of defined aliases. If the -a option is given, then remove all alias definitions. $END @@ -171,6 +185,12 @@ unalias_builtin (list) return (EXECUTION_SUCCESS); } + if (list == 0) + { + builtin_usage (); + return (EX_USAGE); + } + aflag = 0; while (list) { @@ -192,13 +212,16 @@ unalias_builtin (list) /* Output ALIAS in such a way as to allow it to be read back in. */ static void -print_alias (alias) +print_alias (alias, flags) alias_t *alias; + int flags; { char *value; value = sh_single_quote (alias->value); - printf ("alias %s=%s\n", alias->name, value); + if (flags & AL_REUSABLE) + printf ("alias "); + printf ("%s=%s\n", alias->name, value); free (value); fflush (stdout); diff --git a/builtins/bind.def b/builtins/bind.def index ddf5619..4711031 100644 --- a/builtins/bind.def +++ b/builtins/bind.def @@ -1,7 +1,7 @@ This file is bind.def, from which is created bind.c. It implements the builtin "bind" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -72,6 +72,8 @@ extern int errno; #include <readline/readline.h> #include <readline/history.h> +#include "../bashintl.h" + #include "../shell.h" #include "../bashline.h" #include "bashgetopt.h" @@ -189,7 +191,7 @@ bind_builtin (list) kmap = rl_get_keymap_by_name (map_name); if (!kmap) { - builtin_error ("`%s': invalid keymap name", map_name); + builtin_error (_("`%s': invalid keymap name"), map_name); BIND_RETURN (EXECUTION_FAILURE); } } @@ -228,7 +230,7 @@ bind_builtin (list) { if (rl_read_init_file (initfile) != 0) { - builtin_error ("%s: cannot read: %s", initfile, strerror (errno)); + builtin_error (_("%s: cannot read: %s"), initfile, strerror (errno)); BIND_RETURN (EXECUTION_FAILURE); } } @@ -243,7 +245,7 @@ bind_builtin (list) { if (rl_set_key (remove_seq, (rl_command_func_t *)NULL, rl_get_keymap ()) != 0) { - builtin_error ("`%s': cannot unbind", remove_seq); + builtin_error (_("`%s': cannot unbind"), remove_seq); BIND_RETURN (EXECUTION_FAILURE); } } @@ -278,7 +280,7 @@ query_bindings (name) function = rl_named_function (name); if (function == 0) { - builtin_error ("`%s': unknown function name", name); + builtin_error (_("`%s': unknown function name"), name); return EXECUTION_FAILURE; } @@ -286,11 +288,11 @@ query_bindings (name) if (!keyseqs) { - printf ("%s is not bound to any keys.\n", name); + printf (_("%s is not bound to any keys.\n"), name); return EXECUTION_FAILURE; } - printf ("%s can be invoked via ", name); + printf (_("%s can be invoked via "), name); for (j = 0; j < 5 && keyseqs[j]; j++) printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n"); if (keyseqs[j]) diff --git a/builtins/break.def b/builtins/break.def index 1025414..e61d502 100644 --- a/builtins/break.def +++ b/builtins/break.def @@ -1,7 +1,7 @@ This file is break.def, from which is created break.c. It implements the builtins "break" and "continue" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -36,6 +36,8 @@ $END # include <unistd.h> #endif +#include "../bashintl.h" + #include "../shell.h" #include "common.h" @@ -123,7 +125,7 @@ check_loop_level () { #if defined (BREAK_COMPLAINS) if (loop_level == 0 && posixly_correct == 0) - builtin_error ("only meaningful in a `for', `while', or `until' loop"); + builtin_error (_("only meaningful in a `for', `while', or `until' loop")); #endif /* BREAK_COMPLAINS */ return (loop_level); diff --git a/builtins/builtin.def b/builtins/builtin.def index 8571f37..dfa58bc 100644 --- a/builtins/builtin.def +++ b/builtins/builtin.def @@ -68,7 +68,7 @@ builtin_builtin (list) if (!function) { - builtin_error ("%s: not a shell builtin", command); + sh_notbuiltin (command); return (EXECUTION_FAILURE); } else diff --git a/builtins/caller.def b/builtins/caller.def new file mode 100644 index 0000000..d372c58 --- /dev/null +++ b/builtins/caller.def @@ -0,0 +1,147 @@ +This file is caller.def, from which is created caller.c. It implements the +builtin "caller" in Bash. + +Copyright (C) 2002-2003 Rocky Bernstein for 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 caller.c + +$BUILTIN caller +$FUNCTION caller_builtin +$DEPENDS_ON DEBUGGER +$SHORT_DOC caller [EXPR] + +Returns the context of the current subroutine call. + +Without EXPR, returns returns "$line $filename". With EXPR, +returns "$line $subroutine $filename"; this extra information +can be used used to provide a stack trace. + +The value of EXPR indicates how many call frames to go back before the +current one; the top frame is frame 0. +$END + +#include <config.h> +#include <stdio.h> +#include "chartypes.h" +#include "bashtypes.h" + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include <sys/types.h> +# endif +# include <unistd.h> +#endif + +#include <errno.h> + +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" +#include "builtext.h" + +#ifdef LOADABLE_BUILTIN +# include "builtins.h" +#endif + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +int +caller_builtin (list) + WORD_LIST *list; +{ +#if !defined (ARRAY_VARS) + printf ("1 NULL\n"); + return (EXECUTION_FAILURE); +#else + SHELL_VAR *funcname_v, *bash_source_v, *bash_lineno_v; + ARRAY *funcname_a, *bash_source_a, *bash_lineno_a; + char *funcname_s, *source_s, *lineno_s; + ARRAY_ELEMENT *ae; + intmax_t num; + + GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a); + GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a); + GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a); + + if (bash_lineno_a == 0 || array_empty (bash_lineno_a)) + return (EXECUTION_FAILURE); + + if (bash_source_a == 0 || array_empty (bash_source_a)) + return (EXECUTION_FAILURE); + + /* If there is no argument list, then give short form: line filename. */ + if (list == 0) + { + lineno_s = array_reference (bash_lineno_a, 0); + source_s = array_reference (bash_source_a, 1); + printf("%s %s\n", lineno_s ? lineno_s : "NULL", source_s ? source_s : "NULL"); + return (EXECUTION_SUCCESS); + } + + if (funcname_a == 0 || array_empty (funcname_a)) + return (EXECUTION_FAILURE); + + if (legal_number (list->word->word, &num)) + { + lineno_s = array_reference (bash_lineno_a, num); + source_s = array_reference (bash_source_a, num+1); + funcname_s = array_reference (funcname_a, num+1); + + if (lineno_s == NULL|| source_s == NULL || funcname_s == NULL) + return (EXECUTION_FAILURE); + + printf("%s %s %s\n", lineno_s, funcname_s, source_s); + } + else + { + sh_invalidnum (list->word->word); + builtin_usage (); + return (EXECUTION_FAILURE); + } + + return (EXECUTION_SUCCESS); +#endif +} + +#ifdef LOADABLE_BUILTIN +static char *caller_doc[] = { + N_("Returns the context of the current subroutine call."), + N_(""), + N_("Without EXPR, returns returns \"$line $filename\". With EXPR,"), + N_("returns \"$line $subroutine $filename\"; this extra information"), + N_("can be used used to provide a stack trace."), + N_(""), + N_("The value of EXPR indicates how many call frames to go back before the"), + N_("current one; the top frame is frame 0."), + (char *)NULL +}; + +struct builtin caller_struct = { + "caller", + caller_builtin, + BUILTIN_ENABLED, + caller_doc, + "caller [EXPR]", + 0 +}; + +#endif /* LOADABLE_BUILTIN */ diff --git a/builtins/cd.def b/builtins/cd.def index 1c58c7c..2be86d1 100644 --- a/builtins/cd.def +++ b/builtins/cd.def @@ -1,7 +1,7 @@ This file is cd.def, from which is created cd.c. It implements the builtins "cd" and "pwd" in Bash. -Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -39,6 +39,7 @@ $PRODUCES cd.c #include <stdio.h> #include "../bashansi.h" +#include "../bashintl.h" #include <errno.h> #include <tilde/tilde.h> @@ -106,28 +107,30 @@ bindpwd (no_symlinks) array_needs_making = 0; } - tvar = bind_variable ("PWD", dirname); + tvar = bind_variable ("PWD", dirname ? dirname : ""); if (old_anm == 0 && array_needs_making && exported_p (tvar)) { - update_export_env_inplace ("PWD=", 4, dirname); + update_export_env_inplace ("PWD=", 4, dirname ? dirname : ""); array_needs_making = 0; } if (dirname && dirname != the_current_working_directory) free (dirname); + return (EXECUTION_SUCCESS); } /* Call get_working_directory to reset the value of the_current_working_directory () */ static char * -resetpwd () +resetpwd (caller) + char *caller; { char *tdir; FREE (the_current_working_directory); the_current_working_directory = (char *)NULL; - tdir = get_working_directory ("cd"); + tdir = get_working_directory (caller); return (tdir); } @@ -184,7 +187,7 @@ cd_builtin (list) if (dirname == 0) { - builtin_error ("HOME not set"); + builtin_error (_("HOME not set")); return (EXECUTION_FAILURE); } lflag = 0; @@ -196,10 +199,14 @@ cd_builtin (list) if (dirname == 0) { - builtin_error ("OLDPWD not set"); + builtin_error (_("OLDPWD not set")); return (EXECUTION_FAILURE); } +#if 0 lflag = interactive ? LCD_PRINTPATH : 0; +#else + lflag = LCD_PRINTPATH; /* According to SUSv3 */ +#endif } else if (absolute_pathname (list->word->word)) dirname = list->word->word; @@ -222,8 +229,8 @@ cd_builtin (list) is used to find the directory to change to, the new directory name is echoed to stdout, whether or not the shell is interactive. */ - if (opt) - printf ("%s\n", no_symlinks ? temp : the_current_working_directory); + if (opt && (path = no_symlinks ? temp : the_current_working_directory)) + printf ("%s\n", path); free (temp); /* Posix.2 says that after using CDPATH, the resultant @@ -332,6 +339,12 @@ pwd_builtin (list) directory = tcwd ? (verbatim_pwd ? sh_physpath (tcwd, 0) : tcwd) : get_working_directory ("pwd"); + + /* Try again using getcwd() if canonicalization fails (for instance, if + the file system has changed state underneath bash). */ + if (tcwd && directory == 0) + directory = resetpwd ("pwd"); + #undef tcwd if (directory) @@ -342,9 +355,11 @@ pwd_builtin (list) fflush (stdout); if (ferror (stdout)) { - builtin_error ("write error: %s", strerror (errno)); + builtin_error (_("write error: %s"), strerror (errno)); + clearerr (stdout); return (EXECUTION_FAILURE); } + return (EXECUTION_SUCCESS); } else @@ -363,7 +378,7 @@ change_to_directory (newdir, nolinks) int nolinks; { char *t, *tdir; - int err, canon_failed; + int err, canon_failed, r; tdir = (char *)NULL; @@ -398,7 +413,12 @@ change_to_directory (newdir, nolinks) resolved path doesn't exist), fail immediately. */ if (posixly_correct && nolinks == 0 && canon_failed) { - errno = ENOENT; +#if defined ENAMETOOLONG + if (errno != ENOENT && errno != ENAMETOOLONG) +#else + if (errno != ENOENT) +#endif + errno = ENOTDIR; return (0); } @@ -408,12 +428,13 @@ change_to_directory (newdir, nolinks) /* If canonicalization failed, but the chdir succeeded, reset the shell's idea of the_current_working_directory. */ if (canon_failed) - resetpwd (); - else { - FREE (the_current_working_directory); - the_current_working_directory = tdir; + t = resetpwd ("cd"); + if (t == 0) + set_working_directory (tdir); } + else + set_working_directory (tdir); return (1); } @@ -424,23 +445,28 @@ change_to_directory (newdir, nolinks) return (0); err = errno; - free (tdir); /* We're not in physical mode (nolinks == 0), but we failed to change to the canonicalized directory name (TDIR). Try what the user passed verbatim. If we succeed, reinitialize the_current_working_directory. */ if (chdir (newdir) == 0) { - tdir = resetpwd (); - FREE (tdir); + t = resetpwd ("cd"); + if (t == 0) + set_working_directory (tdir); + else + free (t); - return (1); + r = 1; } else { errno = err; - return (0); + r = 0; } + + free (tdir); + return r; } /* Code for cd spelling correction. Original patch submitted by diff --git a/builtins/common.c b/builtins/common.c index b818600..3d3dd59 100644 --- a/builtins/common.c +++ b/builtins/common.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -40,6 +40,7 @@ #endif #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "maxpath.h" @@ -129,7 +130,7 @@ no_args (list) { if (list) { - builtin_error ("too many arguments"); + builtin_error (_("too many arguments")); jump_to_top_level (DISCARD); } } @@ -153,21 +154,21 @@ void sh_needarg (s) char *s; { - builtin_error ("%s: option requires an argument", s); + builtin_error (_("%s: option requires an argument"), s); } void sh_neednumarg (s) char *s; { - builtin_error ("%s: numeric argument required", s); + builtin_error (_("%s: numeric argument required"), s); } void sh_notfound (s) char *s; { - builtin_error ("%s: not found", s); + builtin_error (_("%s: not found"), s); } /* Function called when one of the builtin commands detects an invalid @@ -176,49 +177,49 @@ void sh_invalidopt (s) char *s; { - builtin_error ("%s: invalid option", s); + builtin_error (_("%s: invalid option"), s); } void sh_invalidoptname (s) char *s; { - builtin_error ("%s: invalid option name", s); + builtin_error (_("%s: invalid option name"), s); } void sh_invalidid (s) char *s; { - builtin_error ("`%s': not a valid identifier", s); + builtin_error (_("`%s': not a valid identifier"), s); } void sh_invalidnum (s) char *s; { - builtin_error ("%s: invalid number", s); + builtin_error (_("%s: invalid number"), s); } void sh_invalidsig (s) char *s; { - builtin_error ("%s: invalid signal specification", s); + builtin_error (_("%s: invalid signal specification"), s); } void sh_badpid (s) char *s; { - builtin_error ("`%s': not a pid or valid job spec", s); + builtin_error (_("`%s': not a pid or valid job spec"), s); } void sh_readonly (s) const char *s; { - builtin_error ("%s: readonly variable", s); + builtin_error (_("%s: readonly variable"), s); } void @@ -226,9 +227,9 @@ sh_erange (s, desc) char *s, *desc; { if (s) - builtin_error ("%s: %s out of range", s, desc ? desc : "argument"); + builtin_error (_("%s: %s out of range"), s, desc ? desc : _("argument")); else - builtin_error ("%s out of range", desc ? desc : "argument"); + builtin_error (_("%s out of range"), desc ? desc : _("argument")); } #if defined (JOB_CONTROL) @@ -236,7 +237,7 @@ void sh_badjob (s) char *s; { - builtin_error ("%s: no such job", s); + builtin_error (_("%s: no such job"), s); } void @@ -244,9 +245,9 @@ sh_nojobs (s) char *s; { if (s) - builtin_error ("%s: no job control"); + builtin_error (_("%s: no job control"), s); else - builtin_error ("no job control"); + builtin_error (_("no job control")); } #endif @@ -256,12 +257,19 @@ sh_restricted (s) char *s; { if (s) - builtin_error ("%s: restricted", s); + builtin_error (_("%s: restricted"), s); else - builtin_error ("restricted"); + builtin_error (_("restricted")); } #endif +void +sh_notbuiltin (s) + char *s; +{ + builtin_error (_("%s: not a shell builtin"), s); +} + /* **************************************************************** */ /* */ /* Shell positional parameter manipulation */ @@ -454,28 +462,22 @@ get_working_directory (for_whom) char *for_whom; { char *directory; + size_t dsize; if (no_symbolic_links) { - if (the_current_working_directory) - free (the_current_working_directory); - + FREE (the_current_working_directory); the_current_working_directory = (char *)NULL; } if (the_current_working_directory == 0) { - the_current_working_directory = (char *)xmalloc (PATH_MAX); - the_current_working_directory[0] = '\0'; - directory = getcwd (the_current_working_directory, PATH_MAX); - if (directory == 0) + the_current_working_directory = getcwd (0, 0); + if (the_current_working_directory == 0) { - fprintf (stderr, "%s: could not get current directory: %s: %s\n", + fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"), (for_whom && *for_whom) ? for_whom : get_name_for_error (), - bash_getcwd_errstr, strerror (errno)); - - free (the_current_working_directory); - the_current_working_directory = (char *)NULL; + _(bash_getcwd_errstr), strerror (errno)); return (char *)NULL; } } @@ -537,9 +539,9 @@ get_job_by_name (name, flags) else if (job != NO_JOB) { if (this_shell_builtin) - builtin_error ("%s: ambiguous job spec", name); + builtin_error (_("%s: ambiguous job spec"), name); else - report_error ("%s: ambiguous job spec", name); + report_error (_("%s: ambiguous job spec"), name); return (DUP_JOB); } else @@ -565,7 +567,7 @@ get_job_spec (list) word = list->word->word; if (*word == '\0') - return (current_job); + return (NO_JOB); if (*word == '%') word++; @@ -573,17 +575,14 @@ get_job_spec (list) if (DIGIT (*word) && all_digits (word)) { job = atoi (word); -#if 0 - return (job >= job_slots ? NO_JOB : job - 1); -#else return (job > job_slots ? NO_JOB : job - 1); -#endif } jflags = 0; switch (*word) { case 0: + return NO_JOB; case '%': case '+': return (current_job); @@ -602,6 +601,9 @@ get_job_spec (list) } #endif /* JOB_CONTROL */ +/* + * NOTE: `kill' calls this function with forcecols == 0 + */ int display_signal_list (list, forcecols) WORD_LIST *list; @@ -609,8 +611,7 @@ display_signal_list (list, forcecols) { register int i, column; char *name; - int result; - int signum; + int result, signum, dflags; intmax_t lsignum; result = EXECUTION_SUCCESS; @@ -623,7 +624,13 @@ display_signal_list (list, forcecols) continue; if (posixly_correct && !forcecols) - printf ("%s%s", name, (i == NSIG - 1) ? "" : " "); + { + /* This is for the kill builtin. POSIX.2 says the signal names + are displayed without the `SIG' prefix. */ + if (STREQN (name, "SIG", 3)) + name += 3; + printf ("%s%s", name, (i == NSIG - 1) ? "" : " "); + } else { printf ("%2d) %s", i, name); @@ -677,7 +684,10 @@ display_signal_list (list, forcecols) } else { - signum = decode_signal (list->word->word); + dflags = DSIG_NOCASE; + if (posixly_correct == 0 || this_shell_builtin != kill_builtin) + dflags |= DSIG_SIGPREFIX; + signum = decode_signal (list->word->word, dflags); if (signum == NO_SIG) { sh_invalidsig (list->word->word); diff --git a/builtins/common.h b/builtins/common.h index a971bcd..411ce1e 100644 --- a/builtins/common.h +++ b/builtins/common.h @@ -1,6 +1,6 @@ /* common.h -- extern declarations for functions defined in common.c. */ -/* Copyright (C) 1993-2002 Free Software Foundation, Inc. +/* Copyright (C) 1993-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -30,6 +30,7 @@ #define SEVAL_INTERACT 0x002 #define SEVAL_NOHIST 0x004 #define SEVAL_NOFREE 0x008 +#define SEVAL_RESETLINE 0x010 /* Flags for describe_command, shared between type.def and command.def */ #define CDESC_ALL 0x001 /* type -a */ @@ -74,6 +75,7 @@ extern void sh_badjob __P((char *)); extern void sh_readonly __P((const char *)); extern void sh_nojobs __P((char *)); extern void sh_restricted __P((char *)); +extern void sh_notbuiltin __P((char *)); extern char **make_builtin_argv __P((WORD_LIST *, int *)); extern void remember_args __P((WORD_LIST *, int)); @@ -105,6 +107,9 @@ extern sh_builtin_func_t *builtin_address __P((char *)); extern sh_builtin_func_t *find_special_builtin __P((char *)); extern void initialize_shell_builtins __P((void)); +/* Functions from exit.def */ +extern void bash_logout __P((void)); + /* Functions from getopts.def */ extern void getopts_reset __P((int)); @@ -150,7 +155,7 @@ extern void parse_and_execute_cleanup __P((void)); /* Functions from evalfile.c */ extern int maybe_execute_file __P((const char *, int)); -extern int source_file __P((const char *)); +extern int source_file __P((const char *, int)); extern int fc_execute_file __P((const char *)); #endif /* !__COMMON_H */ diff --git a/builtins/complete.def b/builtins/complete.def index f391620..a859b88 100644 --- a/builtins/complete.def +++ b/builtins/complete.def @@ -1,7 +1,7 @@ This file is complete.def, from which is created complete.c. It implements the builtins "complete" and "compgen" in Bash. -Copyright (C) 1999-2002 Free Software Foundation, Inc. +Copyright (C) 1999-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -43,10 +43,12 @@ $END #endif #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "../builtins.h" #include "../pcomplete.h" +#include "../bashline.h" #include "common.h" #include "bashgetopt.h" @@ -106,10 +108,12 @@ static struct _compopt { char *optname; int optflag; } compopts[] = { + { "bashdefault", COPT_BASHDEFAULT }, { "default", COPT_DEFAULT }, { "dirnames", COPT_DIRNAMES }, { "filenames",COPT_FILENAMES}, { "nospace", COPT_NOSPACE }, + { "plusdirs", COPT_PLUSDIRS }, { (char *)NULL, 0 }, }; @@ -244,7 +248,7 @@ build_actions (list, pp, rp, actp, optp) ind = find_compact (list_optarg); if (ind < 0) { - builtin_error ("%s: invalid action name", list_optarg); + builtin_error (_("%s: invalid action name"), list_optarg); return (EX_USAGE); } acts |= compacts[ind].actflag; @@ -374,7 +378,7 @@ remove_cmd_completions (list) { if (progcomp_remove (l->word->word) == 0) { - builtin_error ("%s: no completion specification", l->word->word); + builtin_error (_("%s: no completion specification"), l->word->word); ret = EXECUTION_FAILURE; } } @@ -428,10 +432,12 @@ print_one_completion (cmd, cs) copts = cs->options; /* First, print the -o options. */ + PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault"); PRINTCOMPOPT (COPT_DEFAULT, "default"); PRINTCOMPOPT (COPT_DIRNAMES, "dirnames"); PRINTCOMPOPT (COPT_FILENAMES, "filenames"); PRINTCOMPOPT (COPT_NOSPACE, "nospace"); + PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs"); acts = cs->actions; @@ -515,7 +521,7 @@ print_cmd_completions (list) print_one_completion (l->word->word, cs); else { - builtin_error ("%s: no completion specification", l->word->word); + builtin_error (_("%s: no completion specification"), l->word->word); ret = EXECUTION_FAILURE; } } @@ -540,7 +546,7 @@ compgen_builtin (list) unsigned long acts, copts; COMPSPEC *cs; STRINGLIST *sl; - char *word; + char *word, **matches; if (list == 0) return (EXECUTION_SUCCESS); @@ -562,9 +568,9 @@ compgen_builtin (list) word = (list && list->word) ? list->word->word : ""; if (Farg) - internal_warning ("compgen: -F option may not work as you expect"); + builtin_error (_("warning: -F option may not work as you expect")); if (Carg) - internal_warning ("compgen: -C option may not work as you expect"); + builtin_error (_("warning: -C option may not work as you expect")); /* If we get here, we need to build a compspec and evaluate it. */ cs = compspec_create (); @@ -583,12 +589,19 @@ compgen_builtin (list) rval = EXECUTION_FAILURE; sl = gen_compspec_completions (cs, "compgen", word, 0, 0); + /* If the compspec wants the bash default completions, temporarily + turn off programmable completion and call the bash completion code. */ + if ((sl == 0 || sl->list_len == 0) && (copts & COPT_BASHDEFAULT)) + { + matches = bash_default_completion (word, 0, 0, 0, 0); + sl = completions_to_stringlist (matches); + strvec_dispose (matches); + } + /* This isn't perfect, but it's the best we can do, given what readline exports from its set of completion utility functions. */ if ((sl == 0 || sl->list_len == 0) && (copts & COPT_DEFAULT)) { - char **matches; - matches = rl_completion_matches (word, rl_filename_completion_function); sl = completions_to_stringlist (matches); strvec_dispose (matches); diff --git a/builtins/declare.def b/builtins/declare.def index 75b154f..fe112dd 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -1,7 +1,7 @@ This file is declare.def, from which is created declare.c. It implements the builtins "declare" and "local" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -23,7 +23,7 @@ $PRODUCES declare.c $BUILTIN declare $FUNCTION declare_builtin -$SHORT_DOC declare [-afFirtx] [-p] name[=value] ... +$SHORT_DOC declare [-afFirtx] [-p] [name[=value] ...] Declare variables and/or give them attributes. If no NAMEs are given, then display the values of variables instead. The -p option will display the attributes and values of each NAME. @@ -32,7 +32,8 @@ The flags are: -a to make NAMEs arrays (if supported) -f to select from among function names only - -F to display function names without definitions + -F to display function names (and line number and source file name if + debugging) without definitions -i to make NAMEs have the `integer' attribute -r to make NAMEs readonly -t to make NAMEs have the `trace' attribute @@ -67,6 +68,7 @@ $END #include <stdio.h> #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "common.h" @@ -100,7 +102,7 @@ local_builtin (list) return (declare_internal (list, 1)); else { - builtin_error ("can only be used in a function"); + builtin_error (_("can only be used in a function")); return (EXECUTION_FAILURE); } } @@ -120,6 +122,7 @@ declare_internal (list, local_var) int flags_on, flags_off, *flags, any_failed, assign_error, pflag, nodefs, opt; char *t, *subscript_start; SHELL_VAR *var; + FUNCTION_DEF *shell_fn; flags_on = flags_off = any_failed = assign_error = pflag = nodefs = 0; reset_internal_getopt (); @@ -225,7 +228,7 @@ declare_internal (list, local_var) #endif name = savestring (list->word->word); - offset = assignment (name); + offset = assignment (name, 0); if (offset) /* declare [-afFirx] name=value */ { @@ -289,7 +292,7 @@ declare_internal (list, local_var) { if (offset) /* declare -f [-rix] foo=bar */ { - builtin_error ("cannot use `-f' to make functions"); + builtin_error (_("cannot use `-f' to make functions")); free (name); return (EXECUTION_FAILURE); } @@ -301,7 +304,7 @@ declare_internal (list, local_var) { if (readonly_p (var) && (flags_off & att_readonly)) { - builtin_error ("%s: readonly function", name); + builtin_error (_("%s: readonly function"), name); any_failed++; NEXT_VARIABLE (); } @@ -309,9 +312,22 @@ declare_internal (list, local_var) /* declare -[Ff] name [name...] */ if (flags_on == att_function && flags_off == 0) { - t = nodefs ? var->name - : named_function_string (name, function_cell (var), 1); - printf ("%s\n", t); +#if defined (DEBUGGER) + if (nodefs && debugging_mode) + { + shell_fn = find_function_def (var->name); + if (shell_fn) + printf ("%s %d %s\n", var->name, shell_fn->line, shell_fn->source_file); + else + printf ("%s\n", var->name); + } + else +#endif /* DEBUGGER */ + { + t = nodefs ? var->name + : named_function_string (name, function_cell (var), 1); + printf ("%s\n", t); + } } else /* declare -[fF] -[rx] name [name...] */ { @@ -370,7 +386,7 @@ declare_internal (list, local_var) /* Cannot use declare +a name to remove an array variable. */ if ((flags_off & att_array) && array_p (var)) { - builtin_error ("%s: cannot destroy array variables in this way", name); + builtin_error (_("%s: cannot destroy array variables in this way"), name); any_failed++; NEXT_VARIABLE (); } diff --git a/builtins/echo.def b/builtins/echo.def index 07e9f24..a91c8e4 100644 --- a/builtins/echo.def +++ b/builtins/echo.def @@ -133,6 +133,8 @@ echo_builtin (list) just_echo: + clearerr (stdout); /* clear error before writing and testing success */ + while (list) { i = len = 0; diff --git a/builtins/enable.def b/builtins/enable.def index 7496d42..823c38f 100644 --- a/builtins/enable.def +++ b/builtins/enable.def @@ -1,7 +1,7 @@ This file is enable.def, from which is created enable.c. It implements the builtin "enable" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -50,6 +50,8 @@ $END #include <stdio.h> #include "../bashansi.h" +#include "../bashintl.h" + #include "../shell.h" #include "../builtins.h" #include "../flags.h" @@ -123,7 +125,7 @@ enable_builtin (list) filename = list_optarg; break; #else - builtin_error ("dynamic loading not available"); + builtin_error (_("dynamic loading not available")); return (EX_USAGE); #endif #if defined (HAVE_DLCLOSE) @@ -131,7 +133,7 @@ enable_builtin (list) flags |= DFLAG; break; #else - builtin_error ("dynamic loading not available"); + builtin_error (_("dynamic loading not available")); return (EX_USAGE); #endif /* HAVE_DLCLOSE */ default: @@ -197,7 +199,7 @@ enable_builtin (list) if (opt == EXECUTION_FAILURE) { - builtin_error ("%s: not a shell builtin", list->word->word); + sh_notbuiltin (list->word->word); result = EXECUTION_FAILURE; } list = list->next; @@ -298,7 +300,7 @@ dyn_load_builtin (list, flags, filename) if (handle == 0) { - builtin_error ("cannot open shared object %s: %s", filename, dlerror ()); + builtin_error (_("cannot open shared object %s: %s"), filename, dlerror ()); return (EXECUTION_FAILURE); } @@ -321,8 +323,8 @@ dyn_load_builtin (list, flags, filename) b = (struct builtin *)dlsym (handle, struct_name); if (b == 0) { - builtin_error ("cannot find %s in shared object %s: %s", struct_name, - filename, dlerror ()); + builtin_error (_("cannot find %s in shared object %s: %s"), + struct_name, filename, dlerror ()); free (struct_name); continue; } @@ -440,12 +442,12 @@ dyn_unload_builtin (name) b = builtin_address_internal (name, 1); if (b == 0) { - builtin_error ("%s: not a shell builtin", name); + sh_notbuiltin (name); return (EXECUTION_FAILURE); } if (b->flags & STATIC_BUILTIN) { - builtin_error ("%s: not dynamically loaded", name); + builtin_error (_("%s: not dynamically loaded"), name); return (EXECUTION_FAILURE); } @@ -460,7 +462,7 @@ dyn_unload_builtin (name) using it drops to zero. */ if (ref == 1 && local_dlclose (handle) != 0) { - builtin_error ("%s: cannot delete: %s", name, dlerror ()); + builtin_error (_("%s: cannot delete: %s"), name, dlerror ()); return (EXECUTION_FAILURE); } diff --git a/builtins/evalfile.c b/builtins/evalfile.c index 0675753..c17e547 100644 --- a/builtins/evalfile.c +++ b/builtins/evalfile.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -31,6 +31,7 @@ #include <errno.h> #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "../jobs.h" @@ -58,6 +59,7 @@ extern int errno; #define FEVAL_HISTORY 0x020 #define FEVAL_CHECKBINARY 0x040 #define FEVAL_REGFILE 0x080 +#define FEVAL_NOPUSHARGS 0x100 extern int posixly_correct; extern int indirection_level, startup_state, subshell_environment; @@ -79,9 +81,28 @@ _evalfile (filename, flags) struct stat finfo; size_t file_size; sh_vmsg_func_t *errfunc; +#if defined (ARRAY_VARS) + SHELL_VAR *funcname_v, *bash_source_v, *bash_lineno_v; + ARRAY *funcname_a, *bash_source_a, *bash_lineno_a; +# if defined (DEBUGGER) + SHELL_VAR *bash_argv_v, *bash_argc_v; + ARRAY *bash_argv_a, *bash_argc_a; +# endif + char *t, tt[2]; +#endif USE_VAR(pflags); +#if defined (ARRAY_VARS) + GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a); + GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a); + GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a); +# if defined (DEBUGGER) + GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a); + GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a); +# endif +#endif + fd = open (filename, O_RDONLY); if (fd < 0 || (fstat (fd, &finfo) == -1)) @@ -104,12 +125,12 @@ file_error_and_exit: if (S_ISDIR (finfo.st_mode)) { - (*errfunc) ("%s: is a directory", filename); + (*errfunc) (_("%s: is a directory"), filename); return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); } else if ((flags & FEVAL_REGFILE) && S_ISREG (finfo.st_mode) == 0) { - (*errfunc) ("%s: not a regular file", filename); + (*errfunc) (_("%s: not a regular file"), filename); return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); } @@ -117,7 +138,7 @@ file_error_and_exit: /* Check for overflow with large files. */ if (file_size != finfo.st_size || file_size + 1 < file_size) { - (*errfunc) ("%s: file is too large", filename); + (*errfunc) (_("%s: file is too large"), filename); return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); } @@ -176,8 +197,27 @@ file_error_and_exit: return_catch_flag++; sourcelevel++; +#if defined (ARRAY_VARS) + array_push (bash_source_a, (char *)filename); + t = itos (executing_line_number ()); + array_push (bash_lineno_a, t); + free (t); + array_push (funcname_a, "source"); /* not exactly right */ +# if defined (DEBUGGER) + /* Have to figure out a better way to do this when `source' is supplied + arguments */ + if ((flags & FEVAL_NOPUSHARGS) == 0) + { + array_push (bash_argv_a, (char *)filename); + tt[0] = '1'; tt[1] = '\0'; + array_push (bash_argc_a, tt); + } +# endif +#endif + /* set the flags to be passed to parse_and_execute */ - pflags = (flags & FEVAL_HISTORY) ? 0 : SEVAL_NOHIST; + pflags = SEVAL_RESETLINE; + pflags |= (flags & FEVAL_HISTORY) ? 0 : SEVAL_NOHIST; if (flags & FEVAL_BUILTIN) result = EXECUTION_SUCCESS; @@ -205,6 +245,19 @@ file_error_and_exit: COPY_PROCENV (old_return_catch, return_catch); } +#if defined (ARRAY_VARS) + array_pop (bash_source_a); + array_pop (bash_lineno_a); + array_pop (funcname_a); +# if defined (DEBUGGER) + if ((flags & FEVAL_NOPUSHARGS) == 0) + { + array_pop (bash_argc_a); + array_pop (bash_argv_a); + } +# endif +#endif + return ((flags & FEVAL_BUILTIN) ? result : 1); } @@ -240,14 +293,20 @@ fc_execute_file (filename) #endif /* HISTORY */ int -source_file (filename) +source_file (filename, sflags) const char *filename; + int sflags; { - int flags; + int flags, rval; flags = FEVAL_BUILTIN|FEVAL_UNWINDPROT|FEVAL_NONINT; + if (sflags) + flags |= FEVAL_NOPUSHARGS; /* POSIX shells exit if non-interactive and file error. */ if (posixly_correct && !interactive_shell) flags |= FEVAL_LONGJMP; - return (_evalfile (filename, flags)); + rval = _evalfile (filename, flags); + + run_return_trap (); + return rval; } diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 860a3de..88d6a9e 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -84,6 +84,7 @@ parse_and_execute_cleanup () (flags & SEVAL_INTERACT) -> interactive = 1; (flags & SEVAL_NOHIST) -> call bash_history_disable () (flags & SEVAL_NOFREE) -> don't free STRING when finished + (flags & SEVAL_RESETLINE) -> reset line_number to 1 */ int @@ -92,7 +93,7 @@ parse_and_execute (string, from_file, flags) const char *from_file; int flags; { - int code, x; + int code, x, lreset; volatile int should_jump_to_top_level, last_result; char *orig_string; COMMAND *volatile command; @@ -107,6 +108,8 @@ parse_and_execute (string, from_file, flags) if (flags & (SEVAL_NONINT|SEVAL_INTERACT)) unwind_protect_int (interactive); + lreset = flags & SEVAL_RESETLINE; + #if defined (HISTORY) unwind_protect_int (remember_on_history); /* can be used in scripts */ # if defined (BANG_HISTORY) @@ -129,7 +132,15 @@ parse_and_execute (string, from_file, flags) end_unwind_frame (); parse_and_execute_level++; - push_stream (1); /* reset the line number */ + + /* Reset the line number if the caller wants us to. If we don't reset the + line number, we have to subtract one, because we will add one just + before executing the next command (resetting the line number sets it to + 0; the first line number is 1). */ + push_stream (lreset); + if (lreset == 0) + line_number--; + indirection_level++; if (flags & (SEVAL_NONINT|SEVAL_INTERACT)) interactive = (flags & SEVAL_NONINT) ? 0 : 1; @@ -141,11 +152,12 @@ parse_and_execute (string, from_file, flags) code = should_jump_to_top_level = 0; last_result = EXECUTION_SUCCESS; - command = (COMMAND *)NULL; with_input_from_string (string, from_file); while (*(bash_input.location.string)) { + command = (COMMAND *)NULL; + if (interrupt_state) { last_result = EXECUTION_FAILURE; @@ -163,15 +175,18 @@ parse_and_execute (string, from_file, flags) switch (code) { case FORCE_EOF: + case ERREXIT: case EXITPROG: - run_unwind_frame ("pe_dispose"); + if (command) + run_unwind_frame ("pe_dispose"); /* Remember to call longjmp (top_level) after the old value for it is restored. */ should_jump_to_top_level = 1; goto out; case DISCARD: - run_unwind_frame ("pe_dispose"); + if (command) + run_unwind_frame ("pe_dispose"); last_result = last_command_exit_value = EXECUTION_FAILURE; /* XXX */ if (subshell_environment) { diff --git a/builtins/exec.def b/builtins/exec.def index a6881b8..acfdae1 100644 --- a/builtins/exec.def +++ b/builtins/exec.def @@ -1,7 +1,7 @@ This file is exec.def, from which is created exec.c. It implements the builtin "exec" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -46,6 +46,7 @@ $END #endif #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "../execute_cmd.h" @@ -201,15 +202,14 @@ exec_builtin (list) if (executable_file (command) == 0) { - builtin_error ("%s: cannot execute: %s", command, strerror (errno)); + builtin_error (_("%s: cannot execute: %s"), command, strerror (errno)); exit_value = EX_NOEXEC; /* As per Posix.2, 3.14.6 */ } else file_error (command); failed_exec: - if (command) - free (command); + FREE (command); if (subshell_environment || (interactive == 0 && no_exit_on_failed_exec == 0)) exit_shell (exit_value); diff --git a/builtins/exit.def b/builtins/exit.def index bf1d920..9384ade 100644 --- a/builtins/exit.def +++ b/builtins/exit.def @@ -1,7 +1,7 @@ This file is exit.def, from which is created exit.c. It implements the builtins "exit", and "logout" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -37,6 +37,8 @@ $END # include <unistd.h> #endif +#include "../bashintl.h" + #include "../shell.h" #include "../jobs.h" @@ -44,6 +46,7 @@ $END #include "builtext.h" /* for jobs_builtin */ extern int last_command_exit_value; +extern int running_trap, trap_saved_exit_value; extern int subshell_environment; extern sh_builtin_func_t *this_shell_builtin; extern sh_builtin_func_t *last_shell_builtin; @@ -77,7 +80,7 @@ logout_builtin (list) { if (login_shell == 0 /* && interactive */) { - builtin_error ("not login shell: use `exit'"); + builtin_error (_("not login shell: use `exit'")); return (EXECUTION_FAILURE); } else @@ -105,7 +108,7 @@ exit_or_logout (list) for (i = 0; i < job_slots; i++) if (jobs[i] && STOPPED (i)) { - fprintf (stderr, "There are stopped jobs.\n"); + fprintf (stderr, _("There are stopped jobs.\n")); /* This is NOT superfluous because EOF can get here without going through the command parser. Set both last and this @@ -120,8 +123,24 @@ exit_or_logout (list) /* Get return value if present. This means that you can type `logout 5' to a shell, and it returns 5. */ - exit_value = get_exitstat (list); + /* If we're running the exit trap (running_trap == 1, since running_trap + gets set to SIG+1), and we don't have a argument given to `exit' + (list == 0), use the exit status we saved before running the trap + commands (trap_saved_exit_value). */ + exit_value = (running_trap == 1 && list == 0) ? trap_saved_exit_value : get_exitstat (list); + + bash_logout (); + + last_command_exit_value = exit_value; + + /* Exit the program. */ + jump_to_top_level (EXITPROG); + /*NOTREACHED*/ +} +void +bash_logout () +{ /* Run our `~/.bash_logout' file if it exists, and this is a login shell. */ if (login_shell && sourced_logout++ == 0 && subshell_environment == 0) { @@ -130,10 +149,4 @@ exit_or_logout (list) maybe_execute_file (SYS_BASH_LOGOUT, 1); #endif } - - last_command_exit_value = exit_value; - - /* Exit the program. */ - jump_to_top_level (EXITPROG); - /*NOTREACHED*/ } diff --git a/builtins/fc.def b/builtins/fc.def index c300066..93c7ae3 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -1,7 +1,7 @@ This file is fc.def, from which is created fc.c. It implements the builtin "fc" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -25,7 +25,6 @@ $BUILTIN fc $FUNCTION fc_builtin $DEPENDS_ON HISTORY $SHORT_DOC fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd] - fc is used to list or edit and re-execute commands from the history list. FIRST and LAST can be numbers specifying the range, or FIRST can be a string, which means the most recent command beginning with that @@ -54,7 +53,7 @@ $END #endif #include "../bashtypes.h" #include "posixstat.h" -#ifndef _MINIX +#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H) # include <sys/file.h> #endif @@ -66,6 +65,7 @@ $END #include <chartypes.h> #include "../bashansi.h" +#include "../bashintl.h" #include <errno.h> #include "../shell.h" @@ -249,7 +249,7 @@ fc_builtin (list) if (command == NULL) { - builtin_error ("no command found"); + builtin_error (_("no command found")); if (rlist) FREE_RLIST (); @@ -314,7 +314,7 @@ fc_builtin (list) /* We print error messages for line specifications out of range. */ if ((histbeg < 0) || (histend < 0)) { - sh_erange ((char *)NULL, "history specification"); + sh_erange ((char *)NULL, _("history specification")); return (EXECUTION_FAILURE); } @@ -335,7 +335,7 @@ fc_builtin (list) stream = sh_mktmpfp ("bash-fc", MT_USERANDOM|MT_USETMPDIR, &fn); if (stream == 0) { - builtin_error ("cannot open temp file %s", fn ? fn : ""); + builtin_error (_("%s: cannot open temp file: %s"), fn ? fn : "", strerror (errno)); FREE (fn); return (EXECUTION_FAILURE); } diff --git a/builtins/fg_bg.def b/builtins/fg_bg.def index c16d894..ea13bef 100644 --- a/builtins/fg_bg.def +++ b/builtins/fg_bg.def @@ -1,7 +1,7 @@ This file is fg_bg.def, from which is created fg_bg.c. It implements the builtins "bg" and "fg" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -39,6 +39,8 @@ $END # include <unistd.h> #endif +#include "../bashintl.h" + #include "../shell.h" #include "../jobs.h" #include "common.h" @@ -128,7 +130,7 @@ fg_bg (list, foreground) /* Or if jobs[job]->pgrp == shell_pgrp. */ if (IS_JOBCONTROL (job) == 0) { - builtin_error ("job %%%d started without job control", job + 1); + builtin_error (_("job %d started without job control"), job + 1); goto failure; } diff --git a/builtins/getopt.c b/builtins/getopt.c index 60c6188..b223a76 100644 --- a/builtins/getopt.c +++ b/builtins/getopt.c @@ -28,6 +28,7 @@ #include <stdio.h> #include "memalloc.h" +#include "../bashintl.h" #include "../shell.h" #include "getopt.h" @@ -105,8 +106,8 @@ int sh_badopt = 0; ARGV-element, is returned in `sh_optarg'. */ /* 1003.2 specifies the format of this message. */ -#define BADOPT(x) fprintf (stderr, "%s: illegal option -- %c\n", argv[0], x) -#define NEEDARG(x) fprintf (stderr, "%s: option requires an argument -- %c\n", argv[0], x) +#define BADOPT(x) fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], x) +#define NEEDARG(x) fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], x) int sh_getopt (argc, argv, optstring) diff --git a/builtins/getopts.def b/builtins/getopts.def index a2a82ff..eb0a31d 100644 --- a/builtins/getopts.def +++ b/builtins/getopts.def @@ -44,7 +44,7 @@ seen, getopts places the option character found into OPTARG. If a required argument is not found, getopts places a ':' into NAME and sets OPTARG to the option character found. If getopts is not in silent mode, and an invalid option is seen, getopts places '?' into -NAME and unsets OPTARG. If a required option is not found, a '?' +NAME and unsets OPTARG. If a required argument is not found, a '?' is placed in NAME, OPTARG is unset, and a diagnostic message is printed. @@ -245,6 +245,7 @@ dogetopts (argc, argv) if (ret == G_EOF) { + unbind_variable ("OPTARG"); getopts_bind_variable (name, "?"); return (EXECUTION_FAILURE); } diff --git a/builtins/hash.def b/builtins/hash.def index 6e0e347..d311ac9 100644 --- a/builtins/hash.def +++ b/builtins/hash.def @@ -1,7 +1,7 @@ This file is hash.def, from which is created hash.c. It implements the builtin "hash" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -49,6 +49,7 @@ $END #include <errno.h> #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "../builtins.h" @@ -79,7 +80,7 @@ hash_builtin (list) if (hashing_enabled == 0) { - builtin_error ("hashing disabled"); + builtin_error (_("hashing disabled")); return (EXECUTION_FAILURE); } @@ -124,7 +125,7 @@ hash_builtin (list) if (list == 0 && expunge_hash_table == 0) { if (print_hashed_commands (list_portably) == 0) - printf ("%s: hash table empty\n", this_command_name); + printf (_("%s: hash table empty\n"), this_command_name); return (EXECUTION_SUCCESS); } diff --git a/builtins/help.def b/builtins/help.def index 234307b..1935b64 100644 --- a/builtins/help.def +++ b/builtins/help.def @@ -1,7 +1,7 @@ This file is help.def, from which is created help.c. It implements the builtin "help" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -48,6 +48,8 @@ $END #include <filecntl.h> +#include "../bashintl.h" + #include "../shell.h" #include "../builtins.h" #include "../pathexp.h" @@ -102,7 +104,10 @@ help_builtin (list) if (glob_pattern_p (list->word->word)) { - printf ("Shell commands matching keyword%s `", list->next ? "s" : ""); + if (list->next) + printf (_("Shell commands matching keywords `")); + else + printf (_("Shell commands matching keyword `")); print_word_list (list, ", "); printf ("'\n\n"); } @@ -130,7 +135,7 @@ help_builtin (list) if (match_found == 0) { - builtin_error ("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'.", pattern, pattern, pattern); + builtin_error (_("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern); return (EXECUTION_FAILURE); } @@ -156,7 +161,7 @@ show_longdoc (i) fd = open (doc[0], O_RDONLY); if (fd == -1) { - builtin_error ("%s: cannot open: %s", doc[0], strerror (errno)); + builtin_error (_("%s: cannot open: %s"), doc[0], strerror (errno)); return; } zcatfd (fd, 1, doc[0]); @@ -164,7 +169,7 @@ show_longdoc (i) } else for (j = 0; doc[j]; j++) - printf (" %s\n", doc[j]); + printf (" %s\n", _(doc[j])); } static void @@ -174,13 +179,13 @@ show_builtin_command_help () char blurb[36]; printf ( -"These shell commands are defined internally. Type `help' to see this list.\n\ +_("These shell commands are defined internally. Type `help' to see this list.\n\ Type `help name' to find out more about the function `name'.\n\ Use `info bash' to find out more about the shell in general.\n\ Use `man -k' or `info' to find out more about commands not in this list.\n\ \n\ A star (*) next to a name means that the command is disabled.\n\ -\n"); +\n")); for (i = 0; i < num_shell_builtins; i++) { diff --git a/builtins/history.def b/builtins/history.def index 7311705..52b1113 100644 --- a/builtins/history.def +++ b/builtins/history.def @@ -1,7 +1,7 @@ This file is history.def, from which is created history.c. It implements the builtin "history" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -34,20 +34,25 @@ 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. Argument `-n' means to read all history lines not already read -from the history file and append them to the history list. If -FILENAME is given, then that is used as the history file else +from the history file and append them to the history list. + +If FILENAME is given, then that is used as the history file else if $HISTFILE has a value, that is used, else ~/.bash_history. If the -s option is supplied, the non-option ARGs are appended to the history list as a single entry. The -p option means to perform history expansion on each ARG and display the result, without storing anything in the history list. + +If the $HISTTIMEFORMAT variable is set and not null, its value is used +as a format string for strftime(3) to print the time stamp associated +with each displayed history entry. No time stamps are printed otherwise. $END #include <config.h> #if defined (HISTORY) #include "../bashtypes.h" -#ifndef _MINIX +#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H) # include <sys/file.h> #endif #include "posixstat.h" @@ -59,6 +64,7 @@ $END #endif #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "../bashhist.h" @@ -72,6 +78,7 @@ extern int errno; extern int current_command_line_count; +static char *histtime __P((HIST_ENTRY *, const char *)); static void display_history __P((WORD_LIST *)); static int delete_histent __P((int)); static int delete_last_history __P((void)); @@ -91,7 +98,7 @@ int history_builtin (list) WORD_LIST *list; { - int flags, opt, result, old_history_lines; + int flags, opt, result, old_history_lines, obase; char *filename, *delete_arg; intmax_t delete_offset; @@ -138,7 +145,7 @@ history_builtin (list) opt = flags & (AFLAG|RFLAG|WFLAG|NFLAG); if (opt && opt != AFLAG && opt != RFLAG && opt != WFLAG && opt != NFLAG) { - builtin_error ("cannot use more than one of -anrw"); + builtin_error (_("cannot use more than one of -anrw")); return (EXECUTION_FAILURE); } @@ -170,7 +177,7 @@ history_builtin (list) || (delete_offset < history_base) || (delete_offset > (history_base + history_length))) { - sh_erange (delete_arg, "history position"); + sh_erange (delete_arg, _("history position")); return (EXECUTION_FAILURE); } opt = delete_offset; @@ -200,11 +207,23 @@ history_builtin (list) { /* Read all of the lines in the file that we haven't already read. */ old_history_lines = history_lines_in_file; + obase = history_base; + using_history (); result = read_history_range (filename, history_lines_in_file, -1); using_history (); + history_lines_in_file = where_history (); - history_lines_this_session += history_lines_in_file - old_history_lines; + /* The question is whether we reset history_lines_this_session to 0, + losing any history entries we had before we read the new entries + from the history file, or whether we count the new entries we just + read from the file as history lines added during this session. + Right now, we do the latter. This will cause these history entries + to be written to the history file along with any intermediate entries + we add when we do a `history -a', but the alternative is losing + them altogether. */ + history_lines_this_session += history_lines_in_file - old_history_lines + + history_base - obase; } return (result ? EXECUTION_FAILURE : EXECUTION_SUCCESS); @@ -214,6 +233,22 @@ history_builtin (list) #define histline(i) (hlist[(i)]->line) #define histdata(i) (hlist[(i)]->data) +static char * +histtime (hlist, histtimefmt) + HIST_ENTRY *hlist; + const char *histtimefmt; +{ + static char timestr[128]; + time_t t; + + t = history_get_time (hlist); + if (t) + strftime (timestr, sizeof (timestr), histtimefmt, localtime (&t)); + else + strcpy (timestr, "??"); + return timestr; +} + static void display_history (list) WORD_LIST *list; @@ -221,6 +256,7 @@ display_history (list) register int i; intmax_t limit; HIST_ENTRY **hlist; + char *histtimefmt, *timestr; if (list) { @@ -243,11 +279,17 @@ display_history (list) else i = 0; + + histtimefmt = get_string_value ("HISTTIMEFORMAT"); + while (hlist[i]) { QUIT; - printf ("%5d%c %s\n", i + history_base, + + timestr = (histtimefmt && *histtimefmt) ? histtime (hlist[i], histtimefmt) : (char *)NULL; + printf ("%5d%c %s%s\n", i + history_base, histdata(i) ? '*' : ' ', + ((timestr && *timestr) ? timestr : ""), histline(i)); i++; } @@ -263,11 +305,8 @@ delete_histent (i) discard = remove_history (i); if (discard) - { - if (discard->line) - free (discard->line); - free ((char *) discard); - } + free_history_entry (discard); + return 1; } @@ -276,6 +315,7 @@ delete_last_history () { register int i; HIST_ENTRY **hlist, *histent; + int r; hlist = history_list (); if (hlist == NULL) @@ -290,7 +330,12 @@ delete_last_history () if (histent == NULL) return 0; - return (delete_histent (i)); + r = delete_histent (i); + + if (where_history () > history_length) + history_set_pos (history_length); + + return r; } /* Remove the last entry in the history list and add each argument in @@ -342,7 +387,7 @@ expand_and_print_history (list) r = history_expand (list->word->word, &s); if (r < 0) { - builtin_error ("%s: history expansion failed", list->word->word); + builtin_error (_("%s: history expansion failed"), list->word->word); result = EXECUTION_FAILURE; } else diff --git a/builtins/jobs.def b/builtins/jobs.def index 54f50ca..76d1957 100644 --- a/builtins/jobs.def +++ b/builtins/jobs.def @@ -1,7 +1,7 @@ This file is jobs.def, from which is created jobs.c. It implements the builtins "jobs" and "disown" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -46,6 +46,7 @@ $END #endif #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "../jobs.h" @@ -74,9 +75,6 @@ jobs_builtin (list) int form, execute, state, opt, any_failed, job; sigset_t set, oset; - if (job_control == 0 && interactive_shell == 0) - return (EXECUTION_SUCCESS); - execute = any_failed = 0; form = JLIST_STANDARD; state = JSTATE_ANY; @@ -98,7 +96,7 @@ jobs_builtin (list) case 'x': if (form != JLIST_STANDARD) { - builtin_error ("no other options allowed with `-x'"); + builtin_error (_("no other options allowed with `-x'")); return (EXECUTION_FAILURE); } execute++; @@ -163,6 +161,7 @@ execute_list_with_replacements (list) { register WORD_LIST *l; int job, result; + COMMAND *command; /* First do the replacement of job specifications with pids. */ for (l = list; l; l = l->next) @@ -182,21 +181,18 @@ execute_list_with_replacements (list) /* Next make a new simple command and execute it. */ begin_unwind_frame ("jobs_builtin"); - { - COMMAND *command = (COMMAND *)NULL; - - add_unwind_protect (dispose_command, command); - command = make_bare_simple_command (); - command->value.Simple->words = copy_word_list (list); - command->value.Simple->redirects = (REDIRECT *)NULL; - command->flags |= CMD_INHIBIT_EXPANSION; - command->value.Simple->flags |= CMD_INHIBIT_EXPANSION; + command = make_bare_simple_command (); + command->value.Simple->words = copy_word_list (list); + command->value.Simple->redirects = (REDIRECT *)NULL; + command->flags |= CMD_INHIBIT_EXPANSION; + command->value.Simple->flags |= CMD_INHIBIT_EXPANSION; - result = execute_command (command); - } + add_unwind_protect (dispose_command, command); + result = execute_command (command); + dispose_command (command); - run_unwind_frame ("jobs_builtin"); + discard_unwind_frame ("jobs_builtin"); return (result); } #endif /* JOB_CONTROL */ diff --git a/builtins/kill.def b/builtins/kill.def index 96b34fc..d1b9f6d 100644 --- a/builtins/kill.def +++ b/builtins/kill.def @@ -1,7 +1,7 @@ This file is kill.def, from which is created kill.c. It implements the builtin "kill" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -23,7 +23,6 @@ $PRODUCES kill.c $BUILTIN kill $FUNCTION kill_builtin -$DEPENDS_ON JOB_CONTROL $SHORT_DOC kill [-s sigspec | -n signum | -sigspec] [pid | job]... or kill -l [sigspec] Send the processes named by PID (or JOB) the signal SIGSPEC. If SIGSPEC is not present, then SIGTERM is assumed. An argument of `-l' @@ -46,6 +45,7 @@ $END #endif #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "../trap.h" @@ -57,9 +57,10 @@ $END extern int errno; #endif /* !errno */ -#if defined (JOB_CONTROL) extern int posixly_correct; +static void kill_error __P((pid_t, int)); + #if !defined (CONTINUE_AFTER_KILL_ERROR) # define CONTINUE_OR_FAIL return (EXECUTION_FAILURE) #else @@ -73,7 +74,7 @@ int kill_builtin (list) WORD_LIST *list; { - int sig, any_succeeded, listing, saw_signal; + int sig, any_succeeded, listing, saw_signal, dflags; char *sigspec, *word; pid_t pid; intmax_t pid_value; @@ -88,6 +89,7 @@ kill_builtin (list) sig = SIGTERM; sigspec = "TERM"; + dflags = DSIG_NOCASE | ((posixly_correct == 0) ? DSIG_SIGPREFIX : 0); /* Process options. */ while (list) { @@ -107,7 +109,7 @@ kill_builtin (list) if (sigspec[0] == '0' && sigspec[1] == '\0') sig = 0; else - sig = decode_signal (sigspec); + sig = decode_signal (sigspec, dflags); list = list->next; } else @@ -132,7 +134,7 @@ kill_builtin (list) else if ((*word == '-') && !saw_signal) { sigspec = word + 1; - sig = decode_signal (sigspec); + sig = decode_signal (sigspec, dflags); saw_signal++; list = list->next; } @@ -169,16 +171,23 @@ kill_builtin (list) pid = (pid_t) pid_value; if ((pid < -1 ? kill_pid (-pid, sig, 1) : kill_pid (pid, sig, 0)) < 0) - goto signal_error; + { + if (errno == EINVAL) + sh_invalidsig (sigspec); + else + kill_error (pid, errno); + CONTINUE_OR_FAIL; + } else any_succeeded++; } +#if defined (JOB_CONTROL) else if (*list->word->word && *list->word->word != '%') { - builtin_error ("%s: no such pid", list->word->word); + builtin_error (_("%s: arguments must be process or job IDs"), list->word->word); CONTINUE_OR_FAIL; } - else if (*word && (interactive || job_control)) + else if (*word) /* Posix.2 says you can kill without job control active (4.32.4) */ { /* Must be a job spec. Check it out. */ int job; @@ -205,16 +214,16 @@ kill_builtin (list) if (kill_pid (pid, sig, 1) < 0) { - signal_error: if (errno == EINVAL) sh_invalidsig (sigspec); else - builtin_error ("(%ld) - %s", (long)pid, strerror (errno)); + kill_error (pid, errno); CONTINUE_OR_FAIL; } else any_succeeded++; } +#endif /* !JOB_CONTROL */ else { sh_badpid (list->word->word); @@ -226,4 +235,16 @@ kill_builtin (list) return (any_succeeded ? EXECUTION_SUCCESS : EXECUTION_FAILURE); } -#endif /* JOB_CONTROL */ + +static void +kill_error (pid, e) + pid_t pid; + int e; +{ + char *x; + + x = strerror (e); + if (x == 0) + x = _("Unknown error"); + builtin_error ("(%ld) - %s", (long)pid, x); +} diff --git a/builtins/let.def b/builtins/let.def index 7c9341e..ab43a45 100644 --- a/builtins/let.def +++ b/builtins/let.def @@ -45,7 +45,7 @@ The levels are listed in order of decreasing precedence. && logical AND || logical OR expr ? expr : expr - conditional expression + conditional operator =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |= assignment @@ -72,6 +72,8 @@ $END # include <unistd.h> #endif +#include "../bashintl.h" + #include "../shell.h" #include "common.h" @@ -89,7 +91,7 @@ let_builtin (list) if (list == 0) { - builtin_error ("expression expected"); + builtin_error (_("expression expected")); return (EXECUTION_FAILURE); } @@ -114,7 +116,7 @@ exp_builtin (list) if (list == 0) { - builtin_error ("expression expected"); + builtin_error (_("expression expected")); return (EXECUTION_FAILURE); } diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c index c911f86..278755b 100644 --- a/builtins/mkbuiltins.c +++ b/builtins/mkbuiltins.c @@ -29,8 +29,10 @@ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #endif #ifndef _MINIX -#include "../bashtypes.h" -#include <sys/file.h> +# include "../bashtypes.h" +# if defined (HAVE_SYS_FILE_H) +# include <sys/file.h> +# endif #endif #include "posixstat.h" @@ -1127,6 +1129,9 @@ write_file_headers (structfile, externfile) fprintf (structfile, "#include \"%s\"\n", extern_filename ? extern_filename : "builtext.h"); + + fprintf (structfile, "#include \"bashintl.h\"\n"); + fprintf (structfile, "\nstruct builtin static_shell_builtins[] = {\n"); } @@ -1367,8 +1372,9 @@ write_documentation (stream, documentation, indentation, flags) continue; } + /* prefix with N_( for gettext */ if (string_array) - fprintf (stream, " \""); + fprintf (stream, " N_(\""); if (indentation) for (j = 0; j < indentation; j++) @@ -1390,7 +1396,8 @@ write_documentation (stream, documentation, indentation, flags) } } - fprintf (stream, "\",\n"); + /* closing right paren for gettext */ + fprintf (stream, "\"),\n"); } else if (texinfo) { diff --git a/builtins/printf.def b/builtins/printf.def index 8821ecb..9b377a9 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -1,7 +1,7 @@ This file is printf.def, from which is created printf.c. It implements the builtin "printf" in Bash. -Copyright (C) 1997-2002 Free Software Foundation, Inc. +Copyright (C) 1997-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -55,6 +55,7 @@ $END #endif #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "stdc.h" @@ -105,7 +106,7 @@ extern int errno; static void printf_erange __P((char *)); static void printstr __P((char *, char *, int, int, int)); -static int tescape __P((char *, int, char *, int *)); +static int tescape __P((char *, char *, int *)); static char *bexpand __P((char *, int, int *, int *)); static char *mklong __P((char *, char *, size_t)); static int getchr __P((void)); @@ -114,7 +115,7 @@ static int getint __P((void)); static intmax_t getintmax __P((void)); static uintmax_t getuintmax __P((void)); -#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD +#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN) typedef long double floatmax_t; # define FLOATMAX_CONV "L" # define strtofltmax strtold @@ -182,13 +183,12 @@ printf_builtin (list) precision = fieldwidth = 0; have_fieldwidth = have_precision = 0; - if (*fmt == '\\') { fmt++; - /* A NULL fourth argument to tescape means to not do special - processing for \c. */ - fmt += tescape (fmt, 1, &nextch, (int *)NULL); + /* A NULL third argument to tescape means to bypass the + special processing for arguments to %b. */ + fmt += tescape (fmt, &nextch, (int *)NULL); putchar (nextch); fmt--; /* for loop will increment it for us again */ continue; @@ -246,7 +246,7 @@ printf_builtin (list) if (*fmt == 0) { - builtin_error ("`%s': missing format character", start); + builtin_error (_("`%s': missing format character"), start); PRETURN (EXECUTION_FAILURE); } @@ -405,7 +405,7 @@ printf_builtin (list) /* We don't output unrecognized format characters; we print an error message and return a failure exit status. */ default: - builtin_error ("`%c': invalid format character", convch); + builtin_error (_("`%c': invalid format character"), convch); PRETURN (EXECUTION_FAILURE); } @@ -531,6 +531,7 @@ printstr (fmt, string, len, fieldwidth, precision) /* Convert STRING by expanding the escape sequences specified by the POSIX standard for printf's `%b' format string. If SAWC is non-null, + perform the processing appropriate for %b arguments. In particular, recognize `\c' and use that as a string terminator. If we see \c, set *SAWC to 1 before returning. LEN is the length of STRING. */ @@ -540,11 +541,10 @@ printstr (fmt, string, len, fieldwidth, precision) 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. */ + sequence; we also bypass the other processing specific to %b arguments. */ static int -tescape (estart, trans_squote, cp, sawc) +tescape (estart, cp, sawc) char *estart; - int trans_squote; char *cp; int *sawc; { @@ -576,14 +576,13 @@ tescape (estart, trans_squote, cp, sawc) case 'v': *cp = '\v'; break; - /* %b octal constants are `\0' followed by one, two, or three - octal digits... */ - case '0': - /* 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'), evalue = c - '0'; ISOCTAL (*p) && temp--; p++) + /* The octal escape sequences are `\0' followed by up to three octal + digits (if SAWC), or `\' followed by up to three octal digits (if + !SAWC). As an extension, we allow the latter form even if SAWC. */ + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + evalue = OCTVALUE (c); + for (temp = 2 + (!evalue && !!sawc); ISOCTAL (*p) && temp--; p++) evalue = (evalue * 8) + OCTVALUE (*p); *cp = evalue & 0xFF; break; @@ -591,11 +590,15 @@ tescape (estart, trans_squote, cp, sawc) /* And, as another extension, we allow \xNNN, where each N is a hex digit. */ case 'x': +#if 0 + for (evalue = 0; ISXDIGIT ((unsigned char)*p); p++) +#else for (temp = 2, evalue = 0; ISXDIGIT ((unsigned char)*p) && temp--; p++) +#endif evalue = (evalue * 16) + HEXVALUE (*p); - if (temp == 2) + if (p == estart + 1) { - builtin_error ("missing hex digit for \\x"); + builtin_error (_("missing hex digit for \\x")); *cp = '\\'; return 0; } @@ -606,8 +609,11 @@ tescape (estart, trans_squote, cp, sawc) *cp = c; break; - case '\'': /* TRANS_SQUOTE != 0 means \' -> ' */ - if (trans_squote) + /* SAWC == 0 means that \', \", and \? are recognized as escape + sequences, though the only processing performed is backslash + removal. */ + case '\'': case '"': case '?': + if (!sawc) *cp = c; else { @@ -657,7 +663,7 @@ bexpand (string, len, sawc, lenp) continue; } temp = 0; - s += tescape (s, 0, &c, &temp); + s += tescape (s, &c, &temp); if (temp) { if (sawc) diff --git a/builtins/pushd.def b/builtins/pushd.def index 2bb72ff..83b69c4 100644 --- a/builtins/pushd.def +++ b/builtins/pushd.def @@ -1,7 +1,7 @@ This file is pushd.def, from which is created pushd.c. It implements the builtins "pushd", "popd", and "dirs" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -107,6 +107,7 @@ $END #endif #include "../bashansi.h" +#include "../bashintl.h" #include <errno.h> @@ -164,7 +165,7 @@ pushd_builtin (list) { if (directory_list_offset == 0) { - builtin_error ("no other directory"); + builtin_error (_("no other directory")); return (EXECUTION_FAILURE); } @@ -431,7 +432,7 @@ dirs_builtin (list) { temp = get_working_directory ("dirs"); if (temp == 0) - temp = savestring ("<no current directory>"); + temp = savestring (_("<no current directory>")); if (vflag & 2) printf ("%2d %s", 0, DIRSTACK_FORMAT (temp)); else @@ -648,66 +649,66 @@ get_directory_stack () #ifdef LOADABLE_BUILTIN static char *dirs_doc[] = { - "Display the list of currently remembered directories. Directories", - "find their way onto the list with the `pushd' command; you can get", - "back up through the list with the `popd' command.", - "", - "The -l flag specifies that `dirs' should not print shorthand versions", - "of directories which are relative to your home directory. This means", - "that `~/bin' might be displayed as `/homes/bfox/bin'. The -v flag", - "causes `dirs' to print the directory stack with one entry per line,", - "prepending the directory name with its position in the stack. The -p", - "flag does the same thing, but the stack position is not prepended.", - "The -c flag clears the directory stack by deleting all of the elements.", - "", - "+N displays the Nth entry counting from the left of the list shown by", - " dirs when invoked without options, starting with zero.", - "", - "-N displays the Nth entry counting from the right of the list shown by", - " dirs when invoked without options, starting with zero.", + N_("Display the list of currently remembered directories. Directories"), + N_("find their way onto the list with the `pushd' command; you can get"), + N_("back up through the list with the `popd' command."), + N_(""), + N_("The -l flag specifies that `dirs' should not print shorthand versions"), + N_("of directories which are relative to your home directory. This means"), + N_("that `~/bin' might be displayed as `/homes/bfox/bin'. The -v flag"), + N_("causes `dirs' to print the directory stack with one entry per line,"), + N_("prepending the directory name with its position in the stack. The -p"), + N_("flag does the same thing, but the stack position is not prepended."), + N_("The -c flag clears the directory stack by deleting all of the elements."), + N_(""), + N_("+N displays the Nth entry counting from the left of the list shown by"), + N_(" dirs when invoked without options, starting with zero."), + N_(""), + N_("-N displays the Nth entry counting from the right of the list shown by"), + N_(" dirs when invoked without options, starting with zero."), (char *)NULL }; static char *pushd_doc[] = { - "Adds a directory to the top of the directory stack, or rotates", - "the stack, making the new top of the stack the current working", - "directory. With no arguments, exchanges the top two directories.", - "", - "+N Rotates the stack so that the Nth directory (counting", - " from the left of the list shown by `dirs', starting with", - " zero) is at the top.", - "", - "-N Rotates the stack so that the Nth directory (counting", - " from the right of the list shown by `dirs', starting with", - " zero) is at the top.", - "", - "-n suppress the normal change of directory when adding directories", - " to the stack, so only the stack is manipulated.", - "", - "dir adds DIR to the directory stack at the top, making it the", - " new current working directory.", - "", - "You can see the directory stack with the `dirs' command.", + N_("Adds a directory to the top of the directory stack, or rotates"), + N_("the stack, making the new top of the stack the current working"), + N_("directory. With no arguments, exchanges the top two directories."), + N_(""), + N_("+N Rotates the stack so that the Nth directory (counting"), + N_(" from the left of the list shown by `dirs', starting with"), + N_(" zero) is at the top."), + N_(""), + N_("-N Rotates the stack so that the Nth directory (counting"), + N_(" from the right of the list shown by `dirs', starting with"), + N_(" zero) is at the top."), + N_(""), + N_("-n suppress the normal change of directory when adding directories"), + N_(" to the stack, so only the stack is manipulated."), + N_(""), + N_("dir adds DIR to the directory stack at the top, making it the"), + N_(" new current working directory."), + N_(""), + N_("You can see the directory stack with the `dirs' command."), (char *)NULL }; static char *popd_doc[] = { - "Removes entries from the directory stack. With no arguments,", - "removes the top directory from the stack, and cd's to the new", - "top directory.", - "", - "+N removes the Nth entry counting from the left of the list", - " shown by `dirs', starting with zero. For example: `popd +0'", - " removes the first directory, `popd +1' the second.", - "", - "-N removes the Nth entry counting from the right of the list", - " shown by `dirs', starting with zero. For example: `popd -0'", - " removes the last directory, `popd -1' the next to last.", - "", - "-n suppress the normal change of directory when removing directories", - " from the stack, so only the stack is manipulated.", - "", - "You can see the directory stack with the `dirs' command.", + N_("Removes entries from the directory stack. With no arguments,"), + N_("removes the top directory from the stack, and cd's to the new"), + N_("top directory."), + N_(""), + N_("+N removes the Nth entry counting from the left of the list"), + N_(" shown by `dirs', starting with zero. For example: `popd +0'"), + N_(" removes the first directory, `popd +1' the second."), + N_(""), + N_("-N removes the Nth entry counting from the right of the list"), + N_(" shown by `dirs', starting with zero. For example: `popd -0'"), + N_(" removes the last directory, `popd -1' the next to last."), + N_(""), + N_("-n suppress the normal change of directory when removing directories"), + N_(" from the stack, so only the stack is manipulated."), + N_(""), + N_("You can see the directory stack with the `dirs' command."), (char *)NULL }; diff --git a/builtins/read.def b/builtins/read.def index 46a0407..cdac9c4 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -1,7 +1,7 @@ This file is read.def, from which is created read.c. It implements the builtin "read" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -66,6 +66,8 @@ $END # include <io.h> #endif +#include "../bashintl.h" + #include "../shell.h" #include "common.h" #include "bashgetopt.h" @@ -202,7 +204,7 @@ read_builtin (list) code = legal_number (list_optarg, &intval); if (code == 0 || intval < 0 || intval != (unsigned int)intval) { - builtin_error ("%s: invalid timeout specification", list_optarg); + builtin_error (_("%s: invalid timeout specification"), list_optarg); return (EXECUTION_FAILURE); } else @@ -225,14 +227,14 @@ read_builtin (list) code = legal_number (list_optarg, &intval); if (code == 0 || intval < 0 || intval != (int)intval) { - builtin_error ("%s: invalid file descriptor specification", list_optarg); + builtin_error (_("%s: invalid file descriptor specification"), list_optarg); return (EXECUTION_FAILURE); } else fd = intval; if (sh_validfd (fd) == 0) { - builtin_error ("%d: invalid file descriptor: %s", fd, strerror (errno)); + builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno)); return (EXECUTION_FAILURE); } break; @@ -458,7 +460,7 @@ read_builtin (list) #if 1 if (retval < 0) { - builtin_error ("read error: %d: %s", fd, strerror (errno)); + builtin_error (_("read error: %d: %s"), fd, strerror (errno)); return (EXECUTION_FAILURE); } #endif @@ -497,6 +499,13 @@ read_builtin (list) an assign them to `arrayname' in turn. */ if (arrayname) { + if (legal_identifier (arrayname) == 0) + { + sh_invalidid (arrayname); + xfree (input_string); + return (EXECUTION_FAILURE); + } + var = find_or_make_array_variable (arrayname, 1); if (var == 0) return EXECUTION_FAILURE; /* readonly or noassign */ @@ -505,6 +514,7 @@ read_builtin (list) alist = list_string (input_string, ifs_chars, 0); if (alist) { + word_list_remove_quoted_nulls (alist); assign_array_var_from_word_list (var, alist); dispose_words (alist); } diff --git a/builtins/return.def b/builtins/return.def index 84a90a3..23389c0 100644 --- a/builtins/return.def +++ b/builtins/return.def @@ -1,7 +1,7 @@ This file is return.def, from which is created return.c. It implements the builtin "return" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -38,6 +38,8 @@ $END # include <unistd.h> #endif +#include "../bashintl.h" + #include "../shell.h" #include "common.h" @@ -58,7 +60,7 @@ return_builtin (list) longjmp (return_catch, 1); else { - builtin_error ("can only `return' from a function or sourced script"); + builtin_error (_("can only `return' from a function or sourced script")); return (EXECUTION_FAILURE); } } diff --git a/builtins/set.def b/builtins/set.def index 10aaf5f..02cc16a 100644 --- a/builtins/set.def +++ b/builtins/set.def @@ -33,6 +33,7 @@ $PRODUCES set.c #include <stdio.h> #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "../flags.h" @@ -77,6 +78,8 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...] emacs use an emacs-style line editing interface #endif /* READLINE */ errexit same as -e + errtrace same as -E + functrace same as -T hashall same as -h #if defined (BANG_HISTORY) histexpand same as -H @@ -97,6 +100,9 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...] nounset same as -u onecmd same as -t physical same as -P + pipefail the return value of a pipeline is the status of + the last command to exit with a non-zero status, + or zero if no command exited with a non-zero status posix change the behavior of bash where the default operation differs from the 1003.2 standard to match the standard @@ -119,12 +125,14 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...] #endif /* BRACE_EXPANSION */ -C If set, disallow existing regular files to be overwritten by redirection of output. + -E If set, the ERR trap is inherited by shell functions. #if defined (BANG_HISTORY) -H Enable ! style history substitution. This flag is on by default. #endif /* BANG_HISTORY */ -P If set, do not follow symbolic links when executing commands such as cd which change the current directory. + -T If set, the DEBUG trap is inherited by shell functions. Using + rather than - causes these flags to be turned off. The flags can also be used upon invocation of the shell. The current @@ -172,6 +180,8 @@ struct { { "emacs", '\0', (int *)NULL, set_edit_mode, get_edit_mode }, #endif { "errexit", 'e', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "errtrace", 'E', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "functrace", 'T', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "hashall", 'h', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, #if defined (BANG_HISTORY) { "histexpand", 'H', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, @@ -195,6 +205,7 @@ struct { { "nounset", 'u', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "onecmd", 't', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "physical", 'P', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "pipefail", '\0', &pipefail_opt, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "posix", '\0', &posixly_correct, set_posix_mode, (setopt_get_func_t *)NULL }, { "privileged", 'p', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, { "verbose", 'v', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, @@ -729,7 +740,7 @@ unset_builtin (list) if (unset_function && unset_variable) { - builtin_error ("cannot simultaneously unset a function and a variable"); + builtin_error (_("cannot simultaneously unset a function and a variable")); return (EXECUTION_FAILURE); } @@ -766,14 +777,14 @@ unset_builtin (list) if (var && !unset_function && non_unsettable_p (var)) { - builtin_error ("%s: cannot unset", name); + builtin_error (_("%s: cannot unset"), name); NEXT_VARIABLE (); } /* Posix.2 says that unsetting readonly variables is an error. */ if (var && readonly_p (var)) { - builtin_error ("%s: cannot unset: readonly %s", + builtin_error (_("%s: cannot unset: readonly %s"), name, unset_function ? "function" : "variable"); NEXT_VARIABLE (); } @@ -784,7 +795,7 @@ unset_builtin (list) { if (array_p (var) == 0) { - builtin_error ("%s: not an array variable", name); + builtin_error (_("%s: not an array variable"), name); NEXT_VARIABLE (); } else diff --git a/builtins/setattr.def b/builtins/setattr.def index 8465e7d..d211dbc 100644 --- a/builtins/setattr.def +++ b/builtins/setattr.def @@ -1,7 +1,7 @@ This file is setattr.def, from which is created setattr.c. It implements the builtins "export" and "readonly", in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -32,6 +32,7 @@ $PRODUCES setattr.c #include <stdio.h> #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "common.h" @@ -75,13 +76,12 @@ export_builtin (list) $BUILTIN readonly $FUNCTION readonly_builtin -$SHORT_DOC readonly [-anf] [name[=value] ...] or readonly -p +$SHORT_DOC readonly [-af] [name[=value] ...] or readonly -p The given NAMEs are marked readonly and the values of these NAMEs may not be changed by subsequent assignment. If the -f option is given, then functions corresponding to the NAMEs are so marked. If no arguments are given, or if `-p' is given, a list of all readonly names -is printed. An argument of `-n' says to remove the readonly property -from subsequent NAMEs. The `-a' option means to treat each NAME as +is printed. The `-a' option means to treat each NAME as an array variable. An argument of `--' disables further option processing. $END @@ -103,7 +103,7 @@ readonly_builtin (list) /* For each variable name in LIST, make that variable have the specified ATTRIBUTE. An arg of `-n' says to remove the attribute from the the - remaining names in LIST. */ + remaining names in LIST (doesn't work for readonly). */ int set_or_show_attributes (list, attribute, nodefs) register WORD_LIST *list; @@ -162,7 +162,7 @@ set_or_show_attributes (list, attribute, nodefs) var = find_function (name); if (var == 0) { - builtin_error ("%s: not a function", name); + builtin_error (_("%s: not a function"), name); any_failed++; } else @@ -173,7 +173,7 @@ set_or_show_attributes (list, attribute, nodefs) } /* xxx [-np] name[=value] */ - assign = assignment (name); + assign = assignment (name, 0); if (assign) name[assign] = '\0'; diff --git a/builtins/shift.def b/builtins/shift.def index dbff062..e20b4d5 100644 --- a/builtins/shift.def +++ b/builtins/shift.def @@ -1,7 +1,7 @@ This file is shift.def, from which is created shift.c. It implements the builtin "shift" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -31,6 +31,7 @@ $PRODUCES shift.c #endif #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "common.h" @@ -62,13 +63,13 @@ shift_builtin (list) return (EXECUTION_SUCCESS); else if (times < 0) { - sh_erange (list->word->word, "shift count"); + sh_erange (list ? list->word->word : NULL, _("shift count")); return (EXECUTION_FAILURE); } else if (times > number_of_args ()) { if (print_shift_error) - sh_erange (list->word->word, "shift count"); + sh_erange (list ? list->word->word : NULL, _("shift count")); return (EXECUTION_FAILURE); } diff --git a/builtins/shopt.def b/builtins/shopt.def index ae15330..ad432e0 100644 --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -1,7 +1,7 @@ This file is shopt.def, from which is created shopt.c. It implements the Bash `shopt' builtin. -Copyright (C) 1994-2002 Free Software Foundation, Inc. +Copyright (C) 1994-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -45,6 +45,8 @@ $END #include <stdio.h> +#include "../bashintl.h" + #include "../shell.h" #include "../flags.h" #include "common.h" @@ -55,15 +57,17 @@ $END #define OPTFMT "%-15s\t%s\n" -extern int allow_null_glob_expansion, glob_dot_filenames; +extern int allow_null_glob_expansion, fail_glob_expansion, glob_dot_filenames; extern int cdable_vars, mail_warning, source_uses_path; extern int no_exit_on_failed_exec, print_shift_error; extern int check_hashed_filenames, promptvars; extern int cdspelling, expand_aliases; +extern int extended_quote; extern int check_window_size; extern int glob_ignore_case; extern int hup_on_exit; extern int xpg_echo; +extern int gnu_error_format; #if defined (EXTENDED_GLOB) extern int extended_glob; @@ -77,6 +81,7 @@ extern int force_append_history; #if defined (READLINE) extern int hist_verify, history_reediting, perform_hostname_completion; extern int no_empty_command_completion; +extern int force_fignore; extern int enable_hostname_completion __P((int)); #endif @@ -88,9 +93,13 @@ extern int prog_completion_enabled; extern char *shell_name; #endif +#if defined (DEBUGGER) +extern int debugging_mode; +#endif + static void shopt_error __P((char *)); -static int set_interactive_comments __P((int)); +static int set_shellopts_after_change __P((int)); #if defined (RESTRICTED_SHELL) static int set_restricted_shell __P((int)); @@ -115,10 +124,17 @@ static struct { { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL }, { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL }, { "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL }, +#if defined (DEBUGGER) + { "extdebug", &debugging_mode, (shopt_set_func_t *)NULL }, +#endif #if defined (EXTENDED_GLOB) { "extglob", &extended_glob, (shopt_set_func_t *)NULL }, #endif + { "extquote", &extended_quote, (shopt_set_func_t *)NULL }, + { "failglob", &fail_glob_expansion, (shopt_set_func_t *)NULL }, #if defined (READLINE) + { "force_fignore", &force_fignore, (shopt_set_func_t *)NULL }, + { "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL }, { "histreedit", &history_reediting, (shopt_set_func_t *)NULL }, #endif #if defined (HISTORY) @@ -129,7 +145,7 @@ static struct { { "hostcomplete", &perform_hostname_completion, enable_hostname_completion }, #endif { "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL }, - { "interactive_comments", &interactive_comments, set_interactive_comments }, + { "interactive_comments", &interactive_comments, set_shellopts_after_change }, #if defined (HISTORY) { "lithist", &literal_history, (shopt_set_func_t *)NULL }, #endif @@ -207,7 +223,7 @@ shopt_builtin (list) if ((flags & (SFLAG|UFLAG)) == (SFLAG|UFLAG)) { - builtin_error ("cannot set and unset shell options simultaneously"); + builtin_error (_("cannot set and unset shell options simultaneously")); return (EXECUTION_FAILURE); } @@ -272,7 +288,7 @@ static void shopt_error (s) char *s; { - builtin_error ("%s: invalid shell option name", s); + builtin_error (_("%s: invalid shell option name"), s); } static int @@ -435,7 +451,7 @@ set_shopt_o_options (mode, list, quiet) /* If we set or unset interactive_comments with shopt, make sure the change is reflected in $SHELLOPTS. */ static int -set_interactive_comments (mode) +set_shellopts_after_change (mode) int mode; { set_shellopts (); diff --git a/builtins/source.def b/builtins/source.def index ffb23f0..f9f812f 100644 --- a/builtins/source.def +++ b/builtins/source.def @@ -1,7 +1,7 @@ This file is source.def, from which is created source.c. It implements the builtins "." and "source" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -23,16 +23,20 @@ $PRODUCES source.c $BUILTIN source $FUNCTION source_builtin -$SHORT_DOC source filename +$SHORT_DOC source filename [arguments] Read and execute commands from FILENAME and return. The pathnames -in $PATH are used to find the directory containing FILENAME. +in $PATH are used to find the directory containing FILENAME. If any +ARGUMENTS are supplied, they become the positional parameters when +FILENAME is executed. $END $BUILTIN . $DOCNAME dot $FUNCTION source_builtin -$SHORT_DOC . filename +$SHORT_DOC . filename [arguments] Read and execute commands from FILENAME and return. The pathnames -in $PATH are used to find the directory containing FILENAME. +in $PATH are used to find the directory containing FILENAME. If any +ARGUMENTS are supplied, they become the positional parameters when +FILENAME is executed. $END /* source.c - Implements the `.' and `source' builtins. */ @@ -41,7 +45,7 @@ $END #include "../bashtypes.h" #include "posixstat.h" #include "filecntl.h" -#ifndef _MINIX +#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H) # include <sys/file.h> #endif #include <errno.h> @@ -51,11 +55,14 @@ $END #endif #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" +#include "../flags.h" #include "../findcmd.h" #include "common.h" #include "bashgetopt.h" +#include "../trap.h" #if !defined (errno) extern int errno; @@ -85,6 +92,8 @@ maybe_pop_dollar_vars () dispose_saved_dollar_vars (); else pop_dollar_vars (); + if (debugging_mode) + pop_args (); /* restore BASH_ARGC and BASH_ARGV */ set_dollar_vars_unchanged (); } @@ -97,7 +106,7 @@ source_builtin (list) WORD_LIST *list; { int result; - char *filename; + char *filename, *debug_trap; if (no_options (list)) return (EX_USAGE); @@ -105,7 +114,7 @@ source_builtin (list) if (list == 0) { - builtin_error ("filename argument required"); + builtin_error (_("filename argument required")); builtin_usage (); return (EX_USAGE); } @@ -125,7 +134,7 @@ source_builtin (list) { if (source_searches_cwd == 0) { - builtin_error ("%s: file not found", list->word->word); + builtin_error (_("%s: file not found"), list->word->word); return (EXECUTION_FAILURE); } else @@ -140,10 +149,24 @@ source_builtin (list) push_dollar_vars (); add_unwind_protect ((Function *)maybe_pop_dollar_vars, (char *)NULL); remember_args (list->next, 1); + if (debugging_mode) + push_args (list->next); /* Update BASH_ARGV and BASH_ARGC */ } set_dollar_vars_unchanged (); - result = source_file (filename); + /* Don't inherit the DEBUG trap unless function_trace_mode (overloaded) + is set. XXX - should sourced files inherit the RETURN trap? Functions + don't. */ + debug_trap = TRAP_STRING (DEBUG_TRAP); + if (debug_trap && function_trace_mode == 0) + { + debug_trap = savestring (debug_trap); + add_unwind_protect (xfree, debug_trap); + add_unwind_protect (set_debug_trap, debug_trap); + restore_default_signal (DEBUG_TRAP); + } + + result = source_file (filename, (list && list->next)); run_unwind_frame ("source"); diff --git a/builtins/suspend.def b/builtins/suspend.def index 43391c0..d616d77 100644 --- a/builtins/suspend.def +++ b/builtins/suspend.def @@ -1,7 +1,7 @@ This file is suspend.def, from which is created suspend.c. It implements the builtin "suspend" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -42,6 +42,7 @@ $END #include "../bashtypes.h" #include <signal.h> +#include "../bashintl.h" #include "../shell.h" #include "../jobs.h" #include "common.h" @@ -89,7 +90,7 @@ suspend_builtin (list) if (job_control == 0) { - sh_nojobs ("cannot suspend"); + sh_nojobs (_("cannot suspend")); return (EXECUTION_FAILURE); } @@ -99,11 +100,14 @@ suspend_builtin (list) if (login_shell) { - builtin_error ("cannot suspend a login shell"); + builtin_error (_("cannot suspend a login shell")); return (EXECUTION_FAILURE); } } + /* XXX - should we put ourselves back into the original pgrp now? If so, + call end_job_control() here and do the right thing in suspend_continue + (that is, call restart_job_control()). */ old_cont = (SigHandler *)set_signal_handler (SIGCONT, suspend_continue); #if 0 old_stop = (SigHandler *)set_signal_handler (SIGSTOP, SIG_DFL); diff --git a/builtins/trap.def b/builtins/trap.def index af9e6d6..9dd746f 100644 --- a/builtins/trap.def +++ b/builtins/trap.def @@ -1,7 +1,7 @@ This file is trap.def, from which is created trap.c. It implements the builtin "trap" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -23,20 +23,21 @@ $PRODUCES trap.c $BUILTIN trap $FUNCTION trap_builtin -$SHORT_DOC trap [arg] [signal_spec ...] or trap -l +$SHORT_DOC trap [-lp] [[arg] signal_spec ...] The command ARG is to be read and executed when the shell receives -signal(s) SIGNAL_SPEC. If ARG is absent all specified signals are -reset to their original values. If ARG is the null string each -SIGNAL_SPEC is ignored by the shell and by the commands it invokes. -If a SIGNAL_SPEC is EXIT (0) the command ARG is executed on exit from -the shell. If a SIGNAL_SPEC is DEBUG, ARG is executed after every -command. If ARG is `-p' then the trap commands associated with -each SIGNAL_SPEC are displayed. If no arguments are supplied or if -only `-p' is given, trap prints the list of commands associated with -each signal number. Each SIGNAL_SPEC is either a signal name in <signal.h> -or a signal number. `trap -l' prints a list of signal names and their -corresponding numbers. Note that a signal can be sent to the shell -with "kill -signal $$". +signal(s) SIGNAL_SPEC. If ARG is absent (and a single SIGNAL_SPEC +is supplied) or `-', each specified signal is reset to its original +value. If ARG is the null string each SIGNAL_SPEC is ignored by the +shell and by the commands it invokes. If a SIGNAL_SPEC is EXIT (0) +the command ARG is executed on exit from the shell. If a SIGNAL_SPEC +is DEBUG, ARG is executed after every simple command. If the`-p' option +is supplied then the trap commands associated with each SIGNAL_SPEC are +displayed. If no arguments are supplied or if only `-p' is given, trap +prints the list of commands associated with each signal. Each SIGNAL_SPEC +is either a signal name in <signal.h> or a signal number. Signal names +are case insensitive and the SIG prefix is optional. `trap -l' prints +a list of signal names and their corresponding numbers. Note that a +signal can be sent to the shell with "kill -signal $$". $END #include <config.h> @@ -108,6 +109,8 @@ trap_builtin (list) } list = loptend; + opt = DSIG_NOCASE|DSIG_SIGPREFIX; /* flags for decode_signal */ + if (list_signal_names) return (display_signal_list ((WORD_LIST *)NULL, 1)); else if (display || list == 0) @@ -119,13 +122,22 @@ trap_builtin (list) operation = SET; first_arg = list->word->word; - if (first_arg && *first_arg && (*first_arg != '-' || first_arg[1]) && - signal_object_p (first_arg)) + /* When in posix mode, the historical behavior of looking for a + missing first argument is disabled. To revert to the original + signal handling disposition, use `-' as the first argument. */ + if (posixly_correct == 0 && first_arg && *first_arg && + (*first_arg != '-' || first_arg[1]) && + signal_object_p (first_arg, opt) && list->next == 0) operation = REVERT; else { list = list->next; - if (*first_arg == '\0') + if (list == 0) + { + builtin_usage (); + return (EX_USAGE); + } + else if (*first_arg == '\0') operation = IGNORE; else if (first_arg[0] == '-' && !first_arg[1]) operation = REVERT; @@ -133,7 +145,7 @@ trap_builtin (list) while (list) { - sig = decode_signal (list->word->word); + sig = decode_signal (list->word->word, opt); if (sig == NO_SIG) { @@ -235,7 +247,7 @@ display_traps (list) for (result = EXECUTION_SUCCESS; list; list = list->next) { - i = decode_signal (list->word->word); + i = decode_signal (list->word->word, DSIG_NOCASE|DSIG_SIGPREFIX); if (i == NO_SIG) { sh_invalidsig (list->word->word); diff --git a/builtins/type.def b/builtins/type.def index 2d9d2a5..7abcedf 100644 --- a/builtins/type.def +++ b/builtins/type.def @@ -58,6 +58,7 @@ $END #include <stdio.h> #include "../bashansi.h" +#include "../bashintl.h" #include "../shell.h" #include "../findcmd.h" @@ -73,6 +74,7 @@ $END extern int find_reserved_word __P((char *)); extern char *this_command_name; +extern int expand_aliases; /* 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 @@ -221,12 +223,12 @@ describe_command (command, dflags) #if defined (ALIAS) /* Command is an alias? */ - if (((dflags & CDESC_FORCE_PATH) == 0) && (alias = find_alias (command))) + if (((dflags & CDESC_FORCE_PATH) == 0) && expand_aliases && (alias = find_alias (command))) { if (dflags & CDESC_TYPE) puts ("alias"); else if (dflags & CDESC_SHORTDESC) - printf ("%s is aliased to `%s'\n", command, alias->value); + printf (_("%s is aliased to `%s'\n"), command, alias->value); else if (dflags & CDESC_REUSABLE) { x = sh_single_quote (alias->value); @@ -247,7 +249,7 @@ describe_command (command, dflags) if (dflags & CDESC_TYPE) puts ("keyword"); else if (dflags & CDESC_SHORTDESC) - printf ("%s is a shell keyword\n", command); + printf (_("%s is a shell keyword\n"), command); else if (dflags & CDESC_REUSABLE) printf ("%s\n", command); @@ -267,7 +269,7 @@ describe_command (command, dflags) #define PRETTY_PRINT_FUNC 1 char *result; - printf ("%s is a function\n", command); + printf (_("%s is a function\n"), command); /* We're blowing away THE_PRINTED_COMMAND here... */ @@ -292,7 +294,7 @@ describe_command (command, dflags) if (dflags & CDESC_TYPE) puts ("builtin"); else if (dflags & CDESC_SHORTDESC) - printf ("%s is a shell builtin\n", command); + printf (_("%s is a shell builtin\n"), command); else if (dflags & CDESC_REUSABLE) printf ("%s\n", command); @@ -313,7 +315,7 @@ describe_command (command, dflags) if (dflags & CDESC_TYPE) puts ("file"); else if (dflags & CDESC_SHORTDESC) - printf ("%s is %s\n", command, command); + printf (_("%s is %s\n"), command, command); else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY)) printf ("%s\n", command); @@ -333,7 +335,7 @@ describe_command (command, dflags) if (dflags & CDESC_TYPE) puts ("file"); else if (dflags & CDESC_SHORTDESC) - printf ("%s is hashed (%s)\n", command, full_path); + printf (_("%s is hashed (%s)\n"), command, full_path); else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY)) printf ("%s\n", full_path); diff --git a/builtins/ulimit.def b/builtins/ulimit.def index 3e147b4..932a6ea 100644 --- a/builtins/ulimit.def +++ b/builtins/ulimit.def @@ -1,7 +1,7 @@ This file is ulimit.def, from which is created ulimit.c. It implements the builtin "ulimit" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2003 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -70,6 +70,8 @@ $END #include <stdio.h> #include <errno.h> +#include "../bashintl.h" + #include "../shell.h" #include "common.h" #include "bashgetopt.h" @@ -327,7 +329,7 @@ ulimit_builtin (list) { if (STREQ (list->word->word, "unlimited") == 0) { - builtin_error ("%s: invalid limit argument", list->word->word); + builtin_error (_("%s: invalid limit argument"), list->word->word); return (EXECUTION_FAILURE); } return (set_all_limits (mode == 0 ? LIMIT_SOFT|LIMIT_HARD : mode, RLIM_INFINITY)); @@ -353,7 +355,7 @@ ulimit_builtin (list) limind = _findlim (cmdlist[c].cmd); if (limind == -1) { - builtin_error ("`%c': bad command", cmdlist[c].cmd); + builtin_error (_("`%c': bad command"), cmdlist[c].cmd); return (EX_USAGE); } } @@ -382,7 +384,7 @@ ulimit_internal (cmd, cmdarg, mode, multiple) opt = get_limit (limind, &soft_limit, &hard_limit); if (opt < 0) { - builtin_error ("%s: cannot get limit: %s", limits[limind].description, + builtin_error (_("%s: cannot get limit: %s"), limits[limind].description, strerror (errno)); return (EXECUTION_FAILURE); } @@ -420,7 +422,7 @@ ulimit_internal (cmd, cmdarg, mode, multiple) if (set_limit (limind, real_limit, mode) < 0) { - builtin_error ("%s: cannot modify limit: %s", limits[limind].description, + builtin_error (_("%s: cannot modify limit: %s"), limits[limind].description, strerror (errno)); return (EXECUTION_FAILURE); } diff --git a/builtins/umask.def b/builtins/umask.def index 19a0ac0..489ca33 100644 --- a/builtins/umask.def +++ b/builtins/umask.def @@ -1,7 +1,7 @@ This file is umask.def, from which is created umask.c. It implements the builtin "umask" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -37,7 +37,7 @@ $END #include "../bashtypes.h" #include "filecntl.h" -#ifndef _MINIX +#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H) # include <sys/file.h> #endif @@ -48,6 +48,8 @@ $END #include <stdio.h> #include <chartypes.h> +#include "../bashintl.h" + #include "../shell.h" #include "posixstat.h" #include "common.h" @@ -107,7 +109,7 @@ umask_builtin (list) is lousy. */ if (umask_value == -1) { - sh_erange (list->word->word, "octal number"); + sh_erange (list->word->word, _("octal number")); return (EXECUTION_FAILURE); } } @@ -221,7 +223,7 @@ parse_symbolic_mode (mode, initial_bits) case '=': break; default: - builtin_error ("`%c': invalid symbolic mode operator", op); + builtin_error (_("`%c': invalid symbolic mode operator"), op); return (-1); } @@ -260,6 +262,8 @@ parse_symbolic_mode (mode, initial_bits) bits &= ~perm; break; case '=': + if (who == 0) + who = S_IRWXU | S_IRWXG | S_IRWXO; bits &= ~who; bits |= perm; break; @@ -274,7 +278,7 @@ parse_symbolic_mode (mode, initial_bits) } else { - builtin_error ("`%c': invalid symbolic mode character", *s); + builtin_error (_("`%c': invalid symbolic mode character"), *s); return (-1); } } @@ -298,7 +302,7 @@ symbolic_umask (list) /* All work is done with the complement of the umask -- it's more intuitive and easier to deal with. It is complemented again before being returned. */ - bits = parse_symbolic_mode (list->word->word, ~um); + bits = parse_symbolic_mode (list->word->word, ~um & 0777); if (bits == -1) return (-1); diff --git a/builtins/wait.def b/builtins/wait.def index 23c8b19..9eb66f6 100644 --- a/builtins/wait.def +++ b/builtins/wait.def @@ -1,7 +1,7 @@ This file is wait.def, from which is created wait.c. It implements the builtin "wait" in Bash. -Copyright (C) 1987-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -141,7 +141,7 @@ wait_builtin (list) } } #if defined (JOB_CONTROL) - else if (job_control && *w) + else if (*w && *w == '%') /* Must be a job spec. Check it out. */ { int job; @@ -164,12 +164,6 @@ wait_builtin (list) UNBLOCK_CHILD (oset); status = wait_for_job (job); } - else if (job_control == 0 && *w == '%') - { - /* can't use jobspecs as arguments if job control is not active. */ - sh_nojobs ((char *)NULL); - status = EXECUTION_FAILURE; - } #endif /* JOB_CONTROL */ else { |