summaryrefslogtreecommitdiff
path: root/builtins
diff options
context:
space:
mode:
Diffstat (limited to 'builtins')
-rw-r--r--builtins/Makefile.in15
-rw-r--r--builtins/bind.def26
-rw-r--r--builtins/break.def6
-rw-r--r--builtins/builtin.def9
-rw-r--r--builtins/caller.def23
-rw-r--r--builtins/cd.def13
-rw-r--r--builtins/common.c23
-rw-r--r--builtins/complete.def16
-rw-r--r--builtins/declare.def32
-rw-r--r--builtins/echo.def9
-rw-r--r--builtins/enable.def6
-rw-r--r--builtins/evalfile.c25
-rw-r--r--builtins/evalstring.c5
-rw-r--r--builtins/exec.def4
-rw-r--r--builtins/exit.def42
-rw-r--r--builtins/fc.def7
-rw-r--r--builtins/fg_bg.def4
-rw-r--r--builtins/hash.def4
-rw-r--r--builtins/help.def46
-rw-r--r--builtins/history.def6
-rw-r--r--builtins/inlib.def2
-rw-r--r--builtins/jobs.def4
-rw-r--r--builtins/mkbuiltins.c2
-rw-r--r--builtins/printf.def40
-rw-r--r--builtins/pushd.def146
-rw-r--r--builtins/read.def9
-rw-r--r--builtins/reserved.def10
-rw-r--r--builtins/set.def12
-rw-r--r--builtins/setattr.def4
-rw-r--r--builtins/shopt.def12
-rw-r--r--builtins/source.def5
-rw-r--r--builtins/suspend.def4
-rw-r--r--builtins/test.def5
-rw-r--r--builtins/times.def4
-rw-r--r--builtins/trap.def6
-rw-r--r--builtins/type.def2
-rw-r--r--builtins/ulimit.def14
-rw-r--r--builtins/wait.def6
38 files changed, 355 insertions, 253 deletions
diff --git a/builtins/Makefile.in b/builtins/Makefile.in
index e027f7aa..65c4d23e 100644
--- a/builtins/Makefile.in
+++ b/builtins/Makefile.in
@@ -39,9 +39,12 @@ prefix = @prefix@
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
+
+datarootdir = @datarootdir@
+
includedir = @includedir@
datadir = @datadir@
-localedir = $(datadir)/locale
+localedir = @localedir@
# Support an alternate destination root directory for package building
DESTDIR =
@@ -74,7 +77,10 @@ RL_INCLUDEDIR = @RL_INCLUDEDIR@
INTL_LIBSRC = ${topdir}/lib/intl
INTL_BUILDDIR = ${LIBBUILD}/intl
+INTL_LIBDIR = ${INTL_BUILDDIR}
+INTL_LIBRARY = ${INTL_BUILDDIR}/libintl.a
INTL_INC = @INTL_INC@
+INTL_DEP = @INTL_DEP@
LIBINTL_H = @LIBINTL_H@
HELPDIR = @HELPDIR@
@@ -236,6 +242,11 @@ $(OFILES): $(MKBUILTINS) ../config.h
po: builtins.c
xgettext -L C -o $(topdir)/po/builtins.pot --keyword='N_' builtins.c 2>/dev/null
+${LIBINTL_H}:
+ @echo making $@ in ${INTL_BUILDDIR}
+ @(cd ${INTL_BUILDDIR} && \
+ $(MAKE) $(MFLAGS) libintl.h) || exit 1
+
# dependencies
alias.o: alias.def
@@ -609,7 +620,7 @@ 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
+mkbuiltins.o: ${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
diff --git a/builtins/bind.def b/builtins/bind.def
index 4711031e..ce246dde 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-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -29,10 +29,10 @@ $FUNCTION bind_builtin
$SHORT_DOC bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command]
Bind a key sequence to a Readline function or a macro, or set
a Readline variable. The non-option argument syntax is equivalent
-to that found in ~/.inputrc, but must be passed as a single argument:
+to that found in ~/.inputrc, but must be passed as a single argument: e.g.,
bind '"\C-x\C-r": re-read-init-file'.
bind accepts the following options:
- -m keymap Use `keymap' as the keymap for the duration of this
+ -m keymap Use KEYMAP as the keymap for the duration of this
command. Acceptable keymap names are emacs,
emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
vi-command, and vi-insert.
@@ -40,18 +40,18 @@ bind accepts the following options:
-P List function names and bindings.
-p List functions and bindings in a form that can be
reused as input.
- -r keyseq Remove the binding for KEYSEQ.
- -x keyseq:shell-command Cause SHELL-COMMAND to be executed when
- KEYSEQ is entered.
- -f filename Read key bindings from FILENAME.
- -q function-name Query about which keys invoke the named function.
- -u function-name Unbind all keys which are bound to the named function.
- -V List variable names and values
- -v List variable names and values in a form that can
- be reused as input.
-S List key sequences that invoke macros and their values
-s List key sequences that invoke macros and their values
in a form that can be reused as input.
+ -V List variable names and values
+ -v List variable names and values in a form that can
+ be reused as input.
+ -q function-name Query about which keys invoke the named function.
+ -u function-name Unbind all keys which are bound to the named function.
+ -r keyseq Remove the binding for KEYSEQ.
+ -f filename Read key bindings from FILENAME.
+ -x keyseq:shell-command Cause SHELL-COMMAND to be executed when
+ KEYSEQ is entered.
$END
#if defined (READLINE)
@@ -310,7 +310,7 @@ unbind_command (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;
}
diff --git a/builtins/break.def b/builtins/break.def
index e61d5027..7d7ebe95 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-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -70,7 +70,7 @@ break_builtin (list)
if (newbreak <= 0)
{
- sh_erange (list->word->word, "loop count");
+ sh_erange (list->word->word, _("loop count"));
breaking = loop_level;
return (EXECUTION_FAILURE);
}
@@ -105,7 +105,7 @@ continue_builtin (list)
if (newcont <= 0)
{
- sh_erange (list->word->word, "loop count");
+ sh_erange (list->word->word, _("loop count"));
breaking = loop_level;
return (EXECUTION_FAILURE);
}
diff --git a/builtins/builtin.def b/builtins/builtin.def
index dfa58bc9..4e38fb4e 100644
--- a/builtins/builtin.def
+++ b/builtins/builtin.def
@@ -1,7 +1,7 @@
This file is builtin.def, from which is created builtin.c.
It implements the builtin "builtin" in Bash.
-Copyright (C) 1987-2002 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -24,9 +24,10 @@ $PRODUCES builtin.c
$BUILTIN builtin
$FUNCTION builtin_builtin
$SHORT_DOC builtin [shell-builtin [arg ...]]
-Run a shell builtin. This is useful when you wish to rename a
-shell builtin to be a function, but need the functionality of the
-builtin within the function itself.
+Execute SHELL-BUILTIN with arguments ARGs without performing shell function
+lookup. This is useful when you wish to reimplement a shell builtin as a
+shell function, but need the functionality of the builtin within the function
+itself.
$END
#include <config.h>
diff --git a/builtins/caller.def b/builtins/caller.def
index 5142cab9..63a25f3d 100644
--- a/builtins/caller.def
+++ b/builtins/caller.def
@@ -24,13 +24,13 @@ $PRODUCES caller.c
$BUILTIN caller
$FUNCTION caller_builtin
$DEPENDS_ON DEBUGGER
-$SHORT_DOC caller [EXPR]
+$SHORT_DOC caller [expr]
Returns the context of the current subroutine call.
-Without EXPR, returns returns "$line $filename". With EXPR,
+Without EXPR, returns "$line $filename". With EXPR,
returns "$line $subroutine $filename"; this extra information
-can be used used to provide a stack trace.
+can be 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.
@@ -76,7 +76,6 @@ caller_builtin (list)
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);
@@ -129,14 +128,14 @@ caller_builtin (list)
#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."),
+N_("Returns the context of the current subroutine call.\n\
+ \n\
+ Without EXPR, 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 025e4f5e..7d3ff461 100644
--- a/builtins/cd.def
+++ b/builtins/cd.def
@@ -56,10 +56,11 @@ extern int errno;
extern int posixly_correct;
extern int array_needs_making;
-extern char *bash_getcwd_errstr;
+extern const char * const bash_getcwd_errstr;
static int bindpwd __P((int));
static void setpwd __P((char *));
+static char *resetpwd __P((char *));
static int change_to_directory __P((char *, int));
static char *cdspell __P((char *));
@@ -72,11 +73,11 @@ int cdable_vars;
$BUILTIN cd
$FUNCTION cd_builtin
$SHORT_DOC cd [-L|-P] [dir]
-Change the current directory to DIR. The variable $HOME is the
-default DIR. The variable CDPATH defines the search path for
-the directory containing DIR. Alternative directory names in CDPATH
-are separated by a colon (:). A null directory name is the same as
-the current directory, i.e. `.'. If DIR begins with a slash (/),
+Change the current directory to DIR. The default for DIR is the value
+of the HOME shell variable. The variable CDPATH defines the search
+path for the directory containing DIR. Alternative directory names in
+CDPATH are separated by a colon (:). A null directory name is the same
+as the current directory, i.e., `.'. If DIR begins with a slash (/),
then CDPATH is not used. If the directory is not found, and the
shell option `cdable_vars' is set, then try the word as a variable
name. If that variable has a value, then cd to the value of that
diff --git a/builtins/common.c b/builtins/common.c
index 9d8f09ab..5d9b189f 100644
--- a/builtins/common.c
+++ b/builtins/common.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -69,7 +69,7 @@ extern int last_command_exit_value;
extern int running_trap;
extern int posixly_correct;
extern char *this_command_name, *shell_name;
-extern char *bash_getcwd_errstr;
+extern const char * const bash_getcwd_errstr;
/* Used by some builtins and the mainline code. */
sh_builtin_func_t *last_shell_builtin = (sh_builtin_func_t *)NULL;
@@ -100,7 +100,7 @@ builtin_error (format, va_alist)
fprintf (stderr, "%s: ", name);
if (interactive_shell == 0)
- fprintf (stderr, "line %d: ", executing_line_number ());
+ fprintf (stderr, _("line %d: "), executing_line_number ());
if (this_command_name && *this_command_name)
fprintf (stderr, "%s: ", this_command_name);
@@ -117,7 +117,7 @@ void
builtin_usage ()
{
if (this_command_name && *this_command_name)
- fprintf (stderr, "%s: usage: ", this_command_name);
+ fprintf (stderr, _("%s: usage: "), this_command_name);
fprintf (stderr, "%s\n", current_builtin->short_doc);
fflush (stderr);
}
@@ -131,6 +131,7 @@ no_args (list)
if (list)
{
builtin_error (_("too many arguments"));
+ top_level_cleanup ();
jump_to_top_level (DISCARD);
}
}
@@ -395,7 +396,10 @@ get_numeric_arg (list, fatal)
if (fatal)
throw_to_top_level ();
else
- jump_to_top_level (DISCARD);
+ {
+ top_level_cleanup ();
+ jump_to_top_level (DISCARD);
+ }
}
no_args (list->next);
}
@@ -467,9 +471,6 @@ char *
get_working_directory (for_whom)
char *for_whom;
{
- char *directory;
- size_t dsize;
-
if (no_symbolic_links)
{
FREE (the_current_working_directory);
@@ -478,7 +479,11 @@ get_working_directory (for_whom)
if (the_current_working_directory == 0)
{
+#if defined (GETCWD_BROKEN)
+ the_current_working_directory = getcwd (0, PATH_MAX);
+#else
the_current_working_directory = getcwd (0, 0);
+#endif
if (the_current_working_directory == 0)
{
fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"),
@@ -642,7 +647,7 @@ display_signal_list (list, forcecols)
{
printf ("%2d) %s", i, name);
- if (++column < 4)
+ if (++column < 5)
printf ("\t");
else
{
diff --git a/builtins/complete.def b/builtins/complete.def
index a859b88f..56f87549 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-2003 Free Software Foundation, Inc.
+Copyright (C) 1999-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -24,12 +24,14 @@ $PRODUCES complete.c
$BUILTIN complete
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION complete_builtin
-$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
+$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
For each NAME, specify how arguments are to be completed.
If the -p option is supplied, or if no options are supplied, existing
completion specifications are printed in a way that allows them to be
reused as input. The -r option removes a completion specification for
each NAME, or, if no NAMEs are supplied, all completion specifications.
+When completion is attempted, the actions are applied in the order the
+uppercase-letter options are listed above.
$END
#include <config.h>
@@ -71,8 +73,8 @@ static int print_cmd_completions __P((WORD_LIST *));
static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
-static struct _compacts {
- char *actname;
+static const struct _compacts {
+ const char * const actname;
int actflag;
int actopt;
} compacts[] = {
@@ -104,8 +106,8 @@ static struct _compacts {
};
/* This should be a STRING_INT_ALIST */
-static struct _compopt {
- char *optname;
+const static struct _compopt {
+ const char * const optname;
int optflag;
} compopts[] = {
{ "bashdefault", COPT_BASHDEFAULT },
@@ -531,7 +533,7 @@ print_cmd_completions (list)
$BUILTIN compgen
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION compgen_builtin
-$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
+$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
Display the possible completions depending on the options. Intended
to be used from within a shell function generating possible completions.
If the optional WORD argument is supplied, matches against WORD are
diff --git a/builtins/declare.def b/builtins/declare.def
index 4d94face..a806f10a 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-2004 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -24,30 +24,29 @@ $PRODUCES declare.c
$BUILTIN declare
$FUNCTION declare_builtin
$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.
+Declare variables and give them attributes. If no NAMEs are
+given, then display the values of variables instead. When
+displaying variable values, the -f option restricts the display
+to function names and definitions; the -F option restricts the
+display to function names only (plus line number and source file
+when debugging). The -p option will display the attributes and
+values of each NAME.
-The flags are:
+The options which set attributes are:
-a to make NAMEs arrays (if supported)
- -f to select from among function names only
- -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
-x to make NAMEs export
-Variables with the integer attribute have arithmetic evaluation (see
-`let') done when the variable is assigned to.
+Using `+' instead of `-' turns off the given attribute.
-When displaying values of variables, -f displays a function's name
-and definition. The -F option restricts the display to function
-name only.
+Variables with the integer attribute have arithmetic evaluation (see
+the `let' command) done when the variable is assigned a value.
-Using `+' instead of `-' turns off the given attribute instead. When
-used in a function, makes NAMEs local, as with the `local' command.
+When used in a function, `declare' makes NAMEs local, as with the `local'
+command.
$END
$BUILTIN typeset
@@ -90,10 +89,11 @@ declare_builtin (list)
$BUILTIN local
$FUNCTION local_builtin
-$SHORT_DOC local name[=value] ...
+$SHORT_DOC local [option] name[=value] ...
Create a local variable called NAME, and give it VALUE. LOCAL
can only be used within a function; it makes the variable NAME
have a visible scope restricted to that function and its children.
+OPTION can be any of the options accepted by `declare'.
$END
int
local_builtin (list)
diff --git a/builtins/echo.def b/builtins/echo.def
index 6792659a..4291d7c1 100644
--- a/builtins/echo.def
+++ b/builtins/echo.def
@@ -31,6 +31,8 @@ $PRODUCES echo.c
#include <stdio.h>
#include "../shell.h"
+#include "common.h"
+
$BUILTIN echo
$FUNCTION echo_builtin
$DEPENDS_ON V9_ECHO
@@ -41,14 +43,17 @@ following backslash-escaped characters is turned on:
\a alert (bell)
\b backspace
\c suppress trailing newline
- \E escape character
+ \e escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
- \num the character whose ASCII code is NUM (octal).
+ \0nnn the character whose ASCII code is NNN (octal). NNN can be
+ 0 to 3 octal digits
+ \xHH the eight-bit character whose value is HH (hexadecimal). HH
+ can be one or two hex digits
You can explicitly turn off the interpretation of the above characters
with the -E option.
diff --git a/builtins/enable.def b/builtins/enable.def
index 823c38f9..3570be5e 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-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -23,7 +23,7 @@ $PRODUCES enable.c
$BUILTIN enable
$FUNCTION enable_builtin
-$SHORT_DOC enable [-pnds] [-a] [-f filename] [name ...]
+$SHORT_DOC enable [-a] [-dnps] [-f filename] [name ...]
Enable and disable builtin shell commands. This allows
you to use a disk command which has the same name as a shell
builtin without specifying a full pathname. If -n is used, the
@@ -32,7 +32,7 @@ to use the `test' found in $PATH instead of the shell builtin
version, type `enable -n test'. On systems supporting dynamic
loading, the -f option may be used to load new builtins from the
shared object FILENAME. The -d option will delete a builtin
-previously loaded with -f. If no non-option names are given, or
+previously loaded with -f. If no non-option NAMEs are given, or
the -p option is supplied, a list of builtins is printed. The
-a option means to print every builtin with an indication of whether
or not it is enabled. The -s option restricts the output to the POSIX.2
diff --git a/builtins/evalfile.c b/builtins/evalfile.c
index 81be017b..ac29ae80 100644
--- a/builtins/evalfile.c
+++ b/builtins/evalfile.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -45,6 +45,8 @@
# include "../bashhist.h"
#endif
+#include <typemax.h>
+
#include "common.h"
#if !defined (errno)
@@ -63,7 +65,7 @@ extern int errno;
#define FEVAL_NOPUSHARGS 0x100
extern int posixly_correct;
-extern int indirection_level, startup_state, subshell_environment;
+extern int indirection_level, subshell_environment;
extern int return_catch_flag, return_catch_value;
extern int last_command_exit_value;
@@ -78,6 +80,7 @@ _evalfile (filename, flags)
volatile int old_interactive;
procenv_t old_return_catch;
int return_val, fd, result, pflags;
+ ssize_t nr; /* return value from read(2) */
char *string;
struct stat finfo;
size_t file_size;
@@ -147,21 +150,27 @@ file_error_and_exit:
setmode (fd, O_TEXT);
#endif
- string = (char *)xmalloc (1 + file_size);
- result = read (fd, string, file_size);
- string[result] = '\0';
+ if (S_ISREG (finfo.st_mode) && file_size <= SSIZE_MAX)
+ {
+ string = (char *)xmalloc (1 + file_size);
+ nr = read (fd, string, file_size);
+ if (nr >= 0)
+ string[nr] = '\0';
+ }
+ else
+ nr = zmapfd (fd, &string, 0);
return_val = errno;
close (fd);
errno = return_val;
- if (result < 0) /* XXX was != file_size, not < 0 */
+ if (nr < 0) /* XXX was != file_size, not < 0 */
{
free (string);
goto file_error_and_exit;
}
- if (result == 0)
+ if (nr == 0)
{
free (string);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_SUCCESS : 1);
@@ -171,7 +180,7 @@ file_error_and_exit:
check_binary_file (string, (result > 80) ? 80 : result))
{
free (string);
- (*errfunc) ("%s: cannot execute binary file", filename);
+ (*errfunc) (_("%s: cannot execute binary file"), filename);
return ((flags & FEVAL_BUILTIN) ? EX_BINARY_FILE : -1);
}
diff --git a/builtins/evalstring.c b/builtins/evalstring.c
index 04afac3d..36f0ad39 100644
--- a/builtins/evalstring.c
+++ b/builtins/evalstring.c
@@ -56,7 +56,7 @@ extern int errno;
#define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL)
-extern int indirection_level, startup_state, subshell_environment;
+extern int indirection_level, subshell_environment;
extern int line_number;
extern int last_command_exit_value;
extern int running_trap;
@@ -316,9 +316,8 @@ static int
cat_file (r)
REDIRECT *r;
{
- char lbuf[128], *fn;
+ char *fn;
int fd, rval;
- ssize_t nr;
if (r->instruction != r_input_direction)
return -1;
diff --git a/builtins/exec.def b/builtins/exec.def
index 0818a25e..dd34ad53 100644
--- a/builtins/exec.def
+++ b/builtins/exec.def
@@ -24,12 +24,12 @@ $PRODUCES exec.c
$BUILTIN exec
$FUNCTION exec_builtin
$SHORT_DOC exec [-cl] [-a name] file [redirection ...]
-Exec FILE, replacing this shell with the specified program.
+Execute FILE, replacing this shell with the specified program.
If FILE is not specified, the redirections take effect in this
shell. If the first argument is `-l', then place a dash in the
zeroth arg passed to FILE, as login does. If the `-c' option
is supplied, FILE is executed with a null environment. The `-a'
-option means to make set argv[0] of the executed process to NAME.
+option means set argv[0] of the executed process to NAME.
If the file cannot be executed and the shell is not interactive,
then the shell exits, unless the shell option `execfail' is set.
$END
diff --git a/builtins/exit.def b/builtins/exit.def
index ddaa5d31..3c0bfdf7 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-2005 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -45,6 +45,7 @@ $END
#include "common.h"
#include "builtext.h" /* for jobs_builtin */
+extern int check_jobs_at_exit;
extern int last_command_exit_value;
extern int running_trap, trap_saved_exit_value;
extern int subshell_environment;
@@ -60,7 +61,7 @@ exit_builtin (list)
{
if (interactive)
{
- fprintf (stderr, login_shell ? "logout\n" : "exit\n");
+ fprintf (stderr, login_shell ? _("logout\n") : "exit\n");
fflush (stderr);
}
@@ -94,7 +95,7 @@ exit_or_logout (list)
int exit_value;
#if defined (JOB_CONTROL)
- int exit_immediate_okay;
+ int exit_immediate_okay, stopmsg;
exit_immediate_okay = (interactive == 0 ||
last_shell_builtin == exit_builtin ||
@@ -102,21 +103,32 @@ exit_or_logout (list)
last_shell_builtin == jobs_builtin);
/* Check for stopped jobs if the user wants to. */
- if (!exit_immediate_okay)
+ if (exit_immediate_okay == 0)
{
register int i;
- for (i = 0; i < js.j_jobslots; i++)
+ for (i = stopmsg = 0; i < js.j_jobslots; i++)
if (jobs[i] && STOPPED (i))
- {
- 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
- so that either `exit', `logout', or ^D will work to exit
- immediately if nothing intervenes. */
- this_shell_builtin = last_shell_builtin = exit_builtin;
- return (EXECUTION_FAILURE);
- }
+ stopmsg = JSTOPPED;
+ else if (check_jobs_at_exit && stopmsg == 0 && RUNNING (i))
+ stopmsg = JRUNNING;
+
+ if (stopmsg == JSTOPPED)
+ fprintf (stderr, _("There are stopped jobs.\n"));
+ else if (stopmsg == JRUNNING)
+ fprintf (stderr, _("There are running jobs.\n"));
+
+ if (stopmsg && check_jobs_at_exit)
+ list_all_jobs (JLIST_STANDARD);
+
+ if (stopmsg)
+ {
+ /* This is NOT superfluous because EOF can get here without
+ going through the command parser. Set both last and this
+ so that either `exit', `logout', or ^D will work to exit
+ immediately if nothing intervenes. */
+ this_shell_builtin = last_shell_builtin = exit_builtin;
+ return (EXECUTION_FAILURE);
+ }
}
#endif /* JOB_CONTROL */
diff --git a/builtins/fc.def b/builtins/fc.def
index ebe36832..a807309d 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-2005 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -24,7 +24,7 @@ $PRODUCES fc.c
$BUILTIN fc
$FUNCTION fc_builtin
$DEPENDS_ON HISTORY
-$SHORT_DOC fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]
+$SHORT_DOC fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]
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
@@ -37,7 +37,7 @@ string.
-n means no line numbers listed.
-r means reverse the order of the lines (making it newest listed first).
-With the `fc -s [pat=rep ...] [command]' format, the command is
+With the `fc -s [pat=rep ...] [command]' format, COMMAND is
re-executed after the substitution OLD=NEW is performed.
A useful alias to use with this is r='fc -s', so that typing `r cc'
@@ -81,7 +81,6 @@ $END
extern int errno;
#endif /* !errno */
-extern int echo_input_at_read;
extern int current_command_line_count;
extern int literal_history;
extern int posixly_correct;
diff --git a/builtins/fg_bg.def b/builtins/fg_bg.def
index c14381b6..2f86c8bd 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-2005 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -137,7 +137,7 @@ fg_bg (list, foreground)
if (INVALID_JOB (job))
{
if (job != DUP_JOB)
- sh_badjob (list ? list->word->word : "current");
+ sh_badjob (list ? list->word->word : _("current"));
goto failure;
}
diff --git a/builtins/hash.def b/builtins/hash.def
index 697ffd0a..8c827e17 100644
--- a/builtins/hash.def
+++ b/builtins/hash.def
@@ -158,7 +158,7 @@ hash_builtin (list)
#ifdef EISDIR
builtin_error ("%s: %s", pathname, strerror (EISDIR));
#else
- builtin_error ("%s: is a directory", pathname);
+ builtin_error (_("%s: is a directory"), pathname);
#endif
opt = EXECUTION_FAILURE;
}
@@ -233,7 +233,7 @@ print_hashed_commands (fmt)
return (0);
if (fmt == 0)
- printf ("hits\tcommand\n");
+ printf (_("hits\tcommand\n"));
hash_walk (hashed_filenames, fmt ? print_portable_hash_info : print_hash_info);
return (1);
}
diff --git a/builtins/help.def b/builtins/help.def
index 35a6de9c..059f9866 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-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -176,7 +176,8 @@ static void
show_builtin_command_help ()
{
int i, j;
- char blurb[36];
+ int height, width;
+ char *t, blurb[128];
printf (
_("These shell commands are defined internally. Type `help' to see this list.\n\
@@ -187,21 +188,42 @@ Use `man -k' or `info' to find out more about commands not in this list.\n\
A star (*) next to a name means that the command is disabled.\n\
\n"));
- for (i = 0; i < num_shell_builtins; i++)
+ t = get_string_value ("COLUMNS");
+ width = (t && *t) ? atoi (t) : 80;
+ if (width <= 0)
+ width = 80;
+
+ width /= 2;
+ if (width > sizeof (blurb))
+ width = sizeof (blurb);
+ height = (num_shell_builtins + 1) / 2; /* number of rows */
+
+ for (i = 0; i < height; i++)
{
QUIT;
+
+ /* first column */
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
- strncpy (blurb + 1, shell_builtins[i].short_doc, 34);
- blurb[35] = '\0';
+ strncpy (blurb + 1, shell_builtins[i].short_doc, width - 2);
+ blurb[width - 2] = '>'; /* indicate truncation */
+ blurb[width - 1] = '\0';
printf ("%s", blurb);
+ if ((i << 1) == num_shell_builtins)
+ {
+ printf ("\n");
+ break;
+ }
- if (i % 2)
- printf ("\n");
- else
- for (j = strlen (blurb); j < 35; j++)
- putc (' ', stdout);
+ /* two spaces */
+ for (j = strlen (blurb); j < width; j++)
+ putc (' ', stdout);
+
+ /* second column */
+ blurb[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
+ strncpy (blurb + 1, shell_builtins[i+height].short_doc, width - 3);
+ blurb[width - 3] = '>'; /* indicate truncation */
+ blurb[width - 2] = '\0';
+ printf ("%s\n", blurb);
}
- if (i % 2)
- printf ("\n");
}
#endif /* HELP_BUILTIN */
diff --git a/builtins/history.def b/builtins/history.def
index efee0052..97207922 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-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -24,7 +24,7 @@ $PRODUCES history.c
$BUILTIN history
$FUNCTION history_builtin
$DEPENDS_ON HISTORY
-$SHORT_DOC history [-c] [-d offset] [n] or history -awrn [filename] or history -ps arg [arg...]
+$SHORT_DOC history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
Display the history list with line numbers. Lines listed with
with a `*' have been modified. Argument of N says to list only
the last N lines. The `-c' option causes the history list to be
@@ -36,7 +36,7 @@ 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
+If FILENAME is given, then that is used as the history file. Otherwise,
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
diff --git a/builtins/inlib.def b/builtins/inlib.def
index 094c4b94..958c72e6 100644
--- a/builtins/inlib.def
+++ b/builtins/inlib.def
@@ -64,7 +64,7 @@ inlib_builtin (list)
if (status.all != status_$ok)
{
- builtin_error ("%s: inlib failed", list->word->word);
+ builtin_error (_("%s: inlib failed"), list->word->word);
return_value = EXECUTION_FAILURE;
}
diff --git a/builtins/jobs.def b/builtins/jobs.def
index 4c3ba6a7..ff1f3a80 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-2005 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -261,7 +261,7 @@ disown_builtin (list)
if (job == NO_JOB || jobs == 0 || INVALID_JOB (job))
{
- sh_badjob (list ? list->word->word : "current");
+ sh_badjob (list ? list->word->word : _("current"));
retval = EXECUTION_FAILURE;
}
else if (nohup_only)
diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c
index ff0bdc09..3923b8a0 100644
--- a/builtins/mkbuiltins.c
+++ b/builtins/mkbuiltins.c
@@ -1224,7 +1224,7 @@ write_builtins (defs, structfile, externfile)
document_name (builtin));
fprintf
- (structfile, " \"%s\", (char *)NULL },\n",
+ (structfile, " N_(\"%s\"), (char *)NULL },\n",
builtin->shortdoc ? builtin->shortdoc : builtin->name);
}
diff --git a/builtins/printf.def b/builtins/printf.def
index e4e31704..e283323c 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-2005 Free Software Foundation, Inc.
+Copyright (C) 1997-2007 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -26,8 +26,8 @@ $FUNCTION printf_builtin
$SHORT_DOC printf [-v var] format [arguments]
printf formats and prints ARGUMENTS under control of the FORMAT. FORMAT
is a character string which contains three types of objects: plain
-characters, which are simply copied to standard output, character escape
-sequences which are converted and copied to the standard output, and
+characters, which are simply copied to standard output; character escape
+sequences, which are converted and copied to the standard output; and
format specifications, each of which causes printing of the next successive
argument. In addition to the standard printf(1) formats, %b means to
expand backslash escape sequences in the corresponding argument, and %q
@@ -49,6 +49,12 @@ $END
# define INT_MIN (-2147483647-1)
#endif
+#if defined (PREFER_STDARG)
+# include <stdarg.h>
+#else
+# include <varargs.h>
+#endif
+
#include <stdio.h>
#include <chartypes.h>
@@ -64,6 +70,10 @@ $END
#include "bashgetopt.h"
#include "common.h"
+#if defined (PRI_MACROS_BROKEN)
+# undef PRIdMAX
+#endif
+
#if !defined (PRIdMAX)
# if HAVE_LONG_LONG
# define PRIdMAX "lld"
@@ -91,6 +101,7 @@ extern int errno;
do { \
char *b = 0; \
int nw; \
+ clearerr (stdout); \
if (have_fieldwidth && have_precision) \
nw = asprintf(&b, f, fieldwidth, precision, func); \
else if (have_fieldwidth) \
@@ -106,6 +117,12 @@ extern int errno;
(void)vbadd (b, nw); \
else \
(void)fputs (b, stdout); \
+ if (ferror (stdout)) \
+ { \
+ sh_wrerror (); \
+ clearerr (stdout); \
+ return (EXECUTION_FAILURE); \
+ } \
free (b); \
} \
} while (0)
@@ -132,6 +149,11 @@ extern int errno;
vbuf = 0; \
} \
fflush (stdout); \
+ if (ferror (stdout)) \
+ { \
+ clearerr (stdout); \
+ return (EXECUTION_FAILURE); \
+ } \
return (value); \
} \
while (0)
@@ -139,6 +161,10 @@ extern int errno;
#define SKIP1 "#'-+ 0"
#define LENMODS "hjlLtz"
+#ifndef HAVE_ASPRINTF
+extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
+#endif
+
static void printf_erange __P((char *));
static int printstr __P((char *, char *, int, int, int));
static int tescape __P((char *, char *, int *));
@@ -407,7 +433,9 @@ printf_builtin (list)
r = 0;
p = getstr ();
- if (ansic_shouldquote (p))
+ if (p && *p == 0) /* XXX - getstr never returns null */
+ xp = savestring ("''");
+ else if (ansic_shouldquote (p))
xp = ansic_quote (p, 0, (int *)0);
else
xp = sh_backslash_quote (p);
@@ -526,7 +554,7 @@ static void
printf_erange (s)
char *s;
{
- builtin_error ("warning: %s: %s", s, strerror(ERANGE));
+ builtin_error (_("warning: %s: %s"), s, strerror(ERANGE));
}
/* We duplicate a lot of what printf(3) does here. */
@@ -816,7 +844,7 @@ vbadd (buf, blen)
#ifdef DEBUG
if (strlen (vbuf) != vblen)
- internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, strlen (vbuf));
+ internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
#endif
return vbuf;
diff --git a/builtins/pushd.def b/builtins/pushd.def
index 86c0bddb..86f0b945 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-2004 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -24,11 +24,14 @@ $PRODUCES pushd.c
$BUILTIN pushd
$FUNCTION pushd_builtin
$DEPENDS_ON PUSHD_AND_POPD
-$SHORT_DOC pushd [dir | +N | -N] [-n]
+$SHORT_DOC pushd [-n] [+N | -N | dir]
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 Suppresses the normal change of directory when adding directories
+ to the stack, so only the stack is manipulated.
+
+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.
@@ -37,10 +40,7 @@ directory. With no arguments, exchanges the top two directories.
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
+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.
@@ -49,22 +49,22 @@ $END
$BUILTIN popd
$FUNCTION popd_builtin
$DEPENDS_ON PUSHD_AND_POPD
-$SHORT_DOC popd [+N | -N] [-n]
+$SHORT_DOC popd [-n] [+N | -N]
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
+-n Suppresses the normal change of directory when removing directories
+ from the stack, so only the stack is manipulated.
+
++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
+-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.
$END
@@ -76,18 +76,18 @@ 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 -c flag clears the directory stack by deleting all of the elements.
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.
+that `~/bin' might be displayed as `/homes/bfox/bin'. The -p flag
+causes `dirs' to print the directory stack with one entry per line.
+The -v flag does the same thing, prefixing each directory name with its
+position in the stack.
-+N displays the Nth entry counting from the left of the list shown by
++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
+-N Displays the Nth entry counting from the right of the list shown by
dirs when invoked without options, starting with zero.
$END
@@ -483,9 +483,9 @@ pushd_error (offset, arg)
char *arg;
{
if (offset == 0)
- builtin_error ("directory stack empty");
+ builtin_error (_("directory stack empty"));
else
- sh_erange (arg, "directory stack index");
+ sh_erange (arg, _("directory stack index"));
}
static void
@@ -660,66 +660,66 @@ get_directory_stack (flags)
#ifdef LOADABLE_BUILTIN
char * const dirs_doc[] = {
- 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."),
+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 -c flag clears the directory stack by deleting all of the elements.\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 -p flag\n\
+ causes `dirs' to print the directory stack with one entry per line.\n\
+ The -v flag does the same thing, prefixing each directory name with its\n\
+ position in the stack.\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
};
char * const pushd_doc[] = {
- 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."),
+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 Suppresses the normal change of directory when adding directories\n\
+ to the stack, so only the stack is manipulated.\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\
+ 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
};
char * const popd_doc[] = {
- 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."),
+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 Suppresses the normal change of directory when removing directories\n\
+ from the stack, so only the stack is manipulated.\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\
+ You can see the directory stack with the `dirs' command."),
(char *)NULL
};
diff --git a/builtins/read.def b/builtins/read.def
index e844906c..d6d4c4da 100644
--- a/builtins/read.def
+++ b/builtins/read.def
@@ -23,7 +23,7 @@ $PRODUCES read.c
$BUILTIN read
$FUNCTION read_builtin
-$SHORT_DOC read [-ers] [-u fd] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...]
+$SHORT_DOC read [-ers] [-a array] [-d delim] [-n nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
One line is read from the standard input, or from file descriptor FD if the
-u option is supplied, and the first word is assigned to the first NAME,
the second word to the second NAME, and so on, with leftover words assigned
@@ -329,8 +329,10 @@ read_builtin (list)
}
old_alrm = set_signal_handler (SIGALRM, sigalrm);
add_unwind_protect (reset_alarm, (char *)NULL);
+#if defined (READLINE)
if (edit)
add_unwind_protect (reset_attempted_completion_function, (char *)NULL);
+#endif
alarm (tmout);
}
@@ -532,7 +534,10 @@ add_char:
alist = list_string (input_string, ifs_chars, 0);
if (alist)
{
- word_list_remove_quoted_nulls (alist);
+ if (saw_escape)
+ dequote_list (alist);
+ else
+ word_list_remove_quoted_nulls (alist);
assign_array_var_from_word_list (var, alist, 0);
dispose_words (alist);
}
diff --git a/builtins/reserved.def b/builtins/reserved.def
index e968ec7c..8b598b04 100644
--- a/builtins/reserved.def
+++ b/builtins/reserved.def
@@ -57,12 +57,12 @@ until a break command is executed.
$END
$BUILTIN time
-$SHORT_DOC time [-p] PIPELINE
+$SHORT_DOC time [-p] pipeline
Execute PIPELINE and print a summary of the real time, user CPU time,
and system CPU time spent executing PIPELINE when it terminates.
The return status is the return status of PIPELINE. The `-p' option
-prints the timing summary in a slightly different format. This uses
-the value of the TIMEFORMAT variable as the output format.
+prints the timing summary in the portable Posix format; otherwise, the
+the value of the TIMEFORMAT variable is used as the output format.
$END
$BUILTIN case
@@ -110,7 +110,7 @@ $END
$BUILTIN %
$DOCNAME fg_percent
-$SHORT_DOC JOB_SPEC [&]
+$SHORT_DOC job_spec [&]
Equivalent to the JOB_SPEC argument to the `fg' command. Resume a
stopped or background job. JOB_SPEC can specify either a job name
or a job number. Following JOB_SPEC with a `&' places the job in
@@ -145,7 +145,7 @@ $END
$BUILTIN variables
$DOCNAME variable_help
-$SHORT_DOC variables - Some variable names and meanings
+$SHORT_DOC variables - Names and meanings of some shell variables
BASH_VERSION Version information for this Bash.
CDPATH A colon-separated list of directories to search
for directries given as arguments to `cd'.
diff --git a/builtins/set.def b/builtins/set.def
index 3bb32704..9de094c2 100644
--- a/builtins/set.def
+++ b/builtins/set.def
@@ -60,7 +60,10 @@ extern int no_line_editing;
$BUILTIN set
$FUNCTION set_builtin
-$SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
+$SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]
+Change the value of shell attributes and positional parameters, or display
+the names and values of shell variables. Available
+shell options are:
-a Mark variables which are modified or created for export.
-b Notify of job termination immediately.
-e Exit immediately if a command exits with a non-zero status.
@@ -161,13 +164,13 @@ static int get_edit_mode __P((char *));
static int bash_set_history __P((int, char *));
#endif
-static char *on = "on";
-static char *off = "off";
+static const char * const on = "on";
+static const char * const off = "off";
/* A struct used to match long options for set -o to the corresponding
option letter or internal variable. The functions can be called to
dynamically generate values. */
-struct {
+const struct {
char *name;
int letter;
int *variable;
@@ -578,7 +581,6 @@ set_builtin (list)
WORD_LIST *list;
{
int on_or_off, flag_name, force_assignment, opts_changed;
- WORD_LIST *l;
register char *arg;
char s[3];
diff --git a/builtins/setattr.def b/builtins/setattr.def
index 28102bc4..d4fe9871 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-2004 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -52,7 +52,7 @@ extern int declare_builtin __P((WORD_LIST *));
$BUILTIN export
$FUNCTION export_builtin
-$SHORT_DOC export [-nf] [name[=value] ...] or export -p
+$SHORT_DOC export [-fn] [name[=value] ...] or export -p
NAMEs are marked for automatic export to the environment of
subsequently executed commands. If the -f option is given,
the NAMEs refer to functions. If no NAMEs are given, or if `-p'
diff --git a/builtins/shopt.def b/builtins/shopt.def
index ae100ace..8055473e 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-2005 Free Software Foundation, Inc.
+Copyright (C) 1994-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -23,7 +23,7 @@ $PRODUCES shopt.c
$BUILTIN shopt
$FUNCTION shopt_builtin
-$SHORT_DOC shopt [-pqsu] [-o long-option] optname [optname...]
+$SHORT_DOC shopt [-pqsu] [-o] [optname ...]
Toggle the values of variables controlling optional behavior.
The -s flag means to enable (set) each OPTNAME; the -u flag
unsets each OPTNAME. The -q flag suppresses output; the exit
@@ -68,6 +68,8 @@ extern int glob_ignore_case, match_ignore_case;
extern int hup_on_exit;
extern int xpg_echo;
extern int gnu_error_format;
+extern int check_jobs_at_exit;
+extern int autocd;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
@@ -114,9 +116,11 @@ static struct {
int *value;
shopt_set_func_t *set_func;
} shopt_vars[] = {
+ { "autocd", &autocd, (shopt_set_func_t *)NULL },
{ "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
{ "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
{ "checkhash", &check_hashed_filenames, (shopt_set_func_t *)NULL },
+ { "checkjobs", &check_jobs_at_exit, (shopt_set_func_t *)NULL },
{ "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
{ "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
@@ -170,8 +174,8 @@ static struct {
{ (char *)0, (int *)0, (shopt_set_func_t *)NULL }
};
-static char *on = "on";
-static char *off = "off";
+static const char * const on = "on";
+static const char * const off = "off";
static int find_shopt __P((char *));
static int toggle_shopts __P((int, WORD_LIST *, int));
diff --git a/builtins/source.def b/builtins/source.def
index f9f812f8..0a8eb0ff 100644
--- a/builtins/source.def
+++ b/builtins/source.def
@@ -38,7 +38,6 @@ 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. */
#include <config.h>
@@ -68,9 +67,7 @@ $END
extern int errno;
#endif /* !errno */
-#if defined (RESTRICTED_SHELL)
-extern int restricted;
-#endif
+static void maybe_pop_dollar_vars __P((void));
/* If non-zero, `.' uses $PATH to look up the script to be sourced. */
int source_uses_path = 1;
diff --git a/builtins/suspend.def b/builtins/suspend.def
index d616d775..ea86ae22 100644
--- a/builtins/suspend.def
+++ b/builtins/suspend.def
@@ -48,13 +48,15 @@ $END
#include "common.h"
#include "bashgetopt.h"
+static sighandler suspend_continue __P((int));
+
static SigHandler *old_cont;
#if 0
static SigHandler *old_stop;
#endif
/* Continue handler. */
-sighandler
+static sighandler
suspend_continue (sig)
int sig;
{
diff --git a/builtins/test.def b/builtins/test.def
index e51d00b7..f74cb0aa 100644
--- a/builtins/test.def
+++ b/builtins/test.def
@@ -1,7 +1,7 @@
This file is test.def, from which is created test.c.
It implements the builtin "test" in Bash.
-Copyright (C) 1987-2002 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -109,6 +109,7 @@ $END
#endif
#include "../bashansi.h"
+#include "../bashintl.h"
#include "../shell.h"
#include "../test.h"
@@ -131,7 +132,7 @@ test_builtin (list)
{
if (this_command_name[0] == '[' && !this_command_name[1])
{
- builtin_error ("missing `]'");
+ builtin_error (_("missing `]'"));
return (EX_BADUSAGE);
}
diff --git a/builtins/times.def b/builtins/times.def
index 22304fc2..db54558d 100644
--- a/builtins/times.def
+++ b/builtins/times.def
@@ -24,8 +24,8 @@ $PRODUCES times.c
$BUILTIN times
$FUNCTION times_builtin
$SHORT_DOC times
-Print the accumulated user and system times for processes run from
-the shell.
+Print the accumulated user and system times for the shell and all of its
+child processes.
$END
#include <config.h>
diff --git a/builtins/trap.def b/builtins/trap.def
index 426833a1..9e7d7636 100644
--- a/builtins/trap.def
+++ b/builtins/trap.def
@@ -23,14 +23,14 @@ $PRODUCES trap.c
$BUILTIN trap
$FUNCTION trap_builtin
-$SHORT_DOC trap [-lp] [arg signal_spec ...]
+$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 (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 DEBUG, ARG is executed before 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
@@ -87,7 +87,7 @@ int
trap_builtin (list)
WORD_LIST *list;
{
- int list_signal_names, display, result, opt, first_signal;
+ int list_signal_names, display, result, opt;
list_signal_names = display = 0;
result = EXECUTION_SUCCESS;
diff --git a/builtins/type.def b/builtins/type.def
index d03ccb2d..39a43162 100644
--- a/builtins/type.def
+++ b/builtins/type.def
@@ -390,7 +390,7 @@ describe_command (command, dflags)
if (dflags & CDESC_TYPE)
puts ("file");
else if (dflags & CDESC_SHORTDESC)
- printf ("%s is %s\n", command, full_path);
+ printf (_("%s is %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 17898699..2307c465 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-2005 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -24,7 +24,7 @@ $PRODUCES ulimit.c
$BUILTIN ulimit
$FUNCTION ulimit_builtin
$DEPENDS_ON !_MINIX
-$SHORT_DOC ulimit [-SHacdfilmnpqstuvx] [limit]
+$SHORT_DOC ulimit [-SHacdefilmnpqrstuvx] [limit]
Ulimit provides control over the resources available to processes
started by the shell, on systems that allow such control. If an
option is given, it is interpreted as follows:
@@ -35,7 +35,7 @@ option is given, it is interpreted as follows:
-c the maximum size of core files created
-d the maximum size of a process's data segment
-e the maximum scheduling priority (`nice')
- -f the maximum size of files created by the shell
+ -f the maximum size of files written by the shell and its children
-i the maximum number of pending signals
-l the maximum size a process may lock into memory
-m the maximum resident set size
@@ -193,8 +193,8 @@ typedef struct {
int option; /* The ulimit option for this limit. */
int parameter; /* Parameter to pass to get_limit (). */
int block_factor; /* Blocking factor for specific limit. */
- char *description; /* Descriptive string to output. */
- char *units; /* scale */
+ const char * const description; /* Descriptive string to output. */
+ const char * const units; /* scale */
} RESOURCE_LIMITS;
static RESOURCE_LIMITS limits[] = {
@@ -430,7 +430,7 @@ ulimit_internal (cmd, cmdarg, mode, multiple)
if ((real_limit / block_factor) != limit)
{
- sh_erange (cmdarg, "limit");
+ sh_erange (cmdarg, _("limit"));
return (EXECUTION_FAILURE);
}
}
@@ -740,7 +740,7 @@ set_all_limits (mode, newlim)
for (retval = i = 0; limits[i].option > 0; i++)
if (set_limit (i, newlim, mode) < 0)
{
- builtin_error ("%s: cannot modify limit: %s", limits[i].description,
+ builtin_error (_("%s: cannot modify limit: %s"), limits[i].description,
strerror (errno));
retval = 1;
}
diff --git a/builtins/wait.def b/builtins/wait.def
index 22a92bea..94e525f5 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-2005 Free Software Foundation, Inc.
+Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -37,8 +37,7 @@ $DEPENDS_ON !JOB_CONTROL
$SHORT_DOC wait [n]
Wait for the specified process and report its termination status. If
N is not given, all currently active child processes are waited for,
-and the return code is zero. N is a process ID; if it is not given,
-all child processes of the shell are waited for.
+and the return code is zero. N must be a process ID.
$END
#include <config.h>
@@ -59,7 +58,6 @@ $END
#include "common.h"
#include "bashgetopt.h"
-extern int interrupt_immediately;
extern int wait_signal_received;
procenv_t wait_intr_buf;