summaryrefslogtreecommitdiff
path: root/builtins
diff options
context:
space:
mode:
Diffstat (limited to 'builtins')
-rw-r--r--builtins/-i0
-rw-r--r--builtins/ChangeLog0
-rw-r--r--builtins/Makefile.in52
-rw-r--r--builtins/bind.def16
-rw-r--r--builtins/break.def6
-rw-r--r--builtins/builtin.def2
-rw-r--r--builtins/caller.def21
-rw-r--r--builtins/cd.def12
-rw-r--r--builtins/common.c52
-rw-r--r--builtins/common.h1
-rw-r--r--builtins/complete.def13
-rw-r--r--builtins/declare.def11
-rw-r--r--builtins/enable.def22
-rw-r--r--builtins/evalfile.c7
-rw-r--r--builtins/exec.def5
-rw-r--r--builtins/exit.def15
-rw-r--r--builtins/fc.def10
-rw-r--r--builtins/fg_bg.def6
-rw-r--r--builtins/getopt.c5
-rw-r--r--builtins/hash.def7
-rw-r--r--builtins/help.def19
-rw-r--r--builtins/history.def9
-rw-r--r--builtins/jobs.def5
-rw-r--r--builtins/kill.def5
-rw-r--r--builtins/let.def6
-rw-r--r--builtins/mkbuiltins.c9
-rw-r--r--builtins/printf.def54
-rw-r--r--builtins/psize-posix.c15
-rw-r--r--builtins/pushd.def111
-rw-r--r--builtins/read.def12
-rw-r--r--builtins/return.def6
-rw-r--r--builtins/set.def9
-rw-r--r--builtins/setattr.def7
-rw-r--r--builtins/shift.def7
-rw-r--r--builtins/shopt.def8
-rw-r--r--builtins/source.def13
-rw-r--r--builtins/suspend.def7
-rw-r--r--builtins/type.def13
-rw-r--r--builtins/ulimit.def12
-rw-r--r--builtins/umask.def8
-rw-r--r--builtins/xkill.def249
41 files changed, 617 insertions, 230 deletions
diff --git a/builtins/-i b/builtins/-i
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/builtins/-i
diff --git a/builtins/ChangeLog b/builtins/ChangeLog
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/builtins/ChangeLog
diff --git a/builtins/Makefile.in b/builtins/Makefile.in
index ce650e7b..676dbb61 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 =
@@ -218,6 +225,12 @@ $(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
@@ -562,3 +575,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 $(BASHINCDIR)/gettext.h
+break.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+caller.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+cd.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+common.c: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+complete.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+declare.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+enable.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+evalfile.c: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+exec.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+exit.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+fc.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+fg_bg.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+getopt.c: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+hash.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+help.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+history.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+inlib.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+jobs.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+kill.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+let.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+mkbuiltins.c: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+printf.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+pushd.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+read.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+return.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+set.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+setattr.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+shift.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+shopt.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+source.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+suspend.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+type.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+ulimit.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
+umask.o: ${topdir}/bashintl.h $(BASHINCDIR)/gettext.h
diff --git a/builtins/bind.def b/builtins/bind.def
index ddf56199..4711031e 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 10254145..e61d5027 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 8571f372..dfa58bc9 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
index 868b2ee8..d372c588 100644
--- a/builtins/caller.def
+++ b/builtins/caller.def
@@ -1,7 +1,7 @@
This file is caller.def, from which is created caller.c. It implements the
builtin "caller" in Bash.
-Copyright (C) 2002 Rocky Bernstein for Free Software Foundation, Inc.
+Copyright (C) 2002-2003 Rocky Bernstein for Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -50,6 +50,8 @@ $END
#include <errno.h>
+#include "../bashintl.h"
+
#include "../shell.h"
#include "common.h"
#include "builtext.h"
@@ -120,17 +122,16 @@ caller_builtin (list)
#endif
}
-
#ifdef LOADABLE_BUILTIN
static char *caller_doc[] = {
- "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.",
+ 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
};
diff --git a/builtins/cd.def b/builtins/cd.def
index c13a78a5..68449e9c 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>
@@ -184,7 +185,7 @@ cd_builtin (list)
if (dirname == 0)
{
- builtin_error ("HOME not set");
+ builtin_error (_("HOME not set"));
return (EXECUTION_FAILURE);
}
lflag = 0;
@@ -196,7 +197,7 @@ cd_builtin (list)
if (dirname == 0)
{
- builtin_error ("OLDPWD not set");
+ builtin_error (_("OLDPWD not set"));
return (EXECUTION_FAILURE);
}
#if 0
@@ -346,7 +347,7 @@ 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);
}
@@ -404,7 +405,8 @@ change_to_directory (newdir, nolinks)
resolved path doesn't exist), fail immediately. */
if (posixly_correct && nolinks == 0 && canon_failed)
{
- errno = ENOENT;
+ if (errno != ENOENT)
+ errno = ENOTDIR;
return (0);
}
diff --git a/builtins/common.c b/builtins/common.c
index e780be5a..0e0787b0 100644
--- a/builtins/common.c
+++ b/builtins/common.c
@@ -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", s);
+ 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 */
@@ -470,9 +478,9 @@ get_working_directory (for_whom)
directory = getcwd (the_current_working_directory, PATH_MAX);
if (directory == 0)
{
- fprintf (stderr, "%s: could not get current directory: %s: %s\n",
+ fprintf (stderr, _("%s: could not get current directory: %s: %s\n"),
(for_whom && *for_whom) ? for_whom : get_name_for_error (),
- bash_getcwd_errstr, strerror (errno));
+ _(bash_getcwd_errstr), strerror (errno));
free (the_current_working_directory);
the_current_working_directory = (char *)NULL;
@@ -537,9 +545,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
diff --git a/builtins/common.h b/builtins/common.h
index c8438638..309bb6d8 100644
--- a/builtins/common.h
+++ b/builtins/common.h
@@ -75,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));
diff --git a/builtins/complete.def b/builtins/complete.def
index 06f0c957..a859b88f 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,6 +43,7 @@ $END
#endif
#include "../bashansi.h"
+#include "../bashintl.h"
#include "../shell.h"
#include "../builtins.h"
@@ -247,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;
@@ -377,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;
}
}
@@ -520,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;
}
}
@@ -567,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 ();
diff --git a/builtins/declare.def b/builtins/declare.def
index 0b151498..fe112dd6 100644
--- a/builtins/declare.def
+++ b/builtins/declare.def
@@ -68,6 +68,7 @@ $END
#include <stdio.h>
#include "../bashansi.h"
+#include "../bashintl.h"
#include "../shell.h"
#include "common.h"
@@ -101,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);
}
}
@@ -227,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 */
{
@@ -291,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);
}
@@ -303,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 ();
}
@@ -385,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/enable.def b/builtins/enable.def
index 7496d427..823c38f9 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 850acbd6..c17e547b 100644
--- a/builtins/evalfile.c
+++ b/builtins/evalfile.c
@@ -31,6 +31,7 @@
#include <errno.h>
#include "../bashansi.h"
+#include "../bashintl.h"
#include "../shell.h"
#include "../jobs.h"
@@ -124,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);
}
@@ -137,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);
}
diff --git a/builtins/exec.def b/builtins/exec.def
index 73a42f69..acfdae10 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,7 +202,7 @@ 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
diff --git a/builtins/exit.def b/builtins/exit.def
index 735fecc2..9384adef 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,7 +123,11 @@ 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 ();
diff --git a/builtins/fc.def b/builtins/fc.def
index 0e6ab990..93c7ae3d 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
@@ -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 c16d894d..ea13bef3 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 60c6188a..b223a76a 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/hash.def b/builtins/hash.def
index 6e0e3476..d311ac90 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 234307b7..1935b64e 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 5c1a829d..52b1113f 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.
@@ -64,6 +64,7 @@ $END
#endif
#include "../bashansi.h"
+#include "../bashintl.h"
#include "../shell.h"
#include "../bashhist.h"
@@ -144,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);
}
@@ -176,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;
@@ -386,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 51b7c267..a1f75ae2 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-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 "../jobs.h"
@@ -98,7 +99,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++;
diff --git a/builtins/kill.def b/builtins/kill.def
index 12074917..fcd5f468 100644
--- a/builtins/kill.def
+++ b/builtins/kill.def
@@ -45,6 +45,7 @@ $END
#endif
#include "../bashansi.h"
+#include "../bashintl.h"
#include "../shell.h"
#include "../trap.h"
@@ -183,7 +184,7 @@ kill_builtin (list)
#if defined (JOB_CONTROL)
else if (*list->word->word && *list->word->word != '%')
{
- builtin_error ("%s: arguments must be process or job IDs", 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))
@@ -244,6 +245,6 @@ kill_error (pid, e)
x = strerror (e);
if (x == 0)
- x = "Unknown error";
+ x = _("Unknown error");
builtin_error ("(%ld) - %s", (long)pid, x);
}
diff --git a/builtins/let.def b/builtins/let.def
index 85131b04..ab43a454 100644
--- a/builtins/let.def
+++ b/builtins/let.def
@@ -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 f8d82f11..278755b4 100644
--- a/builtins/mkbuiltins.c
+++ b/builtins/mkbuiltins.c
@@ -1129,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");
}
@@ -1369,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++)
@@ -1392,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 705f5b6e..9b377a93 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));
@@ -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/psize-posix.c b/builtins/psize-posix.c
new file mode 100644
index 00000000..dffc9c34
--- /dev/null
+++ b/builtins/psize-posix.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <unistd.h>
+
+main(c, v)
+int c;
+char **v;
+{
+ char *p;
+ long l;
+
+ p = v[1] ? v[1] : "/";
+ l = pathconf (p, _PC_PIPE_BUF);
+ printf ("%ld\n", l);
+ exit(0);
+}
diff --git a/builtins/pushd.def b/builtins/pushd.def
index 2bb72ffa..83b69c44 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 7f6a83c1..ccbea843 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-2003 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
diff --git a/builtins/return.def b/builtins/return.def
index 84a90a33..23389c07 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 4f900dd6..02cc16a1 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"
@@ -739,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);
}
@@ -776,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 ();
}
@@ -794,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 0ef5041e..d211dbc4 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"
@@ -161,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
@@ -172,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 236f10ff..9744b814 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->word->word, _("shift count"));
return (EXECUTION_FAILURE);
}
else if (times > number_of_args ())
{
if (print_shift_error)
- sh_erange (list ? list->word->word : NULL, "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 88ecbb2d..ad432e0c 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"
@@ -221,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);
}
@@ -286,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
diff --git a/builtins/source.def b/builtins/source.def
index 422e293e..f9f812f8 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.
@@ -55,6 +55,7 @@ $END
#endif
#include "../bashansi.h"
+#include "../bashintl.h"
#include "../shell.h"
#include "../flags.h"
@@ -91,7 +92,8 @@ maybe_pop_dollar_vars ()
dispose_saved_dollar_vars ();
else
pop_dollar_vars ();
- pop_args (); /* restore BASH_ARGC and BASH_ARGV */
+ if (debugging_mode)
+ pop_args (); /* restore BASH_ARGC and BASH_ARGV */
set_dollar_vars_unchanged ();
}
@@ -112,7 +114,7 @@ source_builtin (list)
if (list == 0)
{
- builtin_error ("filename argument required");
+ builtin_error (_("filename argument required"));
builtin_usage ();
return (EX_USAGE);
}
@@ -132,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
@@ -147,7 +149,8 @@ source_builtin (list)
push_dollar_vars ();
add_unwind_protect ((Function *)maybe_pop_dollar_vars, (char *)NULL);
remember_args (list->next, 1);
- push_args (list->next); /* Update BASH_ARGV and BASH_ARGC */
+ if (debugging_mode)
+ push_args (list->next); /* Update BASH_ARGV and BASH_ARGC */
}
set_dollar_vars_unchanged ();
diff --git a/builtins/suspend.def b/builtins/suspend.def
index 6a77210f..d616d775 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,7 +100,7 @@ suspend_builtin (list)
if (login_shell)
{
- builtin_error ("cannot suspend a login shell");
+ builtin_error (_("cannot suspend a login shell"));
return (EXECUTION_FAILURE);
}
}
diff --git a/builtins/type.def b/builtins/type.def
index 8e5028a0..7abcedf2 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"
@@ -227,7 +228,7 @@ describe_command (command, dflags)
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);
@@ -248,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);
@@ -268,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... */
@@ -293,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);
@@ -314,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);
@@ -334,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 3e147b4f..932a6ea4 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 f1693316..e0f02eee 100644
--- a/builtins/umask.def
+++ b/builtins/umask.def
@@ -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);
}
@@ -274,7 +276,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);
}
}
diff --git a/builtins/xkill.def b/builtins/xkill.def
new file mode 100644
index 00000000..de1a3edf
--- /dev/null
+++ b/builtins/xkill.def
@@ -0,0 +1,249 @@
+This file is kill.def, from which is created kill.c.
+It implements the builtin "kill" in Bash.
+
+Copyright (C) 1987-2003 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 kill.c
+
+$BUILTIN kill
+$FUNCTION kill_builtin
+$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'"
+$_ "lists the signal names; if arguments follow `-l' they are assumed to"
+$_ "be signal numbers for which names should be listed. Kill is a shell"
+$_ "builtin for two reasons: it allows job IDs to be used instead of"
+$_ "process IDs, and, if you have reached the limit on processes that"
+$_ "you can create, you don't have to start a process to kill another one."
+$END
+
+#include <config.h>
+
+#include <stdio.h>
+#include <errno.h>
+#if defined (HAVE_UNISTD_H)
+# ifdef _MINIX
+# include <sys/types.h>
+# endif
+# include <unistd.h>
+#endif
+
+#include "../bashansi.h"
+
+#include "../shell.h"
+#include "../trap.h"
+#include "../jobs.h"
+#include "common.h"
+
+/* Not all systems declare ERRNO in errno.h... and some systems #define it! */
+#if !defined (errno)
+extern int errno;
+#endif /* !errno */
+
+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
+# define CONTINUE_OR_FAIL goto continue_killing
+#endif /* CONTINUE_AFTER_KILL_ERROR */
+
+/* Here is the kill builtin. We only have it so that people can type
+ kill -KILL %1? No, if you fill up the process table this way you
+ can still kill some. */
+int
+kill_builtin (list)
+ WORD_LIST *list;
+{
+ int sig, any_succeeded, listing, saw_signal, dflags;
+ char *sigspec, *word;
+ pid_t pid;
+ intmax_t pid_value;
+
+ if (list == 0)
+ {
+ builtin_usage ();
+ return (EXECUTION_FAILURE);
+ }
+
+ any_succeeded = listing = saw_signal = 0;
+ sig = SIGTERM;
+ sigspec = "TERM";
+
+ dflags = DSIG_NOCASE | ((posixly_correct == 0) ? DSIG_SIGPREFIX : 0);
+ /* Process options. */
+ while (list)
+ {
+ word = list->word->word;
+
+ if (ISOPTION (word, 'l'))
+ {
+ listing++;
+ list = list->next;
+ }
+ else if (ISOPTION (word, 's') || ISOPTION (word, 'n'))
+ {
+ list = list->next;
+ if (list)
+ {
+ sigspec = list->word->word;
+ if (sigspec[0] == '0' && sigspec[1] == '\0')
+ sig = 0;
+ else
+ sig = decode_signal (sigspec, dflags);
+ list = list->next;
+ }
+ else
+ {
+ sh_needarg (word);
+ return (EXECUTION_FAILURE);
+ }
+ }
+ else if (ISOPTION (word, '-'))
+ {
+ list = list->next;
+ break;
+ }
+ else if (ISOPTION (word, '?'))
+ {
+ builtin_usage ();
+ return (EXECUTION_SUCCESS);
+ }
+ /* If this is a signal specification then process it. We only process
+ the first one seen; other arguments may signify process groups (e.g,
+ -num == process group num). */
+ else if ((*word == '-') && !saw_signal)
+ {
+ sigspec = word + 1;
+ sig = decode_signal (sigspec, dflags);
+ saw_signal++;
+ list = list->next;
+ }
+ else
+ break;
+ }
+
+ if (listing)
+ return (display_signal_list (list, 0));
+
+ /* OK, we are killing processes. */
+ if (sig == NO_SIG)
+ {
+ sh_invalidsig (sigspec);
+ return (EXECUTION_FAILURE);
+ }
+
+ if (list == 0)
+ {
+ builtin_usage ();
+ return (EXECUTION_FAILURE);
+ }
+
+ while (list)
+ {
+ word = list->word->word;
+
+ if (*word == '-')
+ word++;
+
+ /* Use the entire argument in case of minus sign presence. */
+ if (*word && legal_number (list->word->word, &pid_value) && (pid_value == (pid_t)pid_value))
+ {
+ pid = (pid_t) pid_value;
+
+ if ((pid < -1 ? kill_pid (-pid, sig, 1) : kill_pid (pid, sig, 0)) < 0)
+ {
+ 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: arguments must be process or job IDs", list->word->word);
+ CONTINUE_OR_FAIL;
+ }
+ else if (*word && (interactive || job_control))
+ /* Posix.2 says you can kill without job control active (4.32.4) */
+ { /* Must be a job spec. Check it out. */
+ int job;
+ sigset_t set, oset;
+
+ BLOCK_CHILD (set, oset);
+ job = get_job_spec (list);
+
+ if (job < 0 || job >= job_slots || !jobs[job])
+ {
+ if (job != DUP_JOB)
+ sh_badjob (list->word->word);
+ UNBLOCK_CHILD (oset);
+ CONTINUE_OR_FAIL;
+ }
+
+ /* Job spec used. Kill the process group. If the job was started
+ without job control, then its pgrp == shell_pgrp, so we have
+ to be careful. We take the pid of the first job in the pipeline
+ in that case. */
+ pid = IS_JOBCONTROL (job) ? jobs[job]->pgrp : jobs[job]->pipe->pid;
+
+ UNBLOCK_CHILD (oset);
+
+ if (kill_pid (pid, sig, 1) < 0)
+ {
+ if (errno == EINVAL)
+ sh_invalidsig (sigspec);
+ else
+ kill_error (pid, errno);
+ CONTINUE_OR_FAIL;
+ }
+ else
+ any_succeeded++;
+ }
+#endif /* !JOB_CONTROL */
+ else
+ {
+ sh_badpid (list->word->word);
+ CONTINUE_OR_FAIL;
+ }
+ continue_killing:
+ list = list->next;
+ }
+
+ return (any_succeeded ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
+}
+
+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);
+}