commit bash-20061214 snapshot

This commit is contained in:
Chet Ramey
2011-12-07 09:01:35 -05:00
parent 10a5f6b4cc
commit 258e3d4698
109 changed files with 19368 additions and 4220 deletions
+38
View File
@@ -14010,3 +14010,41 @@ lib/sh/snprintf.c
- make sure number() sets the FL_UNSIGNED flag for %x and %X, so
fmtulong treats them as unsigned numbers. Fixes bug reported by
James Botte <James.M.Botte@lowes.com>
12/13
-----
lib/readline/util.c
- new function, _rl_ttymsg, for internal warning messages -- does
redisplay after printing message
- new function, _rl_errmsg, for internal warning/error messages --
does not do redisplay after printing message
lib/readline/rlprivate.h
- new extern declaration for _rl_ttymsg, _rl_errmsg
lib/readline/{bind,callback,complete,display,rltty}.c
- use _rl_ttymsg/_rl_errmsg instead of direct writes to stderr
lib/sh/tmpfile.c
- in get_tmpdir(), make sure that $TMPDIR names a writable directory;
otherwise skip it. This catches names longer than PATH_MAX, but in
case it doesn't test that the length does not exceed PATH_MAX. Fixes
heap overrun bug reported by Eric Blake <ebb9@byu.net>
12/16
-----
builtin/{set,declare,shopt,trap,wait,bind,complete,enable,fc,history,read,setattr}.def
doc/{bash.1,bashref.texi}
- improvements and clarifications to the help text associated with
several builtins, in some cases bringing them into line with the
man page text. From Benno Schulenberg <bensberg@justemail.net>
doc/{bash.1,bashref.texi}
- add `E' and `T' to the synopsis of the set builtin.
From Benno Schulenberg <bensberg@justemail.net>
builtins/{break,exit,fg_bg,hash,jobs,type,ulimit}.def
builtins/{common,evalfile}.c
{error,expr,jobs,mksyntax,nojobs,shell,subst,version,siglist}.c
- add gettextizing marks to untranslated strings
From Benno Schulenberg <bensberg@justemail.net>
+42 -3
View File
@@ -13774,7 +13774,7 @@ shell.c
<mike.stroyan@hp.com>
doc/bashref.texi
- fix typos and misspellings sent in by Brian Gough
- fixes for typos and misspellings sent in by Brian Gough
10/24
-----
@@ -13829,7 +13829,7 @@ execute_cmd.c
11/7
----
lib/tilde/tilde.c
lib/readline/{util,undo,callback,input,isearch,kill
lib/readline/{util,undo,callback,input,isearch,kill}.c
- make sure that memory allocated with xmalloc is freed with xfree
11/9
@@ -14008,4 +14008,43 @@ builtins/evalfile.c
----
lib/sh/snprintf.c
- make sure number() sets the FL_UNSIGNED flag for %x and %X, so
fmtulong treats them as unsigned numbers
fmtulong treats them as unsigned numbers. Fixes bug reported by
James Botte <James.M.Botte@lowes.com>
12/13
-----
lib/readline/util.c
- new function, _rl_ttymsg, for internal warning messages -- does
redisplay after printing message
- new function, _rl_errmsg, for internal warning/error messages --
does not do redisplay after printing message
lib/readline/rlprivate.h
- new extern declaration for _rl_ttymsg, _rl_errmsg
lib/readline/{bind,callback,complete,display,rltty}.c
- use _rl_ttymsg/_rl_errmsg instead of direct writes to stderr
lib/sh/tmpfile.c
- in get_tmpdir(), make sure that $TMPDIR names a writable directory;
otherwise skip it. This catches names longer than PATH_MAX, but in
case it doesn't test that the length does not exceed PATH_MAX. Fixes
heap overrun bug reported by Eric Blake <ebb9@byu.net>
12/16
-----
builtin/{set,declare,shopt,trap,wait,bind,complete,enable,fc,history,read,setattr}.def
doc/{bash.1,bashref.texi}
- improvements and clarifications to the help text associated with
several builtins, in some cases bringing them into line with the
man page text. From Benno Schulenberg <bensberg@justemail.net>
doc/{bash.1,bashref.texi}
- add `E' and `T' to the synopsis of the set builtin.
From Benno Schulenberg <bensberg@justemail.net>
builtins/{break,exit,fg_bg,hash,jobs,type,ulimit}.def
builtins/{common,evalfile}.c
{error,expr,jobs,mksyntax,nojobs,shell,subst,version}.c
- add gettextizing marks to untranslated strings
From Benno Schulenberg <bensberg@justemail.net>
+10 -10
View File
@@ -29,7 +29,7 @@ $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
@@ -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)
+10 -10
View File
@@ -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.
@@ -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)
+3 -3
View File
@@ -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);
}
+132
View File
@@ -0,0 +1,132 @@
This file is break.def, from which is created break.c.
It implements the builtins "break" and "continue" in Bash.
Copyright (C) 1987-2006 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 break.c
$BUILTIN break
$FUNCTION break_builtin
$SHORT_DOC break [n]
Exit from within a FOR, WHILE or UNTIL loop. If N is specified,
break N levels.
$END
#include <config.h>
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include "../bashintl.h"
#include "../shell.h"
#include "common.h"
extern char *this_command_name;
extern int posixly_correct;
static int check_loop_level __P((void));
/* The depth of while's and until's. */
int loop_level = 0;
/* Non-zero when a "break" instruction is encountered. */
int breaking = 0;
/* Non-zero when we have encountered a continue instruction. */
int continuing = 0;
/* Set up to break x levels, where x defaults to 1, but can be specified
as the first argument. */
int
break_builtin (list)
WORD_LIST *list;
{
intmax_t newbreak;
if (check_loop_level () == 0)
return (EXECUTION_SUCCESS);
newbreak = get_numeric_arg (list, 1);
if (newbreak <= 0)
{
sh_erange (list->word->word, _("loop count"));
breaking = loop_level;
return (EXECUTION_FAILURE);
}
if (newbreak > loop_level)
newbreak = loop_level;
breaking = newbreak;
return (EXECUTION_SUCCESS);
}
$BUILTIN continue
$FUNCTION continue_builtin
$SHORT_DOC continue [n]
Resume the next iteration of the enclosing FOR, WHILE or UNTIL loop.
If N is specified, resume at the N-th enclosing loop.
$END
/* Set up to continue x levels, where x defaults to 1, but can be specified
as the first argument. */
int
continue_builtin (list)
WORD_LIST *list;
{
intmax_t newcont;
if (check_loop_level () == 0)
return (EXECUTION_SUCCESS);
newcont = get_numeric_arg (list, 1);
if (newcont <= 0)
{
sh_erange (list->word->word, _("loop count"));
breaking = loop_level;
return (EXECUTION_FAILURE);
}
if (newcont > loop_level)
newcont = loop_level;
continuing = newcont;
return (EXECUTION_SUCCESS);
}
/* Return non-zero if a break or continue command would be okay.
Print an error message if break or continue is meaningless here. */
static int
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"));
#endif /* BREAK_COMPLAINS */
return (loop_level);
}
+3 -3
View File
@@ -1,4 +1,4 @@
/* 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.
@@ -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);
}
+808
View File
@@ -0,0 +1,808 @@
/* Copyright (C) 1987-2005 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. */
#include <config.h>
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include <stdio.h>
#include <chartypes.h>
#include "../bashtypes.h"
#include "posixstat.h"
#include <signal.h>
#include <errno.h>
#if defined (PREFER_STDARG)
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include "../bashansi.h"
#include "../bashintl.h"
#include "../shell.h"
#include "maxpath.h"
#include "../flags.h"
#include "../jobs.h"
#include "../builtins.h"
#include "../input.h"
#include "../execute_cmd.h"
#include "../trap.h"
#include "bashgetopt.h"
#include "common.h"
#include "builtext.h"
#include <tilde/tilde.h>
#if defined (HISTORY)
# include "../bashhist.h"
#endif
#if !defined (errno)
extern int errno;
#endif /* !errno */
extern int indirection_level, subshell_environment;
extern int line_number;
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;
/* Used by some builtins and the mainline code. */
sh_builtin_func_t *last_shell_builtin = (sh_builtin_func_t *)NULL;
sh_builtin_func_t *this_shell_builtin = (sh_builtin_func_t *)NULL;
/* **************************************************************** */
/* */
/* Error reporting, usage, and option processing */
/* */
/* **************************************************************** */
/* This is a lot like report_error (), but it is for shell builtins
instead of shell control structures, and it won't ever exit the
shell. */
void
#if defined (PREFER_STDARG)
builtin_error (const char *format, ...)
#else
builtin_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
char *name;
name = get_name_for_error ();
fprintf (stderr, "%s: ", name);
if (interactive_shell == 0)
fprintf (stderr, _("line %d: "), executing_line_number ());
if (this_command_name && *this_command_name)
fprintf (stderr, "%s: ", this_command_name);
SH_VA_START (args, format);
vfprintf (stderr, format, args);
va_end (args);
fprintf (stderr, "\n");
}
/* Print a usage summary for the currently-executing builtin command. */
void
builtin_usage ()
{
if (this_command_name && *this_command_name)
fprintf (stderr, _("%s: usage: "), this_command_name);
fprintf (stderr, "%s\n", current_builtin->short_doc);
fflush (stderr);
}
/* Return if LIST is NULL else barf and jump to top_level. Used by some
builtins that do not accept arguments. */
void
no_args (list)
WORD_LIST *list;
{
if (list)
{
builtin_error (_("too many arguments"));
jump_to_top_level (DISCARD);
}
}
/* Check that no options were given to the currently-executing builtin,
and return 0 if there were options. */
int
no_options (list)
WORD_LIST *list;
{
reset_internal_getopt ();
if (internal_getopt (list, "") != -1)
{
builtin_usage ();
return (1);
}
return (0);
}
void
sh_needarg (s)
char *s;
{
builtin_error (_("%s: option requires an argument"), s);
}
void
sh_neednumarg (s)
char *s;
{
builtin_error (_("%s: numeric argument required"), s);
}
void
sh_notfound (s)
char *s;
{
builtin_error (_("%s: not found"), s);
}
/* Function called when one of the builtin commands detects an invalid
option. */
void
sh_invalidopt (s)
char *s;
{
builtin_error (_("%s: invalid option"), s);
}
void
sh_invalidoptname (s)
char *s;
{
builtin_error (_("%s: invalid option name"), s);
}
void
sh_invalidid (s)
char *s;
{
builtin_error (_("`%s': not a valid identifier"), s);
}
void
sh_invalidnum (s)
char *s;
{
builtin_error (_("%s: invalid number"), s);
}
void
sh_invalidsig (s)
char *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);
}
void
sh_readonly (s)
const char *s;
{
builtin_error (_("%s: readonly variable"), s);
}
void
sh_erange (s, desc)
char *s, *desc;
{
if (s)
builtin_error (_("%s: %s out of range"), s, desc ? desc : _("argument"));
else
builtin_error (_("%s out of range"), desc ? desc : _("argument"));
}
#if defined (JOB_CONTROL)
void
sh_badjob (s)
char *s;
{
builtin_error (_("%s: no such job"), s);
}
void
sh_nojobs (s)
char *s;
{
if (s)
builtin_error (_("%s: no job control"), s);
else
builtin_error (_("no job control"));
}
#endif
#if defined (RESTRICTED_SHELL)
void
sh_restricted (s)
char *s;
{
if (s)
builtin_error (_("%s: restricted"), s);
else
builtin_error (_("restricted"));
}
#endif
void
sh_notbuiltin (s)
char *s;
{
builtin_error (_("%s: not a shell builtin"), s);
}
void
sh_wrerror ()
{
builtin_error (_("write error: %s"), strerror (errno));
}
/* **************************************************************** */
/* */
/* Shell positional parameter manipulation */
/* */
/* **************************************************************** */
/* Convert a WORD_LIST into a C-style argv. Return the number of elements
in the list in *IP, if IP is non-null. A convenience function for
loadable builtins; also used by `test'. */
char **
make_builtin_argv (list, ip)
WORD_LIST *list;
int *ip;
{
char **argv;
argv = strvec_from_word_list (list, 0, 1, ip);
argv[0] = this_command_name;
return argv;
}
/* Remember LIST in $0 ... $9, and REST_OF_ARGS. If DESTRUCTIVE is
non-zero, then discard whatever the existing arguments are, else
only discard the ones that are to be replaced. */
void
remember_args (list, destructive)
WORD_LIST *list;
int destructive;
{
register int i;
for (i = 1; i < 10; i++)
{
if ((destructive || list) && dollar_vars[i])
{
free (dollar_vars[i]);
dollar_vars[i] = (char *)NULL;
}
if (list)
{
dollar_vars[i] = savestring (list->word->word);
list = list->next;
}
}
/* If arguments remain, assign them to REST_OF_ARGS.
Note that copy_word_list (NULL) returns NULL, and
that dispose_words (NULL) does nothing. */
if (destructive || list)
{
dispose_words (rest_of_args);
rest_of_args = copy_word_list (list);
}
if (destructive)
set_dollar_vars_changed ();
}
static int changed_dollar_vars;
/* Have the dollar variables been reset to new values since we last
checked? */
int
dollar_vars_changed ()
{
return (changed_dollar_vars);
}
void
set_dollar_vars_unchanged ()
{
changed_dollar_vars = 0;
}
void
set_dollar_vars_changed ()
{
if (variable_context)
changed_dollar_vars |= ARGS_FUNC;
else if (this_shell_builtin == set_builtin)
changed_dollar_vars |= ARGS_SETBLTIN;
else
changed_dollar_vars |= ARGS_INVOC;
}
/* **************************************************************** */
/* */
/* Validating numeric input and arguments */
/* */
/* **************************************************************** */
/* Read a numeric arg for this_command_name, the name of the shell builtin
that wants it. LIST is the word list that the arg is to come from.
Accept only the numeric argument; report an error if other arguments
follow. If FATAL is true, call throw_to_top_level, which exits the
shell; if not, call jump_to_top_level (DISCARD), which aborts the
current command. */
intmax_t
get_numeric_arg (list, fatal)
WORD_LIST *list;
int fatal;
{
intmax_t count = 1;
if (list && list->word && ISOPTION (list->word->word, '-'))
list = list->next;
if (list)
{
register char *arg;
arg = list->word->word;
if (arg == 0 || (legal_number (arg, &count) == 0))
{
sh_neednumarg (list->word->word);
if (fatal)
throw_to_top_level ();
else
jump_to_top_level (DISCARD);
}
no_args (list->next);
}
return (count);
}
/* Get an eight-bit status value from LIST */
int
get_exitstat (list)
WORD_LIST *list;
{
int status;
intmax_t sval;
char *arg;
if (list && list->word && ISOPTION (list->word->word, '-'))
list = list->next;
if (list == 0)
return (last_command_exit_value);
arg = list->word->word;
if (arg == 0 || legal_number (arg, &sval) == 0)
{
sh_neednumarg (list->word->word ? list->word->word : "`'");
return 255;
}
no_args (list->next);
status = sval & 255;
return status;
}
/* Return the octal number parsed from STRING, or -1 to indicate
that the string contained a bad number. */
int
read_octal (string)
char *string;
{
int result, digits;
result = digits = 0;
while (*string && ISOCTAL (*string))
{
digits++;
result = (result * 8) + (*string++ - '0');
if (result > 0777)
return -1;
}
if (digits == 0 || *string)
result = -1;
return (result);
}
/* **************************************************************** */
/* */
/* Manipulating the current working directory */
/* */
/* **************************************************************** */
/* Return a consed string which is the current working directory.
FOR_WHOM is the name of the caller for error printing. */
char *the_current_working_directory = (char *)NULL;
char *
get_working_directory (for_whom)
char *for_whom;
{
if (no_symbolic_links)
{
FREE (the_current_working_directory);
the_current_working_directory = (char *)NULL;
}
if (the_current_working_directory == 0)
{
the_current_working_directory = getcwd (0, 0);
if (the_current_working_directory == 0)
{
fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"),
(for_whom && *for_whom) ? for_whom : get_name_for_error (),
_(bash_getcwd_errstr), strerror (errno));
return (char *)NULL;
}
}
return (savestring (the_current_working_directory));
}
/* Make NAME our internal idea of the current working directory. */
void
set_working_directory (name)
char *name;
{
FREE (the_current_working_directory);
the_current_working_directory = savestring (name);
}
/* **************************************************************** */
/* */
/* Job control support functions */
/* */
/* **************************************************************** */
#if defined (JOB_CONTROL)
int
get_job_by_name (name, flags)
const char *name;
int flags;
{
register int i, wl, cl, match, job;
register PROCESS *p;
register JOB *j;
job = NO_JOB;
wl = strlen (name);
for (i = js.j_jobslots - 1; i >= 0; i--)
{
j = get_job_by_jid (i);
if (j == 0 || ((flags & JM_STOPPED) && J_JOBSTATE(j) != JSTOPPED))
continue;
p = j->pipe;
do
{
if (flags & JM_EXACT)
{
cl = strlen (p->command);
match = STREQN (p->command, name, cl);
}
else if (flags & JM_SUBSTRING)
match = strindex (p->command, name) != (char *)0;
else
match = STREQN (p->command, name, wl);
if (match == 0)
{
p = p->next;
continue;
}
else if (flags & JM_FIRSTMATCH)
return i; /* return first match */
else if (job != NO_JOB)
{
if (this_shell_builtin)
builtin_error (_("%s: ambiguous job spec"), name);
else
report_error (_("%s: ambiguous job spec"), name);
return (DUP_JOB);
}
else
job = i;
}
while (p != j->pipe);
}
return (job);
}
/* Return the job spec found in LIST. */
int
get_job_spec (list)
WORD_LIST *list;
{
register char *word;
int job, jflags;
if (list == 0)
return (js.j_current);
word = list->word->word;
if (*word == '\0')
return (NO_JOB);
if (*word == '%')
word++;
if (DIGIT (*word) && all_digits (word))
{
job = atoi (word);
return (job > js.j_jobslots ? NO_JOB : job - 1);
}
jflags = 0;
switch (*word)
{
case 0:
case '%':
case '+':
return (js.j_current);
case '-':
return (js.j_previous);
case '?': /* Substring search requested. */
jflags |= JM_SUBSTRING;
word++;
/* FALLTHROUGH */
default:
return get_job_by_name (word, jflags);
}
}
#endif /* JOB_CONTROL */
/*
* NOTE: `kill' calls this function with forcecols == 0
*/
int
display_signal_list (list, forcecols)
WORD_LIST *list;
int forcecols;
{
register int i, column;
char *name;
int result, signum, dflags;
intmax_t lsignum;
result = EXECUTION_SUCCESS;
if (!list)
{
for (i = 1, column = 0; i < NSIG; i++)
{
name = signal_name (i);
if (STREQN (name, "SIGJUNK", 7) || STREQN (name, "Unknown", 7))
continue;
if (posixly_correct && !forcecols)
{
/* This is for the kill builtin. POSIX.2 says the signal names
are displayed without the `SIG' prefix. */
if (STREQN (name, "SIG", 3))
name += 3;
printf ("%s%s", name, (i == NSIG - 1) ? "" : " ");
}
else
{
printf ("%2d) %s", i, name);
if (++column < 4)
printf ("\t");
else
{
printf ("\n");
column = 0;
}
}
}
if ((posixly_correct && !forcecols) || column != 0)
printf ("\n");
return result;
}
/* List individual signal names or numbers. */
while (list)
{
if (legal_number (list->word->word, &lsignum))
{
/* This is specified by Posix.2 so that exit statuses can be
mapped into signal numbers. */
if (lsignum > 128)
lsignum -= 128;
if (lsignum < 0 || lsignum >= NSIG)
{
sh_invalidsig (list->word->word);
result = EXECUTION_FAILURE;
list = list->next;
continue;
}
signum = lsignum;
name = signal_name (signum);
if (STREQN (name, "SIGJUNK", 7) || STREQN (name, "Unknown", 7))
{
list = list->next;
continue;
}
#if defined (JOB_CONTROL)
/* POSIX.2 says that `kill -l signum' prints the signal name without
the `SIG' prefix. */
printf ("%s\n", (this_shell_builtin == kill_builtin) ? name + 3 : name);
#else
printf ("%s\n", name);
#endif
}
else
{
dflags = DSIG_NOCASE;
if (posixly_correct == 0 || this_shell_builtin != kill_builtin)
dflags |= DSIG_SIGPREFIX;
signum = decode_signal (list->word->word, dflags);
if (signum == NO_SIG)
{
sh_invalidsig (list->word->word);
result = EXECUTION_FAILURE;
list = list->next;
continue;
}
printf ("%d\n", signum);
}
list = list->next;
}
return (result);
}
/* **************************************************************** */
/* */
/* Finding builtin commands and their functions */
/* */
/* **************************************************************** */
/* Perform a binary search and return the address of the builtin function
whose name is NAME. If the function couldn't be found, or the builtin
is disabled or has no function associated with it, return NULL.
Return the address of the builtin.
DISABLED_OKAY means find it even if the builtin is disabled. */
struct builtin *
builtin_address_internal (name, disabled_okay)
char *name;
int disabled_okay;
{
int hi, lo, mid, j;
hi = num_shell_builtins - 1;
lo = 0;
while (lo <= hi)
{
mid = (lo + hi) / 2;
j = shell_builtins[mid].name[0] - name[0];
if (j == 0)
j = strcmp (shell_builtins[mid].name, name);
if (j == 0)
{
/* It must have a function pointer. It must be enabled, or we
must have explicitly allowed disabled functions to be found,
and it must not have been deleted. */
if (shell_builtins[mid].function &&
((shell_builtins[mid].flags & BUILTIN_DELETED) == 0) &&
((shell_builtins[mid].flags & BUILTIN_ENABLED) || disabled_okay))
return (&shell_builtins[mid]);
else
return ((struct builtin *)NULL);
}
if (j > 0)
hi = mid - 1;
else
lo = mid + 1;
}
return ((struct builtin *)NULL);
}
/* Return the pointer to the function implementing builtin command NAME. */
sh_builtin_func_t *
find_shell_builtin (name)
char *name;
{
current_builtin = builtin_address_internal (name, 0);
return (current_builtin ? current_builtin->function : (sh_builtin_func_t *)NULL);
}
/* Return the address of builtin with NAME, whether it is enabled or not. */
sh_builtin_func_t *
builtin_address (name)
char *name;
{
current_builtin = builtin_address_internal (name, 1);
return (current_builtin ? current_builtin->function : (sh_builtin_func_t *)NULL);
}
/* Return the function implementing the builtin NAME, but only if it is a
POSIX.2 special builtin. */
sh_builtin_func_t *
find_special_builtin (name)
char *name;
{
current_builtin = builtin_address_internal (name, 0);
return ((current_builtin && (current_builtin->flags & SPECIAL_BUILTIN)) ?
current_builtin->function :
(sh_builtin_func_t *)NULL);
}
static int
shell_builtin_compare (sbp1, sbp2)
struct builtin *sbp1, *sbp2;
{
int result;
if ((result = sbp1->name[0] - sbp2->name[0]) == 0)
result = strcmp (sbp1->name, sbp2->name);
return (result);
}
/* Sort the table of shell builtins so that the binary search will work
in find_shell_builtin. */
void
initialize_shell_builtins ()
{
qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
(QSFUNC *)shell_builtin_compare);
}
+5 -3
View File
@@ -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>
@@ -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
+624
View File
@@ -0,0 +1,624 @@
This file is complete.def, from which is created complete.c.
It implements the builtins "complete" and "compgen" in Bash.
Copyright (C) 1999-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES complete.c
$BUILTIN complete
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION complete_builtin
$SHORT_DOC complete [-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>
#include <stdio.h>
#include "../bashtypes.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "../bashansi.h"
#include "../bashintl.h"
#include "../shell.h"
#include "../builtins.h"
#include "../pcomplete.h"
#include "../bashline.h"
#include "common.h"
#include "bashgetopt.h"
#include <readline/readline.h>
#define STRDUP(x) ((x) ? savestring (x) : (char *)NULL)
static int find_compact __P((char *));
static int find_compopt __P((char *));
static int build_actions __P((WORD_LIST *, int *, int *, unsigned long *, unsigned long *));
static int remove_cmd_completions __P((WORD_LIST *));
static int print_one_completion __P((char *, COMPSPEC *));
static int print_compitem __P((BUCKET_CONTENTS *));
static void print_all_completions __P((void));
static int print_cmd_completions __P((WORD_LIST *));
static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
static struct _compacts {
char *actname;
int actflag;
int actopt;
} compacts[] = {
{ "alias", CA_ALIAS, 'a' },
{ "arrayvar", CA_ARRAYVAR, 0 },
{ "binding", CA_BINDING, 0 },
{ "builtin", CA_BUILTIN, 'b' },
{ "command", CA_COMMAND, 'c' },
{ "directory", CA_DIRECTORY, 'd' },
{ "disabled", CA_DISABLED, 0 },
{ "enabled", CA_ENABLED, 0 },
{ "export", CA_EXPORT, 'e' },
{ "file", CA_FILE, 'f' },
{ "function", CA_FUNCTION, 0 },
{ "helptopic", CA_BUILTIN, 0 }, /* for now */
{ "hostname", CA_HOSTNAME, 0 },
{ "group", CA_GROUP, 'g' },
{ "job", CA_JOB, 'j' },
{ "keyword", CA_KEYWORD, 'k' },
{ "running", CA_RUNNING, 0 },
{ "service", CA_SERVICE, 's' },
{ "setopt", CA_SETOPT, 0 },
{ "shopt", CA_SHOPT, 0 },
{ "signal", CA_SIGNAL, 0 },
{ "stopped", CA_STOPPED, 0 },
{ "user", CA_USER, 'u' },
{ "variable", CA_VARIABLE, 'v' },
{ (char *)NULL, 0, 0 },
};
/* This should be a STRING_INT_ALIST */
static struct _compopt {
char *optname;
int optflag;
} compopts[] = {
{ "bashdefault", COPT_BASHDEFAULT },
{ "default", COPT_DEFAULT },
{ "dirnames", COPT_DIRNAMES },
{ "filenames",COPT_FILENAMES},
{ "nospace", COPT_NOSPACE },
{ "plusdirs", COPT_PLUSDIRS },
{ (char *)NULL, 0 },
};
static int
find_compact (name)
char *name;
{
register int i;
for (i = 0; compacts[i].actname; i++)
if (STREQ (name, compacts[i].actname))
return i;
return -1;
}
static int
find_compopt (name)
char *name;
{
register int i;
for (i = 0; compopts[i].optname; i++)
if (STREQ (name, compopts[i].optname))
return i;
return -1;
}
/* Build the actions and compspec options from the options specified in LIST.
ACTP is a pointer to an unsigned long in which to place the bitmap of
actions. OPTP is a pointer to an unsigned long in which to place the
btmap of compspec options (arguments to `-o'). PP, if non-null, gets 1
if -p is supplied; RP, if non-null, gets 1 if -r is supplied.
If either is null, the corresponding option generates an error.
This also sets variables corresponding to options that take arguments as
a side effect; the caller should ensure that those variables are set to
NULL before calling build_actions. Return value:
EX_USAGE = bad option
EXECUTION_SUCCESS = some options supplied
EXECUTION_FAILURE = no options supplied
*/
static int
build_actions (list, pp, rp, actp, optp)
WORD_LIST *list;
int *pp, *rp;
unsigned long *actp, *optp;
{
int opt, ind, opt_given;
unsigned long acts, copts;
acts = copts = (unsigned long)0L;
opt_given = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:")) != -1)
{
opt_given = 1;
switch (opt)
{
case 'r':
if (rp)
{
*rp = 1;
break;
}
else
{
sh_invalidopt ("-r");
builtin_usage ();
return (EX_USAGE);
}
case 'p':
if (pp)
{
*pp = 1;
break;
}
else
{
sh_invalidopt ("-p");
builtin_usage ();
return (EX_USAGE);
}
case 'a':
acts |= CA_ALIAS;
break;
case 'b':
acts |= CA_BUILTIN;
break;
case 'c':
acts |= CA_COMMAND;
break;
case 'd':
acts |= CA_DIRECTORY;
break;
case 'e':
acts |= CA_EXPORT;
break;
case 'f':
acts |= CA_FILE;
break;
case 'g':
acts |= CA_GROUP;
break;
case 'j':
acts |= CA_JOB;
break;
case 'k':
acts |= CA_KEYWORD;
break;
case 's':
acts |= CA_SERVICE;
break;
case 'u':
acts |= CA_USER;
break;
case 'v':
acts |= CA_VARIABLE;
break;
case 'o':
ind = find_compopt (list_optarg);
if (ind < 0)
{
sh_invalidoptname (list_optarg);
return (EX_USAGE);
}
copts |= compopts[ind].optflag;
break;
case 'A':
ind = find_compact (list_optarg);
if (ind < 0)
{
builtin_error (_("%s: invalid action name"), list_optarg);
return (EX_USAGE);
}
acts |= compacts[ind].actflag;
break;
case 'C':
Carg = list_optarg;
break;
case 'F':
Farg = list_optarg;
break;
case 'G':
Garg = list_optarg;
break;
case 'P':
Parg = list_optarg;
break;
case 'S':
Sarg = list_optarg;
break;
case 'W':
Warg = list_optarg;
break;
case 'X':
Xarg = list_optarg;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
*actp = acts;
*optp = copts;
return (opt_given ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
/* Add, remove, and display completion specifiers. */
int
complete_builtin (list)
WORD_LIST *list;
{
int opt_given, pflag, rflag, rval;
unsigned long acts, copts;
COMPSPEC *cs;
if (list == 0)
{
print_all_completions ();
return (EXECUTION_SUCCESS);
}
opt_given = pflag = rflag = 0;
acts = copts = (unsigned long)0L;
Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
cs = (COMPSPEC *)NULL;
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
as a side effect if they are supplied as options. */
rval = build_actions (list, &pflag, &rflag, &acts, &copts);
if (rval == EX_USAGE)
return (rval);
opt_given = rval != EXECUTION_FAILURE;
list = loptend;
/* -p overrides everything else */
if (pflag || (list == 0 && opt_given == 0))
{
if (list == 0)
{
print_all_completions ();
return (EXECUTION_SUCCESS);
}
return (print_cmd_completions (list));
}
/* next, -r overrides everything else. */
if (rflag)
{
if (list == 0)
{
progcomp_flush ();
return (EXECUTION_SUCCESS);
}
return (remove_cmd_completions (list));
}
if (list == 0 && opt_given)
{
builtin_usage ();
return (EX_USAGE);
}
/* If we get here, we need to build a compspec and add it for each
remaining argument. */
cs = compspec_create ();
cs->actions = acts;
cs->options = copts;
cs->globpat = STRDUP (Garg);
cs->words = STRDUP (Warg);
cs->prefix = STRDUP (Parg);
cs->suffix = STRDUP (Sarg);
cs->funcname = STRDUP (Farg);
cs->command = STRDUP (Carg);
cs->filterpat = STRDUP (Xarg);
for (rval = EXECUTION_SUCCESS ; list; list = list->next)
{
/* Add CS as the compspec for the specified commands. */
if (progcomp_insert (list->word->word, cs) == 0)
rval = EXECUTION_FAILURE;
}
return (rval);
}
static int
remove_cmd_completions (list)
WORD_LIST *list;
{
WORD_LIST *l;
int ret;
for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next)
{
if (progcomp_remove (l->word->word) == 0)
{
builtin_error (_("%s: no completion specification"), l->word->word);
ret = EXECUTION_FAILURE;
}
}
return ret;
}
#define SQPRINTARG(a, f) \
do { \
if (a) \
{ \
x = sh_single_quote (a); \
printf ("%s %s ", f, x); \
free (x); \
} \
} while (0)
#define PRINTARG(a, f) \
do { \
if (a) \
printf ("%s %s ", f, a); \
} while (0)
#define PRINTOPT(a, f) \
do { \
if (acts & a) \
printf ("%s ", f); \
} while (0)
#define PRINTACT(a, f) \
do { \
if (acts & a) \
printf ("-A %s ", f); \
} while (0)
#define PRINTCOMPOPT(a, f) \
do { \
if (copts & a) \
printf ("-o %s ", f); \
} while (0)
static int
print_one_completion (cmd, cs)
char *cmd;
COMPSPEC *cs;
{
unsigned long acts, copts;
char *x;
printf ("complete ");
copts = cs->options;
/* First, print the -o options. */
PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");
PRINTCOMPOPT (COPT_DEFAULT, "default");
PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
PRINTCOMPOPT (COPT_FILENAMES, "filenames");
PRINTCOMPOPT (COPT_NOSPACE, "nospace");
PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
acts = cs->actions;
/* simple flags next */
PRINTOPT (CA_ALIAS, "-a");
PRINTOPT (CA_BUILTIN, "-b");
PRINTOPT (CA_COMMAND, "-c");
PRINTOPT (CA_DIRECTORY, "-d");
PRINTOPT (CA_EXPORT, "-e");
PRINTOPT (CA_FILE, "-f");
PRINTOPT (CA_GROUP, "-g");
PRINTOPT (CA_JOB, "-j");
PRINTOPT (CA_KEYWORD, "-k");
PRINTOPT (CA_SERVICE, "-s");
PRINTOPT (CA_USER, "-u");
PRINTOPT (CA_VARIABLE, "-v");
/* now the rest of the actions */
PRINTACT (CA_ARRAYVAR, "arrayvar");
PRINTACT (CA_BINDING, "binding");
PRINTACT (CA_DISABLED, "disabled");
PRINTACT (CA_ENABLED, "enabled");
PRINTACT (CA_FUNCTION, "function");
PRINTACT (CA_HELPTOPIC, "helptopic");
PRINTACT (CA_HOSTNAME, "hostname");
PRINTACT (CA_RUNNING, "running");
PRINTACT (CA_SETOPT, "setopt");
PRINTACT (CA_SHOPT, "shopt");
PRINTACT (CA_SIGNAL, "signal");
PRINTACT (CA_STOPPED, "stopped");
/* now the rest of the arguments */
/* arguments that require quoting */
SQPRINTARG (cs->globpat, "-G");
SQPRINTARG (cs->words, "-W");
SQPRINTARG (cs->prefix, "-P");
SQPRINTARG (cs->suffix, "-S");
SQPRINTARG (cs->filterpat, "-X");
/* simple arguments that don't require quoting */
PRINTARG (cs->funcname, "-F");
PRINTARG (cs->command, "-C");
printf ("%s\n", cmd);
return (0);
}
static int
print_compitem (item)
BUCKET_CONTENTS *item;
{
COMPSPEC *cs;
char *cmd;
cmd = item->key;
cs = (COMPSPEC *)item->data;
return (print_one_completion (cmd, cs));
}
static void
print_all_completions ()
{
progcomp_walk (print_compitem);
}
static int
print_cmd_completions (list)
WORD_LIST *list;
{
WORD_LIST *l;
COMPSPEC *cs;
int ret;
for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next)
{
cs = progcomp_search (l->word->word);
if (cs)
print_one_completion (l->word->word, cs);
else
{
builtin_error (_("%s: no completion specification"), l->word->word);
ret = EXECUTION_FAILURE;
}
}
return (ret);
}
$BUILTIN compgen
$DEPENDS_ON PROGRAMMABLE_COMPLETION
$FUNCTION compgen_builtin
$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
Display the possible completions depending on the options. Intended
to be used from within a shell function generating possible completions.
If the optional WORD argument is supplied, matches against WORD are
generated.
$END
int
compgen_builtin (list)
WORD_LIST *list;
{
int rval;
unsigned long acts, copts;
COMPSPEC *cs;
STRINGLIST *sl;
char *word, **matches;
if (list == 0)
return (EXECUTION_SUCCESS);
acts = copts = (unsigned long)0L;
Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
cs = (COMPSPEC *)NULL;
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
as a side effect if they are supplied as options. */
rval = build_actions (list, (int *)NULL, (int *)NULL, &acts, &copts);
if (rval == EX_USAGE)
return (rval);
if (rval == EXECUTION_FAILURE)
return (EXECUTION_SUCCESS);
list = loptend;
word = (list && list->word) ? list->word->word : "";
if (Farg)
builtin_error (_("warning: -F option may not work as you expect"));
if (Carg)
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 ();
cs->actions = acts;
cs->options = copts;
cs->refcount = 1;
cs->globpat = STRDUP (Garg);
cs->words = STRDUP (Warg);
cs->prefix = STRDUP (Parg);
cs->suffix = STRDUP (Sarg);
cs->funcname = STRDUP (Farg);
cs->command = STRDUP (Carg);
cs->filterpat = STRDUP (Xarg);
rval = EXECUTION_FAILURE;
sl = gen_compspec_completions (cs, "compgen", word, 0, 0);
/* If the compspec wants the bash default completions, temporarily
turn off programmable completion and call the bash completion code. */
if ((sl == 0 || sl->list_len == 0) && (copts & COPT_BASHDEFAULT))
{
matches = bash_default_completion (word, 0, 0, 0, 0);
sl = completions_to_stringlist (matches);
strvec_dispose (matches);
}
/* This isn't perfect, but it's the best we can do, given what readline
exports from its set of completion utility functions. */
if ((sl == 0 || sl->list_len == 0) && (copts & COPT_DEFAULT))
{
matches = rl_completion_matches (word, rl_filename_completion_function);
sl = completions_to_stringlist (matches);
strvec_dispose (matches);
}
if (sl)
{
if (sl->list && sl->list_len)
{
rval = EXECUTION_SUCCESS;
strlist_print (sl, (char *)NULL);
}
strlist_dispose (sl);
}
compspec_dispose (cs);
return (rval);
}
+3 -2
View File
@@ -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.
@@ -89,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)
+13 -14
View File
@@ -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
Using `+' instead of `-' turns off the given attribute.
Variables with the integer attribute have arithmetic evaluation (see
`let') done when the variable is assigned to.
the `let' command) done when the variable is assigned a value.
When displaying values of variables, -f displays a function's name
and definition. The -F option restricts the display to function
name only.
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
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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.
@@ -176,7 +176,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);
}
+325
View File
@@ -0,0 +1,325 @@
/* Copyright (C) 1996-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. */
#include <config.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "../bashtypes.h"
#include "posixstat.h"
#include "filecntl.h"
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include "../bashansi.h"
#include "../bashintl.h"
#include "../shell.h"
#include "../jobs.h"
#include "../builtins.h"
#include "../flags.h"
#include "../input.h"
#include "../execute_cmd.h"
#include "../trap.h"
#if defined (HISTORY)
# include "../bashhist.h"
#endif
#include "common.h"
#if !defined (errno)
extern int errno;
#endif
/* Flags for _evalfile() */
#define FEVAL_ENOENTOK 0x001
#define FEVAL_BUILTIN 0x002
#define FEVAL_UNWINDPROT 0x004
#define FEVAL_NONINT 0x008
#define FEVAL_LONGJMP 0x010
#define FEVAL_HISTORY 0x020
#define FEVAL_CHECKBINARY 0x040
#define FEVAL_REGFILE 0x080
#define FEVAL_NOPUSHARGS 0x100
extern int posixly_correct;
extern int indirection_level, subshell_environment;
extern int return_catch_flag, return_catch_value;
extern int last_command_exit_value;
/* How many `levels' of sourced files we have. */
int sourcelevel = 0;
static int
_evalfile (filename, flags)
const char *filename;
int flags;
{
volatile int old_interactive;
procenv_t old_return_catch;
int return_val, fd, result, pflags;
char *string;
struct stat finfo;
size_t file_size;
sh_vmsg_func_t *errfunc;
#if defined (ARRAY_VARS)
SHELL_VAR *funcname_v, *nfv, *bash_source_v, *bash_lineno_v;
ARRAY *funcname_a, *bash_source_a, *bash_lineno_a;
# if defined (DEBUGGER)
SHELL_VAR *bash_argv_v, *bash_argc_v;
ARRAY *bash_argv_a, *bash_argc_a;
# endif
char *t, tt[2];
#endif
USE_VAR(pflags);
#if defined (ARRAY_VARS)
GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a);
GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a);
GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a);
# if defined (DEBUGGER)
GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a);
GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a);
# endif
#endif
fd = open (filename, O_RDONLY);
if (fd < 0 || (fstat (fd, &finfo) == -1))
{
file_error_and_exit:
if (((flags & FEVAL_ENOENTOK) == 0) || errno != ENOENT)
file_error (filename);
if (flags & FEVAL_LONGJMP)
{
last_command_exit_value = 1;
jump_to_top_level (EXITPROG);
}
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE
: ((errno == ENOENT) ? 0 : -1));
}
errfunc = ((flags & FEVAL_BUILTIN) ? builtin_error : internal_error);
if (S_ISDIR (finfo.st_mode))
{
(*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);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
}
file_size = (size_t)finfo.st_size;
/* Check for overflow with large files. */
if (file_size != finfo.st_size || file_size + 1 < file_size)
{
(*errfunc) (_("%s: file is too large"), filename);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
}
#if defined (__CYGWIN__) && defined (O_TEXT)
setmode (fd, O_TEXT);
#endif
if (S_ISREG (finfo.st_mode))
{
string = (char *)xmalloc (1 + file_size);
result = read (fd, string, file_size);
string[result] = '\0';
}
else
result = zmapfd (fd, &string, 0);
return_val = errno;
close (fd);
errno = return_val;
if (result < 0) /* XXX was != file_size, not < 0 */
{
free (string);
goto file_error_and_exit;
}
if (result == 0)
{
free (string);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_SUCCESS : 1);
}
if ((flags & FEVAL_CHECKBINARY) &&
check_binary_file (string, (result > 80) ? 80 : result))
{
free (string);
(*errfunc) (_("%s: cannot execute binary file"), filename);
return ((flags & FEVAL_BUILTIN) ? EX_BINARY_FILE : -1);
}
if (flags & FEVAL_UNWINDPROT)
{
begin_unwind_frame ("_evalfile");
unwind_protect_int (return_catch_flag);
unwind_protect_jmp_buf (return_catch);
if (flags & FEVAL_NONINT)
unwind_protect_int (interactive);
unwind_protect_int (sourcelevel);
}
else
{
COPY_PROCENV (return_catch, old_return_catch);
if (flags & FEVAL_NONINT)
old_interactive = interactive;
}
if (flags & FEVAL_NONINT)
interactive = 0;
return_catch_flag++;
sourcelevel++;
#if defined (ARRAY_VARS)
array_push (bash_source_a, (char *)filename);
t = itos (executing_line_number ());
array_push (bash_lineno_a, t);
free (t);
array_push (funcname_a, "source"); /* not exactly right */
# if defined (DEBUGGER)
/* Have to figure out a better way to do this when `source' is supplied
arguments */
if ((flags & FEVAL_NOPUSHARGS) == 0)
{
array_push (bash_argv_a, (char *)filename);
tt[0] = '1'; tt[1] = '\0';
array_push (bash_argc_a, tt);
}
# endif
#endif
/* set the flags to be passed to parse_and_execute */
pflags = SEVAL_RESETLINE;
pflags |= (flags & FEVAL_HISTORY) ? 0 : SEVAL_NOHIST;
if (flags & FEVAL_BUILTIN)
result = EXECUTION_SUCCESS;
return_val = setjmp (return_catch);
/* If `return' was seen outside of a function, but in the script, then
force parse_and_execute () to clean up. */
if (return_val)
{
parse_and_execute_cleanup ();
result = return_catch_value;
}
else
result = parse_and_execute (string, filename, pflags);
if (flags & FEVAL_UNWINDPROT)
run_unwind_frame ("_evalfile");
else
{
if (flags & FEVAL_NONINT)
interactive = old_interactive;
return_catch_flag--;
sourcelevel--;
COPY_PROCENV (old_return_catch, return_catch);
}
#if defined (ARRAY_VARS)
/* These two variables cannot be unset, and cannot be affected by the
sourced file. */
array_pop (bash_source_a);
array_pop (bash_lineno_a);
/* FUNCNAME can be unset, and so can potentially be changed by the
sourced file. */
GET_ARRAY_FROM_VAR ("FUNCNAME", nfv, funcname_a);
if (nfv == funcname_v)
array_pop (funcname_a);
# if defined (DEBUGGER)
if ((flags & FEVAL_NOPUSHARGS) == 0)
{
array_pop (bash_argc_a);
array_pop (bash_argv_a);
}
# endif
#endif
return ((flags & FEVAL_BUILTIN) ? result : 1);
}
int
maybe_execute_file (fname, force_noninteractive)
const char *fname;
int force_noninteractive;
{
char *filename;
int result, flags;
filename = bash_tilde_expand (fname, 0);
flags = FEVAL_ENOENTOK;
if (force_noninteractive)
flags |= FEVAL_NONINT;
result = _evalfile (filename, flags);
free (filename);
return result;
}
#if defined (HISTORY)
int
fc_execute_file (filename)
const char *filename;
{
int flags;
/* We want these commands to show up in the history list if
remember_on_history is set. */
flags = FEVAL_ENOENTOK|FEVAL_HISTORY|FEVAL_REGFILE;
return (_evalfile (filename, flags));
}
#endif /* HISTORY */
int
source_file (filename, sflags)
const char *filename;
int sflags;
{
int flags, rval;
flags = FEVAL_BUILTIN|FEVAL_UNWINDPROT|FEVAL_NONINT;
if (sflags)
flags |= FEVAL_NOPUSHARGS;
/* POSIX shells exit if non-interactive and file error. */
if (posixly_correct && !interactive_shell)
flags |= FEVAL_LONGJMP;
rval = _evalfile (filename, flags);
run_return_trap ();
return rval;
}
+2 -2
View File
@@ -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.
@@ -60,7 +60,7 @@ exit_builtin (list)
{
if (interactive)
{
fprintf (stderr, login_shell ? "logout\n" : "exit\n");
fprintf (stderr, login_shell ? _("logout\n") : "exit\n");
fflush (stderr);
}
+152
View File
@@ -0,0 +1,152 @@
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.
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 exit.c
$BUILTIN exit
$FUNCTION exit_builtin
$SHORT_DOC exit [n]
Exit the shell with a status of N. If N is omitted, the exit status
is that of the last command executed.
$END
#include <config.h>
#include "../bashtypes.h"
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "../bashintl.h"
#include "../shell.h"
#include "../jobs.h"
#include "common.h"
#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;
static int exit_or_logout __P((WORD_LIST *));
static int sourced_logout;
int
exit_builtin (list)
WORD_LIST *list;
{
if (interactive)
{
fprintf (stderr, login_shell ? "logout\n" : "exit\n");
fflush (stderr);
}
return (exit_or_logout (list));
}
$BUILTIN logout
$FUNCTION logout_builtin
$SHORT_DOC logout
Logout of a login shell.
$END
/* How to logout. */
int
logout_builtin (list)
WORD_LIST *list;
{
if (login_shell == 0 /* && interactive */)
{
builtin_error (_("not login shell: use `exit'"));
return (EXECUTION_FAILURE);
}
else
return (exit_or_logout (list));
}
static int
exit_or_logout (list)
WORD_LIST *list;
{
int exit_value;
#if defined (JOB_CONTROL)
int exit_immediate_okay;
exit_immediate_okay = (interactive == 0 ||
last_shell_builtin == exit_builtin ||
last_shell_builtin == logout_builtin ||
last_shell_builtin == jobs_builtin);
/* Check for stopped jobs if the user wants to. */
if (!exit_immediate_okay)
{
register int i;
for (i = 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);
}
}
#endif /* JOB_CONTROL */
/* Get return value if present. This means that you can type
`logout 5' to a shell, and it returns 5. */
/* If we're running the exit trap (running_trap == 1, since running_trap
gets set to SIG+1), and we don't have a argument given to `exit'
(list == 0), use the exit status we saved before running the trap
commands (trap_saved_exit_value). */
exit_value = (running_trap == 1 && list == 0) ? trap_saved_exit_value : get_exitstat (list);
bash_logout ();
last_command_exit_value = exit_value;
/* Exit the program. */
jump_to_top_level (EXITPROG);
/*NOTREACHED*/
}
void
bash_logout ()
{
/* Run our `~/.bash_logout' file if it exists, and this is a login shell. */
if (login_shell && sourced_logout++ == 0 && subshell_environment == 0)
{
maybe_execute_file ("~/.bash_logout", 1);
#ifdef SYS_BASH_LOGOUT
maybe_execute_file (SYS_BASH_LOGOUT, 1);
#endif
}
}
+1 -1
View File
@@ -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] [command]
$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
+1 -1
View File
@@ -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.
+2 -2
View File
@@ -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;
}
+177
View File
@@ -0,0 +1,177 @@
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.
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 fg_bg.c
$BUILTIN fg
$FUNCTION fg_builtin
$DEPENDS_ON JOB_CONTROL
$SHORT_DOC fg [job_spec]
Place JOB_SPEC in the foreground, and make it the current job. If
JOB_SPEC is not present, the shell's notion of the current job is
used.
$END
#include <config.h>
#include "../bashtypes.h"
#include <signal.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "../bashintl.h"
#include "../shell.h"
#include "../jobs.h"
#include "common.h"
#include "bashgetopt.h"
#if defined (JOB_CONTROL)
extern char *this_command_name;
static int fg_bg __P((WORD_LIST *, int));
/* How to bring a job into the foreground. */
int
fg_builtin (list)
WORD_LIST *list;
{
int fg_bit;
register WORD_LIST *t;
if (job_control == 0)
{
sh_nojobs ((char *)NULL);
return (EXECUTION_FAILURE);
}
if (no_options (list))
return (EX_USAGE);
list = loptend;
/* If the last arg on the line is '&', then start this job in the
background. Else, fg the job. */
for (t = list; t && t->next; t = t->next)
;
fg_bit = (t && t->word->word[0] == '&' && t->word->word[1] == '\0') == 0;
return (fg_bg (list, fg_bit));
}
#endif /* JOB_CONTROL */
$BUILTIN bg
$FUNCTION bg_builtin
$DEPENDS_ON JOB_CONTROL
$SHORT_DOC bg [job_spec ...]
Place each JOB_SPEC in the background, as if it had been started with
`&'. If JOB_SPEC is not present, the shell's notion of the current
job is used.
$END
#if defined (JOB_CONTROL)
/* How to put a job into the background. */
int
bg_builtin (list)
WORD_LIST *list;
{
int r;
if (job_control == 0)
{
sh_nojobs ((char *)NULL);
return (EXECUTION_FAILURE);
}
if (no_options (list))
return (EX_USAGE);
list = loptend;
/* This relies on the fact that fg_bg() takes a WORD_LIST *, but only acts
on the first member (if any) of that list. */
r = EXECUTION_SUCCESS;
do
{
if (fg_bg (list, 0) == EXECUTION_FAILURE)
r = EXECUTION_FAILURE;
if (list)
list = list->next;
}
while (list);
return r;
}
/* How to put a job into the foreground/background. */
static int
fg_bg (list, foreground)
WORD_LIST *list;
int foreground;
{
sigset_t set, oset;
int job, status, old_async_pid;
JOB *j;
BLOCK_CHILD (set, oset);
job = get_job_spec (list);
if (INVALID_JOB (job))
{
if (job != DUP_JOB)
sh_badjob (list ? list->word->word : "current");
goto failure;
}
j = get_job_by_jid (job);
/* Or if j->pgrp == shell_pgrp. */
if (IS_JOBCONTROL (job) == 0)
{
builtin_error (_("job %d started without job control"), job + 1);
goto failure;
}
if (foreground == 0)
{
old_async_pid = last_asynchronous_pid;
last_asynchronous_pid = j->pgrp; /* As per Posix.2 5.4.2 */
}
status = start_job (job, foreground);
if (status >= 0)
{
/* win: */
UNBLOCK_CHILD (oset);
return (foreground ? status : EXECUTION_SUCCESS);
}
else
{
if (foreground == 0)
last_asynchronous_pid = old_async_pid;
failure:
UNBLOCK_CHILD (oset);
return (EXECUTION_FAILURE);
}
}
#endif /* JOB_CONTROL */
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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.
@@ -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
+2 -2
View File
@@ -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)
+280
View File
@@ -0,0 +1,280 @@
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.
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 jobs.c
$BUILTIN jobs
$FUNCTION jobs_builtin
$DEPENDS_ON JOB_CONTROL
$SHORT_DOC jobs [-lnprs] [jobspec ...] or jobs -x command [args]
Lists the active jobs. The -l option lists process id's in addition
to the normal information; the -p option lists process id's only.
If -n is given, only processes that have changed status since the last
notification are printed. JOBSPEC restricts output to that job. The
-r and -s options restrict output to running and stopped jobs only,
respectively. Without options, the status of all active jobs is
printed. If -x is given, COMMAND is run after all job specifications
that appear in ARGS have been replaced with the process ID of that job's
process group leader.
$END
#include <config.h>
#if defined (JOB_CONTROL)
#include "../bashtypes.h"
#include <signal.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "../bashansi.h"
#include "../bashintl.h"
#include "../shell.h"
#include "../jobs.h"
#include "../execute_cmd.h"
#include "bashgetopt.h"
#include "common.h"
#define JSTATE_ANY 0x0
#define JSTATE_RUNNING 0x1
#define JSTATE_STOPPED 0x2
static int execute_list_with_replacements __P((WORD_LIST *));
/* The `jobs' command. Prints outs a list of active jobs. If the
argument `-l' is given, then the process id's are printed also.
If the argument `-p' is given, print the process group leader's
pid only. If `-n' is given, only processes that have changed
status since the last notification are printed. If -x is given,
replace all job specs with the pid of the appropriate process
group leader and execute the command. The -r and -s options mean
to print info about running and stopped jobs only, respectively. */
int
jobs_builtin (list)
WORD_LIST *list;
{
int form, execute, state, opt, any_failed, job;
sigset_t set, oset;
execute = any_failed = 0;
form = JLIST_STANDARD;
state = JSTATE_ANY;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "lpnxrs")) != -1)
{
switch (opt)
{
case 'l':
form = JLIST_LONG;
break;
case 'p':
form = JLIST_PID_ONLY;
break;
case 'n':
form = JLIST_CHANGED_ONLY;
break;
case 'x':
if (form != JLIST_STANDARD)
{
builtin_error (_("no other options allowed with `-x'"));
return (EXECUTION_FAILURE);
}
execute++;
break;
case 'r':
state = JSTATE_RUNNING;
break;
case 's':
state = JSTATE_STOPPED;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
if (execute)
return (execute_list_with_replacements (list));
if (!list)
{
switch (state)
{
case JSTATE_ANY:
list_all_jobs (form);
break;
case JSTATE_RUNNING:
list_running_jobs (form);
break;
case JSTATE_STOPPED:
list_stopped_jobs (form);
break;
}
return (EXECUTION_SUCCESS);
}
while (list)
{
BLOCK_CHILD (set, oset);
job = get_job_spec (list);
if ((job == NO_JOB) || jobs == 0 || get_job_by_jid (job) == 0)
{
sh_badjob (list->word->word);
any_failed++;
}
else if (job != DUP_JOB)
list_one_job ((JOB *)NULL, form, 0, job);
UNBLOCK_CHILD (oset);
list = list->next;
}
return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
}
static int
execute_list_with_replacements (list)
WORD_LIST *list;
{
register WORD_LIST *l;
int job, result;
COMMAND *command;
JOB *j;
/* First do the replacement of job specifications with pids. */
for (l = list; l; l = l->next)
{
if (l->word->word[0] == '%') /* we have a winner */
{
job = get_job_spec (l);
/* A bad job spec is not really a job spec! Pass it through. */
if (INVALID_JOB (job))
continue;
j = get_job_by_jid (job);
free (l->word->word);
l->word->word = itos (j->pgrp);
}
}
/* Next make a new simple command and execute it. */
begin_unwind_frame ("jobs_builtin");
command = make_bare_simple_command ();
command->value.Simple->words = copy_word_list (list);
command->value.Simple->redirects = (REDIRECT *)NULL;
command->flags |= CMD_INHIBIT_EXPANSION;
command->value.Simple->flags |= CMD_INHIBIT_EXPANSION;
add_unwind_protect (dispose_command, command);
result = execute_command (command);
dispose_command (command);
discard_unwind_frame ("jobs_builtin");
return (result);
}
#endif /* JOB_CONTROL */
$BUILTIN disown
$FUNCTION disown_builtin
$DEPENDS_ON JOB_CONTROL
$SHORT_DOC disown [-h] [-ar] [jobspec ...]
By default, removes each JOBSPEC argument from the table of active jobs.
If the -h option is given, the job is not removed from the table, but is
marked so that SIGHUP is not sent to the job if the shell receives a
SIGHUP. The -a option, when JOBSPEC is not supplied, means to remove all
jobs from the job table; the -r option means to remove only running jobs.
$END
#if defined (JOB_CONTROL)
int
disown_builtin (list)
WORD_LIST *list;
{
int opt, job, retval, nohup_only, running_jobs, all_jobs;
sigset_t set, oset;
intmax_t pid_value;
nohup_only = running_jobs = all_jobs = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "ahr")) != -1)
{
switch (opt)
{
case 'a':
all_jobs = 1;
break;
case 'h':
nohup_only = 1;
break;
case 'r':
running_jobs = 1;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
retval = EXECUTION_SUCCESS;
/* `disown -a' or `disown -r' */
if (list == 0 && (all_jobs || running_jobs))
{
if (nohup_only)
nohup_all_jobs (running_jobs);
else
delete_all_jobs (running_jobs);
return (EXECUTION_SUCCESS);
}
do
{
BLOCK_CHILD (set, oset);
job = (list && legal_number (list->word->word, &pid_value) && pid_value == (pid_t) pid_value)
? get_job_by_pid ((pid_t) pid_value, 0)
: get_job_spec (list);
if (job == NO_JOB || jobs == 0 || INVALID_JOB (job))
{
sh_badjob (list ? list->word->word : "current");
retval = EXECUTION_FAILURE;
}
else if (nohup_only)
nohup_job (job);
else
delete_job (job, 1);
UNBLOCK_CHILD (oset);
if (list)
list = list->next;
}
while (list);
return (retval);
}
#endif /* JOB_CONTROL */
+1 -1
View File
@@ -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
+784
View File
@@ -0,0 +1,784 @@
This file is read.def, from which is created read.c.
It implements the builtin "read" in Bash.
Copyright (C) 1987-2005 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 read.c
$BUILTIN read
$FUNCTION read_builtin
$SHORT_DOC read [-ers] [-u fd] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [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
to the last NAME. Only the characters found in $IFS are recognized as word
delimiters. If no NAMEs are supplied, the line read is stored in the REPLY
variable. If the -r option is given, this signifies `raw' input, and
backslash escaping is disabled. The -d option causes read to continue
until the first character of DELIM is read, rather than newline. If the -p
option is supplied, the string PROMPT is output without a trailing newline
before attempting to read. If -a is supplied, the words read are assigned
to sequential indices of ARRAY, starting at zero. If -e is supplied and
the shell is interactive, readline is used to obtain the line. If -n is
supplied with a non-zero NCHARS argument, read returns after NCHARS
characters have been read. The -s option causes input coming from a
terminal to not be echoed.
The -t option causes read to time out and return failure if a complete line
of input is not read within TIMEOUT seconds. If the TMOUT variable is set,
its value is the default timeout. The return code is zero, unless end-of-file
is encountered, read times out, or an invalid file descriptor is supplied as
the argument to -u.
$END
#include <config.h>
#include "bashtypes.h"
#include "posixstat.h"
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include <signal.h>
#include <errno.h>
#ifdef __CYGWIN__
# include <fcntl.h>
# include <io.h>
#endif
#include "../bashintl.h"
#include "../shell.h"
#include "common.h"
#include "bashgetopt.h"
#include <shtty.h>
#if defined (READLINE)
#include "../bashline.h"
#include <readline/readline.h>
#endif
#if defined (BUFFERED_INPUT)
# include "input.h"
#endif
#if !defined(errno)
extern int errno;
#endif
#if defined (READLINE)
static void reset_attempted_completion_function __P((char *));
static char *edit_line __P((char *));
static void set_eol_delim __P((int));
static void reset_eol_delim __P((char *));
#endif
static SHELL_VAR *bind_read_variable __P((char *, char *));
static sighandler sigalrm __P((int));
static void reset_alarm __P((void));
static procenv_t alrmbuf;
static SigHandler *old_alrm;
static unsigned char delim;
static sighandler
sigalrm (s)
int s;
{
longjmp (alrmbuf, 1);
}
static void
reset_alarm ()
{
set_signal_handler (SIGALRM, old_alrm);
alarm (0);
}
/* Read the value of the shell variables whose names follow.
The reading is done from the current input stream, whatever
that may be. Successive words of the input line are assigned
to the variables mentioned in LIST. The last variable in LIST
gets the remainder of the words on the line. If no variables
are mentioned in LIST, then the default variable is $REPLY. */
int
read_builtin (list)
WORD_LIST *list;
{
register char *varname;
int size, i, nr, pass_next, saw_escape, eof, opt, retval, code;
int input_is_tty, input_is_pipe, unbuffered_read;
int raw, edit, nchars, silent, have_timeout, fd;
unsigned int tmout;
intmax_t intval;
char c;
char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
char *e, *t, *t1;
struct stat tsb;
SHELL_VAR *var;
#if defined (ARRAY_VARS)
WORD_LIST *alist;
#endif
#if defined (READLINE)
char *rlbuf;
int rlind;
#endif
USE_VAR(size);
USE_VAR(i);
USE_VAR(pass_next);
USE_VAR(saw_escape);
USE_VAR(input_is_pipe);
/* USE_VAR(raw); */
USE_VAR(edit);
USE_VAR(tmout);
USE_VAR(nchars);
USE_VAR(silent);
USE_VAR(ifs_chars);
USE_VAR(prompt);
USE_VAR(arrayname);
#if defined (READLINE)
USE_VAR(rlbuf);
USE_VAR(rlind);
#endif
USE_VAR(list);
i = 0; /* Index into the string that we are reading. */
raw = edit = 0; /* Not reading raw input by default. */
silent = 0;
arrayname = prompt = (char *)NULL;
fd = 0; /* file descriptor to read from */
#if defined (READLINE)
rlbuf = (char *)0;
rlind = 0;
#endif
tmout = 0; /* no timeout */
nr = nchars = input_is_tty = input_is_pipe = unbuffered_read = have_timeout = 0;
delim = '\n'; /* read until newline */
reset_internal_getopt ();
while ((opt = internal_getopt (list, "ersa:d:n:p:t:u:")) != -1)
{
switch (opt)
{
case 'r':
raw = 1;
break;
case 'p':
prompt = list_optarg;
break;
case 's':
silent = 1;
break;
case 'e':
#if defined (READLINE)
edit = 1;
#endif
break;
#if defined (ARRAY_VARS)
case 'a':
arrayname = list_optarg;
break;
#endif
case 't':
code = legal_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (unsigned int)intval)
{
builtin_error (_("%s: invalid timeout specification"), list_optarg);
return (EXECUTION_FAILURE);
}
else
{
have_timeout = 1;
tmout = intval;
}
break;
case 'n':
code = legal_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (int)intval)
{
sh_invalidnum (list_optarg);
return (EXECUTION_FAILURE);
}
else
nchars = intval;
break;
case 'u':
code = legal_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (int)intval)
{
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));
return (EXECUTION_FAILURE);
}
break;
case 'd':
delim = *list_optarg;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
/* `read -t 0 var' returns failure immediately. XXX - should it test
whether input is available with select/FIONREAD, and fail if those
are unavailable? */
if (have_timeout && tmout == 0)
return (EXECUTION_FAILURE);
/* IF IFS is unset, we use the default of " \t\n". */
ifs_chars = getifs ();
if (ifs_chars == 0) /* XXX - shouldn't happen */
ifs_chars = "";
input_string = (char *)xmalloc (size = 112); /* XXX was 128 */
/* $TMOUT, if set, is the default timeout for read. */
if (have_timeout == 0 && (e = get_string_value ("TMOUT")))
{
code = legal_number (e, &intval);
if (code == 0 || intval < 0 || intval != (unsigned int)intval)
tmout = 0;
else
tmout = intval;
}
begin_unwind_frame ("read_builtin");
#if defined (BUFFERED_INPUT)
if (interactive == 0 && default_buffered_input >= 0 && fd_is_bash_input (fd))
sync_buffered_stream (default_buffered_input);
#endif
input_is_tty = isatty (fd);
if (input_is_tty == 0)
#ifndef __CYGWIN__
input_is_pipe = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
#else
input_is_pipe = 1;
#endif
/* If the -p, -e or -s flags were given, but input is not coming from the
terminal, turn them off. */
if ((prompt || edit || silent) && input_is_tty == 0)
{
prompt = (char *)NULL;
edit = silent = 0;
}
#if defined (READLINE)
if (edit)
add_unwind_protect (xfree, rlbuf);
#endif
if (prompt && edit == 0)
{
fprintf (stderr, "%s", prompt);
fflush (stderr);
}
pass_next = 0; /* Non-zero signifies last char was backslash. */
saw_escape = 0; /* Non-zero signifies that we saw an escape char */
if (tmout > 0)
{
/* Turn off the timeout if stdin is a regular file (e.g. from
input redirection). */
if ((fstat (fd, &tsb) < 0) || S_ISREG (tsb.st_mode))
tmout = 0;
}
if (tmout > 0)
{
code = setjmp (alrmbuf);
if (code)
{
run_unwind_frame ("read_builtin");
return (EXECUTION_FAILURE);
}
old_alrm = set_signal_handler (SIGALRM, sigalrm);
add_unwind_protect (reset_alarm, (char *)NULL);
#if defined (READLINE)
if (edit)
add_unwind_protect (reset_attempted_completion_function, (char *)NULL);
#endif
alarm (tmout);
}
/* If we've been asked to read only NCHARS chars, or we're using some
character other than newline to terminate the line, do the right
thing to readline or the tty. */
if (nchars > 0 || delim != '\n')
{
#if defined (READLINE)
if (edit)
{
if (nchars > 0)
{
unwind_protect_int (rl_num_chars_to_read);
rl_num_chars_to_read = nchars;
}
if (delim != '\n')
{
set_eol_delim (delim);
add_unwind_protect (reset_eol_delim, (char *)NULL);
}
}
else
#endif
if (input_is_tty)
{
ttsave ();
if (silent)
ttcbreak ();
else
ttonechar ();
add_unwind_protect ((Function *)ttrestore, (char *)NULL);
}
}
else if (silent) /* turn off echo but leave term in canonical mode */
{
ttsave ();
ttnoecho ();
add_unwind_protect ((Function *)ttrestore, (char *)NULL);
}
/* This *must* be the top unwind-protect on the stack, so the manipulation
of the unwind-protect stack after the realloc() works right. */
add_unwind_protect (xfree, input_string);
interrupt_immediately++;
terminate_immediately = 1;
unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
#if defined (__CYGWIN__) && defined (O_TEXT)
setmode (0, O_TEXT);
#endif
for (eof = retval = 0;;)
{
#if defined (READLINE)
if (edit)
{
if (rlbuf && rlbuf[rlind] == '\0')
{
xfree (rlbuf);
rlbuf = (char *)0;
}
if (rlbuf == 0)
{
rlbuf = edit_line (prompt ? prompt : "");
rlind = 0;
}
if (rlbuf == 0)
{
eof = 1;
break;
}
c = rlbuf[rlind++];
}
else
{
#endif
if (unbuffered_read)
retval = zread (fd, &c, 1);
else
retval = zreadc (fd, &c);
if (retval <= 0)
{
eof = 1;
break;
}
#if defined (READLINE)
}
#endif
if (i + 2 >= size)
{
input_string = (char *)xrealloc (input_string, size += 128);
remove_unwind_protect ();
add_unwind_protect (xfree, input_string);
}
/* If the next character is to be accepted verbatim, a backslash
newline pair still disappears from the input. */
if (pass_next)
{
pass_next = 0;
if (c == '\n')
i--; /* back up over the CTLESC */
else
goto add_char;
continue;
}
if (c == '\\' && raw == 0)
{
pass_next++;
saw_escape++;
input_string[i++] = CTLESC;
continue;
}
if ((unsigned char)c == delim)
break;
if (c == CTLESC || c == CTLNUL)
{
saw_escape++;
input_string[i++] = CTLESC;
}
add_char:
input_string[i++] = c;
nr++;
if (nchars > 0 && nr >= nchars)
break;
}
input_string[i] = '\0';
#if 1
if (retval < 0)
{
builtin_error (_("read error: %d: %s"), fd, strerror (errno));
run_unwind_frame ("read_builtin");
return (EXECUTION_FAILURE);
}
#endif
if (tmout > 0)
reset_alarm ();
if (nchars > 0 || delim != '\n')
{
#if defined (READLINE)
if (edit)
{
if (nchars > 0)
rl_num_chars_to_read = 0;
if (delim != '\n')
reset_eol_delim ((char *)NULL);
}
else
#endif
if (input_is_tty)
ttrestore ();
}
else if (silent)
ttrestore ();
if (unbuffered_read == 0)
zsyncfd (fd);
interrupt_immediately--;
terminate_immediately = 0;
discard_unwind_frame ("read_builtin");
retval = eof ? EXECUTION_FAILURE : EXECUTION_SUCCESS;
#if defined (ARRAY_VARS)
/* If -a was given, take the string read, break it into a list of words,
an assign them to `arrayname' in turn. */
if (arrayname)
{
if (legal_identifier (arrayname) == 0)
{
sh_invalidid (arrayname);
xfree (input_string);
return (EXECUTION_FAILURE);
}
var = find_or_make_array_variable (arrayname, 1);
if (var == 0)
{
xfree (input_string);
return EXECUTION_FAILURE; /* readonly or noassign */
}
array_flush (array_cell (var));
alist = list_string (input_string, ifs_chars, 0);
if (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);
}
xfree (input_string);
return (retval);
}
#endif /* ARRAY_VARS */
/* If there are no variables, save the text of the line read to the
variable $REPLY. ksh93 strips leading and trailing IFS whitespace,
so that `read x ; echo "$x"' and `read ; echo "$REPLY"' behave the
same way, but I believe that the difference in behaviors is useful
enough to not do it. Without the bash behavior, there is no way
to read a line completely without interpretation or modification
unless you mess with $IFS (e.g., setting it to the empty string).
If you disagree, change the occurrences of `#if 0' to `#if 1' below. */
if (list == 0)
{
#if 0
orig_input_string = input_string;
for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && isifs(*t); t++)
;
input_string = t;
input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape);
#endif
if (saw_escape)
{
t = dequote_string (input_string);
var = bind_variable ("REPLY", t, 0);
free (t);
}
else
var = bind_variable ("REPLY", input_string, 0);
VUNSETATTR (var, att_invisible);
free (input_string);
return (retval);
}
/* This code implements the Posix.2 spec for splitting the words
read and assigning them to variables. */
orig_input_string = input_string;
/* Remove IFS white space at the beginning of the input string. If
$IFS is null, no field splitting is performed. */
for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && isifs(*t); t++)
;
input_string = t;
for (; list->next; list = list->next)
{
varname = list->word->word;
#if defined (ARRAY_VARS)
if (legal_identifier (varname) == 0 && valid_array_reference (varname) == 0)
#else
if (legal_identifier (varname) == 0)
#endif
{
sh_invalidid (varname);
xfree (orig_input_string);
return (EXECUTION_FAILURE);
}
/* If there are more variables than words read from the input,
the remaining variables are set to the empty string. */
if (*input_string)
{
/* This call updates INPUT_STRING. */
t = get_word_from_string (&input_string, ifs_chars, &e);
if (t)
*e = '\0';
/* Don't bother to remove the CTLESC unless we added one
somewhere while reading the string. */
if (t && saw_escape)
{
t1 = dequote_string (t);
var = bind_read_variable (varname, t1);
xfree (t1);
}
else
var = bind_read_variable (varname, t);
}
else
{
t = (char *)0;
var = bind_read_variable (varname, "");
}
FREE (t);
if (var == 0)
{
xfree (orig_input_string);
return (EXECUTION_FAILURE);
}
stupidly_hack_special_variables (varname);
VUNSETATTR (var, att_invisible);
}
/* Now assign the rest of the line to the last variable argument. */
#if defined (ARRAY_VARS)
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word) == 0)
#else
if (legal_identifier (list->word->word) == 0)
#endif
{
sh_invalidid (list->word->word);
xfree (orig_input_string);
return (EXECUTION_FAILURE);
}
#if 0
/* This has to be done this way rather than using string_list
and list_string because Posix.2 says that the last variable gets the
remaining words and their intervening separators. */
input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape);
#else
/* Check whether or not the number of fields is exactly the same as the
number of variables. */
if (*input_string)
{
t1 = input_string;
t = get_word_from_string (&input_string, ifs_chars, &e);
if (*input_string == 0)
input_string = t;
else
input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
}
#endif
if (saw_escape)
{
t = dequote_string (input_string);
var = bind_read_variable (list->word->word, t);
xfree (t);
}
else
var = bind_read_variable (list->word->word, input_string);
stupidly_hack_special_variables (list->word->word);
if (var)
VUNSETATTR (var, att_invisible);
xfree (orig_input_string);
return (retval);
}
static SHELL_VAR *
bind_read_variable (name, value)
char *name, *value;
{
#if defined (ARRAY_VARS)
if (valid_array_reference (name) == 0)
return (bind_variable (name, value, 0));
else
return (assign_array_element (name, value, 0));
#else /* !ARRAY_VARS */
return bind_variable (name, value, 0);
#endif /* !ARRAY_VARS */
}
#if defined (READLINE)
static rl_completion_func_t *old_attempted_completion_function = 0;
static void
reset_attempted_completion_function (cp)
char *cp;
{
if (rl_attempted_completion_function == 0 && old_attempted_completion_function)
rl_attempted_completion_function = old_attempted_completion_function;
}
static char *
edit_line (p)
char *p;
{
char *ret;
int len;
if (bash_readline_initialized == 0)
initialize_readline ();
old_attempted_completion_function = rl_attempted_completion_function;
rl_attempted_completion_function = (rl_completion_func_t *)NULL;
ret = readline (p);
rl_attempted_completion_function = old_attempted_completion_function;
old_attempted_completion_function = (rl_completion_func_t *)NULL;
if (ret == 0)
return ret;
len = strlen (ret);
ret = (char *)xrealloc (ret, len + 2);
ret[len++] = delim;
ret[len] = '\0';
return ret;
}
static int old_delim_ctype;
static rl_command_func_t *old_delim_func;
static int old_newline_ctype;
static rl_command_func_t *old_newline_func;
static unsigned char delim_char;
static void
set_eol_delim (c)
int c;
{
Keymap cmap;
if (bash_readline_initialized == 0)
initialize_readline ();
cmap = rl_get_keymap ();
/* Change newline to self-insert */
old_newline_ctype = cmap[RETURN].type;
old_newline_func = cmap[RETURN].function;
cmap[RETURN].type = ISFUNC;
cmap[RETURN].function = rl_insert;
/* Bind the delimiter character to accept-line. */
old_delim_ctype = cmap[c].type;
old_delim_func = cmap[c].function;
cmap[c].type = ISFUNC;
cmap[c].function = rl_newline;
delim_char = c;
}
static void
reset_eol_delim (cp)
char *cp;
{
Keymap cmap;
cmap = rl_get_keymap ();
cmap[RETURN].type = old_newline_ctype;
cmap[RETURN].function = old_newline_func;
cmap[delim_char].type = old_delim_ctype;
cmap[delim_char].function = old_delim_func;
}
#endif
+3
View File
@@ -61,6 +61,9 @@ extern int no_line_editing;
$BUILTIN set
$FUNCTION set_builtin
$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.
+1 -1
View File
@@ -60,7 +60,7 @@ 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 ...]
-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.
+2 -2
View File
@@ -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'
+441
View File
@@ -0,0 +1,441 @@
This file is setattr.def, from which is created setattr.c.
It implements the builtins "export" and "readonly", in Bash.
Copyright (C) 1987-2006 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 setattr.c
#include <config.h>
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include <stdio.h>
#include "../bashansi.h"
#include "../bashintl.h"
#include "../shell.h"
#include "common.h"
#include "bashgetopt.h"
extern int posixly_correct;
extern int array_needs_making;
extern char *this_command_name;
extern sh_builtin_func_t *this_shell_builtin;
#ifdef ARRAY_VARS
extern int declare_builtin __P((WORD_LIST *));
#endif
#define READONLY_OR_EXPORT \
(this_shell_builtin == readonly_builtin || this_shell_builtin == export_builtin)
$BUILTIN export
$FUNCTION export_builtin
$SHORT_DOC export [-nf] [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'
is given, a list of all names that are exported in this shell is
printed. An argument of `-n' says to remove the export property
from subsequent NAMEs. An argument of `--' disables further option
processing.
$END
/* For each variable name in LIST, make that variable appear in the
environment passed to simple commands. If there is no LIST, then
print all such variables. An argument of `-n' says to remove the
exported attribute from variables named in LIST. An argument of
-f indicates that the names present in LIST refer to functions. */
int
export_builtin (list)
register WORD_LIST *list;
{
return (set_or_show_attributes (list, att_exported, 0));
}
$BUILTIN readonly
$FUNCTION readonly_builtin
$SHORT_DOC readonly [-af] [name[=value] ...] or readonly -p
The given NAMEs are marked readonly and the values of these NAMEs may
not be changed by subsequent assignment. If the -f option is given,
then functions corresponding to the NAMEs are so marked. If no
arguments are given, or if `-p' is given, a list of all readonly names
is printed. The `-a' option means to treat each NAME as
an array variable. An argument of `--' disables further option
processing.
$END
/* For each variable name in LIST, make that variable readonly. Given an
empty LIST, print out all existing readonly variables. */
int
readonly_builtin (list)
register WORD_LIST *list;
{
return (set_or_show_attributes (list, att_readonly, 0));
}
#if defined (ARRAY_VARS)
# define ATTROPTS "afnp"
#else
# define ATTROPTS "fnp"
#endif
/* For each variable name in LIST, make that variable have the specified
ATTRIBUTE. An arg of `-n' says to remove the attribute from the the
remaining names in LIST (doesn't work for readonly). */
int
set_or_show_attributes (list, attribute, nodefs)
register WORD_LIST *list;
int attribute, nodefs;
{
register SHELL_VAR *var;
int assign, undo, functions_only, arrays_only, any_failed, assign_error, opt;
int aflags;
char *name;
#if defined (ARRAY_VARS)
WORD_LIST *nlist, *tlist;
WORD_DESC *w;
#endif
undo = functions_only = arrays_only = any_failed = assign_error = 0;
/* Read arguments from the front of the list. */
reset_internal_getopt ();
while ((opt = internal_getopt (list, ATTROPTS)) != -1)
{
switch (opt)
{
case 'n':
undo = 1;
break;
case 'f':
functions_only = 1;
break;
#if defined (ARRAY_VARS)
case 'a':
arrays_only = 1;
break;
#endif
case 'p':
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
if (list)
{
if (attribute & att_exported)
array_needs_making = 1;
/* Cannot undo readonly status, silently disallowed. */
if (undo && (attribute & att_readonly))
attribute &= ~att_readonly;
while (list)
{
name = list->word->word;
if (functions_only) /* xxx -f name */
{
var = find_function (name);
if (var == 0)
{
builtin_error (_("%s: not a function"), name);
any_failed++;
}
else
SETVARATTR (var, attribute, undo);
list = list->next;
continue;
}
/* xxx [-np] name[=value] */
assign = assignment (name, 0);
aflags = 0;
if (assign)
{
name[assign] = '\0';
if (name[assign - 1] == '+')
{
aflags |= ASS_APPEND;
name[assign - 1] = '\0';
}
}
if (legal_identifier (name) == 0)
{
sh_invalidid (name);
if (assign)
assign_error++;
else
any_failed++;
list = list->next;
continue;
}
if (assign) /* xxx [-np] name=value */
{
name[assign] = '=';
if (aflags & ASS_APPEND)
name[assign - 1] = '+';
#if defined (ARRAY_VARS)
/* Let's try something here. Turn readonly -a xxx=yyy into
declare -ra xxx=yyy and see what that gets us. */
if (arrays_only)
{
tlist = list->next;
list->next = (WORD_LIST *)NULL;
w = make_word ("-ra");
nlist = make_word_list (w, list);
opt = declare_builtin (nlist);
if (opt != EXECUTION_SUCCESS)
assign_error++;
list->next = tlist;
dispose_word (w);
free (nlist);
}
else
#endif
/* This word has already been expanded once with command
and parameter expansion. Call do_assignment_no_expand (),
which does not do command or parameter substitution. If
the assignment is not performed correctly, flag an error. */
if (do_assignment_no_expand (name) == 0)
assign_error++;
name[assign] = '\0';
if (aflags & ASS_APPEND)
name[assign - 1] = '\0';
}
set_var_attribute (name, attribute, undo);
list = list->next;
}
}
else
{
SHELL_VAR **variable_list;
register int i;
if ((attribute & att_function) || functions_only)
{
variable_list = all_shell_functions ();
if (attribute != att_function)
attribute &= ~att_function; /* so declare -xf works, for example */
}
else
variable_list = all_shell_variables ();
#if defined (ARRAY_VARS)
if (attribute & att_array)
{
arrays_only++;
if (attribute != att_array)
attribute &= ~att_array;
}
#endif
if (variable_list)
{
for (i = 0; var = variable_list[i]; i++)
{
#if defined (ARRAY_VARS)
if (arrays_only && array_p (var) == 0)
continue;
#endif
if ((var->attributes & attribute))
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
}
free (variable_list);
}
}
return (assign_error ? EX_BADASSIGN
: ((any_failed == 0) ? EXECUTION_SUCCESS
: EXECUTION_FAILURE));
}
/* Show the attributes for shell variable VAR. If NODEFS is non-zero,
don't show function definitions along with the name. If PATTR is
non-zero, it indicates we're being called from `export' or `readonly'.
In POSIX mode, this prints the name of the calling builtin (`export'
or `readonly') instead of `declare', and doesn't print function defs
when called by `export' or `readonly'. */
int
show_var_attributes (var, pattr, nodefs)
SHELL_VAR *var;
int pattr, nodefs;
{
char flags[8], *x;
int i;
i = 0;
/* pattr == 0 means we are called from `declare'. */
if (pattr == 0 || posixly_correct == 0)
{
#if defined (ARRAY_VARS)
if (array_p (var))
flags[i++] = 'a';
#endif
if (function_p (var))
flags[i++] = 'f';
if (integer_p (var))
flags[i++] = 'i';
if (readonly_p (var))
flags[i++] = 'r';
if (trace_p (var))
flags[i++] = 't';
if (exported_p (var))
flags[i++] = 'x';
}
else
{
#if defined (ARRAY_VARS)
if (array_p (var))
flags[i++] = 'a';
#endif
if (function_p (var))
flags[i++] = 'f';
}
flags[i] = '\0';
/* If we're printing functions with definitions, print the function def
first, then the attributes, instead of printing output that can't be
reused as input to recreate the current state. */
if (function_p (var) && nodefs == 0 && (pattr == 0 || posixly_correct == 0))
{
printf ("%s\n", named_function_string (var->name, function_cell (var), 1));
nodefs++;
if (pattr == 0 && i == 1 && flags[0] == 'f')
return 0; /* don't print `declare -f name' */
}
if (pattr == 0 || posixly_correct == 0)
printf ("declare -%s ", i ? flags : "-");
else if (i)
printf ("%s -%s ", this_command_name, flags);
else
printf ("%s ", this_command_name);
#if defined (ARRAY_VARS)
if (array_p (var))
print_array_assignment (var, 1);
else
#endif
/* force `readonly' and `export' to not print out function definitions
when in POSIX mode. */
if (nodefs || (function_p (var) && pattr != 0 && posixly_correct))
printf ("%s\n", var->name);
else if (function_p (var))
printf ("%s\n", named_function_string (var->name, function_cell (var), 1));
else if (invisible_p (var))
printf ("%s\n", var->name);
else
{
x = sh_double_quote (var_isset (var) ? value_cell (var) : "");
printf ("%s=%s\n", var->name, x);
free (x);
}
return (0);
}
int
show_name_attributes (name, nodefs)
char *name;
int nodefs;
{
SHELL_VAR *var;
var = find_variable_internal (name, 1);
if (var && invisible_p (var) == 0)
{
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
return (0);
}
else
return (1);
}
void
set_var_attribute (name, attribute, undo)
char *name;
int attribute, undo;
{
SHELL_VAR *var, *tv;
char *tvalue;
if (undo)
var = find_variable (name);
else
{
tv = find_tempenv_variable (name);
/* XXX -- need to handle case where tv is a temp variable in a
function-scope context, since function_env has been merged into
the local variables table. */
if (tv && tempvar_p (tv))
{
tvalue = var_isset (tv) ? savestring (value_cell (tv)) : savestring ("");
var = bind_variable (tv->name, tvalue, 0);
var->attributes |= tv->attributes & ~att_tempvar;
VSETATTR (tv, att_propagate);
if (var->context != 0)
VSETATTR (var, att_propagate);
SETVARATTR (tv, attribute, undo); /* XXX */
stupidly_hack_special_variables (tv->name);
free (tvalue);
}
else
{
var = find_variable_internal (name, 0);
if (var == 0)
{
var = bind_variable (name, (char *)NULL, 0);
VSETATTR (var, att_invisible);
}
else if (var->context != 0)
VSETATTR (var, att_propagate);
}
}
if (var)
SETVARATTR (var, attribute, undo);
if (var && (exported_p (var) || (attribute & att_exported)))
array_needs_making++; /* XXX */
}
+2 -2
View File
@@ -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
+540
View File
@@ -0,0 +1,540 @@
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.
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 shopt.c
$BUILTIN shopt
$FUNCTION shopt_builtin
$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
status indicates whether each OPTNAME is set or unset. The -o
option restricts the OPTNAMEs to those defined for use with
`set -o'. With no options, or with the -p option, a list of all
settable options is displayed, with an indication of whether or
not each is set.
$END
#include <config.h>
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include <stdio.h>
#include "../bashintl.h"
#include "../shell.h"
#include "../flags.h"
#include "common.h"
#include "bashgetopt.h"
#define UNSETOPT 0
#define SETOPT 1
#define OPTFMT "%-15s\t%s\n"
extern int allow_null_glob_expansion, fail_glob_expansion, glob_dot_filenames;
extern int cdable_vars, mail_warning, source_uses_path;
extern int no_exit_on_failed_exec, print_shift_error;
extern int check_hashed_filenames, promptvars;
extern int cdspelling, expand_aliases;
extern int extended_quote;
extern int check_window_size;
extern int glob_ignore_case, match_ignore_case;
extern int hup_on_exit;
extern int xpg_echo;
extern int gnu_error_format;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
#endif
#if defined (HISTORY)
extern int literal_history, command_oriented_history;
extern int force_append_history;
#endif
#if defined (READLINE)
extern int hist_verify, history_reediting, perform_hostname_completion;
extern int no_empty_command_completion;
extern int force_fignore;
extern int enable_hostname_completion __P((int));
#endif
#if defined (PROGRAMMABLE_COMPLETION)
extern int prog_completion_enabled;
#endif
#if defined (RESTRICTED_SHELL)
extern char *shell_name;
#endif
#if defined (DEBUGGER)
extern int debugging_mode;
#endif
static void shopt_error __P((char *));
static int set_shellopts_after_change __P((int));
#if defined (RESTRICTED_SHELL)
static int set_restricted_shell __P((int));
#endif
static int shopt_login_shell;
typedef int shopt_set_func_t __P((int));
static struct {
char *name;
int *value;
shopt_set_func_t *set_func;
} shopt_vars[] = {
{ "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 },
{ "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
{ "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
#endif
{ "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
{ "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
{ "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
#if defined (DEBUGGER)
{ "extdebug", &debugging_mode, (shopt_set_func_t *)NULL },
#endif
#if defined (EXTENDED_GLOB)
{ "extglob", &extended_glob, (shopt_set_func_t *)NULL },
#endif
{ "extquote", &extended_quote, (shopt_set_func_t *)NULL },
{ "failglob", &fail_glob_expansion, (shopt_set_func_t *)NULL },
#if defined (READLINE)
{ "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },
#endif
{ "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
{ "histappend", &force_append_history, (shopt_set_func_t *)NULL },
#endif
#if defined (READLINE)
{ "histreedit", &history_reediting, (shopt_set_func_t *)NULL },
{ "histverify", &hist_verify, (shopt_set_func_t *)NULL },
{ "hostcomplete", &perform_hostname_completion, enable_hostname_completion },
#endif
{ "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL },
{ "interactive_comments", &interactive_comments, set_shellopts_after_change },
#if defined (HISTORY)
{ "lithist", &literal_history, (shopt_set_func_t *)NULL },
#endif
{ "login_shell", &shopt_login_shell, set_login_shell },
{ "mailwarn", &mail_warning, (shopt_set_func_t *)NULL },
#if defined (READLINE)
{ "no_empty_cmd_completion", &no_empty_command_completion, (shopt_set_func_t *)NULL },
#endif
{ "nocaseglob", &glob_ignore_case, (shopt_set_func_t *)NULL },
{ "nocasematch", &match_ignore_case, (shopt_set_func_t *)NULL },
{ "nullglob", &allow_null_glob_expansion, (shopt_set_func_t *)NULL },
#if defined (PROGRAMMABLE_COMPLETION)
{ "progcomp", &prog_completion_enabled, (shopt_set_func_t *)NULL },
#endif
{ "promptvars", &promptvars, (shopt_set_func_t *)NULL },
#if defined (RESTRICTED_SHELL)
{ "restricted_shell", &restricted_shell, set_restricted_shell },
#endif
{ "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL },
{ "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL },
{ "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
{ (char *)0, (int *)0, (shopt_set_func_t *)NULL }
};
static char *on = "on";
static char *off = "off";
static int find_shopt __P((char *));
static int toggle_shopts __P((int, WORD_LIST *, int));
static void print_shopt __P((char *, int, int));
static int list_shopts __P((WORD_LIST *, int));
static int list_some_shopts __P((int, int));
static int list_shopt_o_options __P((WORD_LIST *, int));
static int list_some_o_options __P((int, int));
static int set_shopt_o_options __P((int, WORD_LIST *, int));
#define SFLAG 0x01
#define UFLAG 0x02
#define QFLAG 0x04
#define OFLAG 0x08
#define PFLAG 0x10
int
shopt_builtin (list)
WORD_LIST *list;
{
int opt, flags, rval;
flags = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "psuoq")) != -1)
{
switch (opt)
{
case 's':
flags |= SFLAG;
break;
case 'u':
flags |= UFLAG;
break;
case 'q':
flags |= QFLAG;
break;
case 'o':
flags |= OFLAG;
break;
case 'p':
flags |= PFLAG;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
if ((flags & (SFLAG|UFLAG)) == (SFLAG|UFLAG))
{
builtin_error (_("cannot set and unset shell options simultaneously"));
return (EXECUTION_FAILURE);
}
rval = EXECUTION_SUCCESS;
if ((flags & OFLAG) && ((flags & (SFLAG|UFLAG)) == 0)) /* shopt -o */
rval = list_shopt_o_options (list, flags);
else if (list && (flags & OFLAG)) /* shopt -so args */
rval = set_shopt_o_options ((flags & SFLAG) ? FLAG_ON : FLAG_OFF, list, flags & QFLAG);
else if (flags & OFLAG) /* shopt -so */
rval = list_some_o_options ((flags & SFLAG) ? 1 : 0, flags);
else if (list && (flags & (SFLAG|UFLAG))) /* shopt -su args */
rval = toggle_shopts ((flags & SFLAG) ? SETOPT : UNSETOPT, list, flags & QFLAG);
else if ((flags & (SFLAG|UFLAG)) == 0) /* shopt [args] */
rval = list_shopts (list, flags);
else /* shopt -su */
rval = list_some_shopts ((flags & SFLAG) ? SETOPT : UNSETOPT, flags);
return (rval);
}
/* Reset the options managed by `shopt' to the values they would have at
shell startup. */
void
reset_shopt_options ()
{
allow_null_glob_expansion = glob_dot_filenames = 0;
cdable_vars = mail_warning = 0;
no_exit_on_failed_exec = print_shift_error = 0;
check_hashed_filenames = cdspelling = expand_aliases = check_window_size = 0;
source_uses_path = promptvars = 1;
#if defined (EXTENDED_GLOB)
extended_glob = 0;
#endif
#if defined (HISTORY)
literal_history = force_append_history = 0;
command_oriented_history = 1;
#endif
#if defined (READLINE)
hist_verify = history_reediting = 0;
perform_hostname_completion = 1;
#endif
shopt_login_shell = login_shell;
}
static int
find_shopt (name)
char *name;
{
int i;
for (i = 0; shopt_vars[i].name; i++)
if (STREQ (name, shopt_vars[i].name))
return i;
return -1;
}
static void
shopt_error (s)
char *s;
{
builtin_error (_("%s: invalid shell option name"), s);
}
static int
toggle_shopts (mode, list, quiet)
int mode;
WORD_LIST *list;
int quiet;
{
WORD_LIST *l;
int ind, rval;
for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
{
ind = find_shopt (l->word->word);
if (ind < 0)
{
shopt_error (l->word->word);
rval = EXECUTION_FAILURE;
}
else
{
*shopt_vars[ind].value = mode; /* 1 for set, 0 for unset */
if (shopt_vars[ind].set_func)
(*shopt_vars[ind].set_func) (mode);
}
}
return (rval);
}
static void
print_shopt (name, val, flags)
char *name;
int val, flags;
{
if (flags & PFLAG)
printf ("shopt %s %s\n", val ? "-s" : "-u", name);
else
printf (OPTFMT, name, val ? on : off);
}
/* List the values of all or any of the `shopt' options. Returns 0 if
all were listed or all variables queried were on; 1 otherwise. */
static int
list_shopts (list, flags)
WORD_LIST *list;
int flags;
{
WORD_LIST *l;
int i, val, rval;
if (list == 0)
{
for (i = 0; shopt_vars[i].name; i++)
{
val = *shopt_vars[i].value;
if ((flags & QFLAG) == 0)
print_shopt (shopt_vars[i].name, val, flags);
}
return (EXECUTION_SUCCESS);
}
for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
{
i = find_shopt (l->word->word);
if (i < 0)
{
shopt_error (l->word->word);
rval = EXECUTION_FAILURE;
continue;
}
val = *shopt_vars[i].value;
if (val == 0)
rval = EXECUTION_FAILURE;
if ((flags & QFLAG) == 0)
print_shopt (l->word->word, val, flags);
}
return (rval);
}
static int
list_some_shopts (mode, flags)
int mode, flags;
{
int val, i;
for (i = 0; shopt_vars[i].name; i++)
{
val = *shopt_vars[i].value;
if (((flags & QFLAG) == 0) && mode == val)
print_shopt (shopt_vars[i].name, val, flags);
}
return (EXECUTION_SUCCESS);
}
static int
list_shopt_o_options (list, flags)
WORD_LIST *list;
int flags;
{
WORD_LIST *l;
int val, rval;
if (list == 0)
{
if ((flags & QFLAG) == 0)
list_minus_o_opts (-1, (flags & PFLAG));
return (EXECUTION_SUCCESS);
}
for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
{
val = minus_o_option_value (l->word->word);
if (val == -1)
{
sh_invalidoptname (l->word->word);
rval = EXECUTION_FAILURE;
continue;
}
if (val == 0)
rval = EXECUTION_FAILURE;
if ((flags & QFLAG) == 0)
{
if (flags & PFLAG)
printf ("set %co %s\n", val ? '-' : '+', l->word->word);
else
printf (OPTFMT, l->word->word, val ? on : off);
}
}
return (rval);
}
static int
list_some_o_options (mode, flags)
int mode, flags;
{
if ((flags & QFLAG) == 0)
list_minus_o_opts (mode, (flags & PFLAG));
return (EXECUTION_SUCCESS);
}
static int
set_shopt_o_options (mode, list, quiet)
int mode;
WORD_LIST *list;
int quiet;
{
WORD_LIST *l;
int rval;
for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
{
if (set_minus_o_option (mode, l->word->word) == EXECUTION_FAILURE)
rval = EXECUTION_FAILURE;
}
set_shellopts ();
return rval;
}
/* If we set or unset interactive_comments with shopt, make sure the
change is reflected in $SHELLOPTS. */
static int
set_shellopts_after_change (mode)
int mode;
{
set_shellopts ();
return (0);
}
#if defined (RESTRICTED_SHELL)
/* Don't allow the value of restricted_shell to be modified. */
static int
set_restricted_shell (mode)
int mode;
{
static int save_restricted = -1;
if (save_restricted == -1)
save_restricted = shell_is_restricted (shell_name);
restricted_shell = save_restricted;
return (0);
}
#endif /* RESTRICTED_SHELL */
/* Not static so shell.c can call it to initialize shopt_login_shell */
int
set_login_shell (mode)
int mode;
{
shopt_login_shell = login_shell != 0;
return (0);
}
char **
get_shopt_options ()
{
char **ret;
int n, i;
n = sizeof (shopt_vars) / sizeof (shopt_vars[0]);
ret = strvec_create (n + 1);
for (i = 0; shopt_vars[i].name; i++)
ret[i] = savestring (shopt_vars[i].name);
ret[i] = (char *)NULL;
return ret;
}
/*
* External interface for other parts of the shell. NAME is a string option;
* MODE is 0 if we want to unset an option; 1 if we want to set an option.
* REUSABLE is 1 if we want to print output in a form that may be reused.
*/
int
shopt_setopt (name, mode)
char *name;
int mode;
{
WORD_LIST *wl;
int r;
wl = add_string_to_list (name, (WORD_LIST *)NULL);
r = toggle_shopts (mode, wl, 0);
dispose_words (wl);
return r;
}
int
shopt_listopt (name, reusable)
char *name;
int reusable;
{
int i;
if (name == 0)
return (list_shopts ((WORD_LIST *)NULL, reusable ? PFLAG : 0));
i = find_shopt (name);
if (i < 0)
{
shopt_error (name);
return (EXECUTION_FAILURE);
}
print_shopt (name, *shopt_vars[i].value, reusable ? PFLAG : 0);
return (EXECUTION_SUCCESS);
}
+2 -2
View File
@@ -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
+268
View File
@@ -0,0 +1,268 @@
This file is trap.def, from which is created trap.c.
It implements the builtin "trap" in Bash.
Copyright (C) 1987-2006 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 trap.c
$BUILTIN trap
$FUNCTION trap_builtin
$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 supplied then the trap commands associated with each SIGNAL_SPEC are
displayed. If no arguments are supplied or if only `-p' is given, trap
prints the list of commands associated with each signal. Each SIGNAL_SPEC
is either a signal name in <signal.h> or a signal number. Signal names
are case insensitive and the SIG prefix is optional. `trap -l' prints
a list of signal names and their corresponding numbers. Note that a
signal can be sent to the shell with "kill -signal $$".
$END
#include <config.h>
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include "../bashtypes.h"
#include <signal.h>
#include <stdio.h>
#include "../bashansi.h"
#include "../shell.h"
#include "../trap.h"
#include "common.h"
#include "bashgetopt.h"
static void showtrap __P((int));
static int display_traps __P((WORD_LIST *));
/* The trap command:
trap <arg> <signal ...>
trap <signal ...>
trap -l
trap -p [sigspec ...]
trap [--]
Set things up so that ARG is executed when SIGNAL(s) N is recieved.
If ARG is the empty string, then ignore the SIGNAL(s). If there is
no ARG, then set the trap for SIGNAL(s) to its original value. Just
plain "trap" means to print out the list of commands associated with
each signal number. Single arg of "-l" means list the signal names. */
/* Possible operations to perform on the list of signals.*/
#define SET 0 /* Set this signal to first_arg. */
#define REVERT 1 /* Revert to this signals original value. */
#define IGNORE 2 /* Ignore this signal. */
extern int posixly_correct;
int
trap_builtin (list)
WORD_LIST *list;
{
int list_signal_names, display, result, opt;
list_signal_names = display = 0;
result = EXECUTION_SUCCESS;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "lp")) != -1)
{
switch (opt)
{
case 'l':
list_signal_names++;
break;
case 'p':
display++;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
opt = DSIG_NOCASE|DSIG_SIGPREFIX; /* flags for decode_signal */
if (list_signal_names)
return (display_signal_list ((WORD_LIST *)NULL, 1));
else if (display || list == 0)
return (display_traps (list));
else
{
char *first_arg;
int operation, sig, first_signal;
operation = SET;
first_arg = list->word->word;
first_signal = first_arg && *first_arg && all_digits (first_arg) && signal_object_p (first_arg, opt);
/* Backwards compatibility. XXX - question about whether or not we
should throw an error if an all-digit argument doesn't correspond
to a valid signal number (e.g., if it's `50' on a system with only
32 signals). */
if (first_signal)
operation = REVERT;
/* When in posix mode, the historical behavior of looking for a
missing first argument is disabled. To revert to the original
signal handling disposition, use `-' as the first argument. */
else if (posixly_correct == 0 && first_arg && *first_arg &&
(*first_arg != '-' || first_arg[1]) &&
signal_object_p (first_arg, opt) && list->next == 0)
operation = REVERT;
else
{
list = list->next;
if (list == 0)
{
builtin_usage ();
return (EX_USAGE);
}
else if (*first_arg == '\0')
operation = IGNORE;
else if (first_arg[0] == '-' && !first_arg[1])
operation = REVERT;
}
while (list)
{
sig = decode_signal (list->word->word, opt);
if (sig == NO_SIG)
{
sh_invalidsig (list->word->word);
result = EXECUTION_FAILURE;
}
else
{
switch (operation)
{
case SET:
set_signal (sig, first_arg);
break;
case REVERT:
restore_default_signal (sig);
/* Signals that the shell treats specially need special
handling. */
switch (sig)
{
case SIGINT:
if (interactive)
set_signal_handler (SIGINT, sigint_sighandler);
else
set_signal_handler (SIGINT, termsig_sighandler);
break;
case SIGQUIT:
/* Always ignore SIGQUIT. */
set_signal_handler (SIGQUIT, SIG_IGN);
break;
case SIGTERM:
#if defined (JOB_CONTROL)
case SIGTTIN:
case SIGTTOU:
case SIGTSTP:
#endif /* JOB_CONTROL */
if (interactive)
set_signal_handler (sig, SIG_IGN);
break;
}
break;
case IGNORE:
ignore_signal (sig);
break;
}
}
list = list->next;
}
}
return (result);
}
static void
showtrap (i)
int i;
{
char *t, *p, *sn;
p = trap_list[i];
if (p == (char *)DEFAULT_SIG)
return;
t = (p == (char *)IGNORE_SIG) ? (char *)NULL : sh_single_quote (p);
sn = signal_name (i);
/* Make sure that signals whose names are unknown (for whatever reason)
are printed as signal numbers. */
if (STREQN (sn, "SIGJUNK", 7) || STREQN (sn, "unknown", 7))
printf ("trap -- %s %d\n", t ? t : "''", i);
else if (posixly_correct)
{
if (STREQN (sn, "SIG", 3))
printf ("trap -- %s %s\n", t ? t : "''", sn+3);
else
printf ("trap -- %s %s\n", t ? t : "''", sn);
}
else
printf ("trap -- %s %s\n", t ? t : "''", sn);
FREE (t);
}
static int
display_traps (list)
WORD_LIST *list;
{
int result, i;
if (list == 0)
{
for (i = 0; i < BASH_NSIG; i++)
showtrap (i);
return (EXECUTION_SUCCESS);
}
for (result = EXECUTION_SUCCESS; list; list = list->next)
{
i = decode_signal (list->word->word, DSIG_NOCASE|DSIG_SIGPREFIX);
if (i == NO_SIG)
{
sh_invalidsig (list->word->word);
result = EXECUTION_FAILURE;
}
else
showtrap (i);
}
return (result);
}
+1 -1
View File
@@ -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);
+405
View File
@@ -0,0 +1,405 @@
This file is type.def, from which is created type.c.
It implements the builtin "type" in Bash.
Copyright (C) 1987-2002 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 type.c
$BUILTIN type
$FUNCTION type_builtin
$SHORT_DOC type [-afptP] name [name ...]
For each NAME, indicate how it would be interpreted if used as a
command name.
If the -t option is used, `type' outputs a single word which is one of
`alias', `keyword', `function', `builtin', `file' or `', if NAME is an
alias, shell reserved word, shell function, shell builtin, disk file,
or unfound, respectively.
If the -p flag is used, `type' either returns the name of the disk
file that would be executed, or nothing if `type -t NAME' would not
return `file'.
If the -a flag is used, `type' displays all of the places that contain
an executable named `file'. This includes aliases, builtins, and
functions, if and only if the -p flag is not also used.
The -f flag suppresses shell function lookup.
The -P flag forces a PATH search for each NAME, even if it is an alias,
builtin, or function, and returns the name of the disk file that would
be executed.
$END
#include <config.h>
#include "../bashtypes.h"
#include "posixstat.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include <stdio.h>
#include "../bashansi.h"
#include "../bashintl.h"
#include "../shell.h"
#include "../findcmd.h"
#include "../hashcmd.h"
#if defined (ALIAS)
#include "../alias.h"
#endif /* ALIAS */
#include "common.h"
#include "bashgetopt.h"
extern int find_reserved_word __P((char *));
extern char *this_command_name;
extern int expand_aliases, posixly_correct;
/* For each word in LIST, find out what the shell is going to do with
it as a simple command. i.e., which file would this shell use to
execve, or if it is a builtin command, or an alias. Possible flag
arguments:
-t Returns the "type" of the object, one of
`alias', `keyword', `function', `builtin',
or `file'.
-p Returns the pathname of the file if -type is
a file.
-a Returns all occurrences of words, whether they
be a filename in the path, alias, function,
or builtin.
-f Suppress shell function lookup, like `command'.
-P Force a path search even in the presence of other
definitions.
Order of evaluation:
alias
keyword
function
builtin
file
*/
int
type_builtin (list)
WORD_LIST *list;
{
int dflags, successful_finds, opt;
WORD_LIST *this;
if (list == 0)
return (EXECUTION_SUCCESS);
dflags = CDESC_SHORTDESC; /* default */
successful_finds = 0;
/* Handle the obsolescent `-type', `-path', and `-all' by prescanning
the arguments and converting those options to the form that
internal_getopt recognizes. Converts `--type', `--path', and `--all'
also. THIS SHOULD REALLY GO AWAY. */
for (this = list; this && this->word->word[0] == '-'; this = this->next)
{
char *flag = &(this->word->word[1]);
if (STREQ (flag, "type") || STREQ (flag, "-type"))
{
this->word->word[1] = 't';
this->word->word[2] = '\0';
}
else if (STREQ (flag, "path") || STREQ (flag, "-path"))
{
this->word->word[1] = 'p';
this->word->word[2] = '\0';
}
else if (STREQ (flag, "all") || STREQ (flag, "-all"))
{
this->word->word[1] = 'a';
this->word->word[2] = '\0';
}
}
reset_internal_getopt ();
while ((opt = internal_getopt (list, "afptP")) != -1)
{
switch (opt)
{
case 'a':
dflags |= CDESC_ALL;
break;
case 'f':
dflags |= CDESC_NOFUNCS;
break;
case 'p':
dflags |= CDESC_PATH_ONLY;
dflags &= ~(CDESC_TYPE|CDESC_SHORTDESC);
break;
case 't':
dflags |= CDESC_TYPE;
dflags &= ~(CDESC_PATH_ONLY|CDESC_SHORTDESC);
break;
case 'P': /* shorthand for type -ap */
dflags |= (CDESC_PATH_ONLY|CDESC_FORCE_PATH);
dflags &= ~(CDESC_TYPE|CDESC_SHORTDESC);
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
while (list)
{
int found;
found = describe_command (list->word->word, dflags);
if (!found && (dflags & (CDESC_PATH_ONLY|CDESC_TYPE)) == 0)
sh_notfound (list->word->word);
successful_finds += found;
list = list->next;
}
fflush (stdout);
return ((successful_finds != 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
/*
* Describe COMMAND as required by the type and command builtins.
*
* Behavior is controlled by DFLAGS. Flag values are
* CDESC_ALL print all descriptions of a command
* CDESC_SHORTDESC print the description for type and command -V
* CDESC_REUSABLE print in a format that may be reused as input
* CDESC_TYPE print the type for type -t
* CDESC_PATH_ONLY print the path for type -p
* CDESC_FORCE_PATH force a path search for type -P
* CDESC_NOFUNCS skip function lookup for type -f
* CDESC_ABSPATH convert to absolute path, no ./ prefix
*
* CDESC_ALL says whether or not to look for all occurrences of COMMAND, or
* return after finding it once.
*/
int
describe_command (command, dflags)
char *command;
int dflags;
{
int found, i, found_file, f, all;
char *full_path, *x;
SHELL_VAR *func;
#if defined (ALIAS)
alias_t *alias;
#endif
all = (dflags & CDESC_ALL) != 0;
found = found_file = 0;
full_path = (char *)NULL;
#if defined (ALIAS)
/* Command is an alias? */
if (((dflags & CDESC_FORCE_PATH) == 0) && expand_aliases && (alias = find_alias (command)))
{
if (dflags & CDESC_TYPE)
puts ("alias");
else if (dflags & CDESC_SHORTDESC)
printf (_("%s is aliased to `%s'\n"), command, alias->value);
else if (dflags & CDESC_REUSABLE)
{
x = sh_single_quote (alias->value);
printf ("alias %s=%s\n", command, x);
free (x);
}
found = 1;
if (all == 0)
return (1);
}
#endif /* ALIAS */
/* Command is a shell reserved word? */
if (((dflags & CDESC_FORCE_PATH) == 0) && (i = find_reserved_word (command)) >= 0)
{
if (dflags & CDESC_TYPE)
puts ("keyword");
else if (dflags & CDESC_SHORTDESC)
printf (_("%s is a shell keyword\n"), command);
else if (dflags & CDESC_REUSABLE)
printf ("%s\n", command);
found = 1;
if (all == 0)
return (1);
}
/* Command is a function? */
if (((dflags & (CDESC_FORCE_PATH|CDESC_NOFUNCS)) == 0) && (func = find_function (command)))
{
if (dflags & CDESC_TYPE)
puts ("function");
else if (dflags & CDESC_SHORTDESC)
{
#define PRETTY_PRINT_FUNC 1
char *result;
printf (_("%s is a function\n"), command);
/* We're blowing away THE_PRINTED_COMMAND here... */
result = named_function_string (command,
(COMMAND *) function_cell (func),
PRETTY_PRINT_FUNC);
printf ("%s\n", result);
#undef PRETTY_PRINT_FUNC
}
else if (dflags & CDESC_REUSABLE)
printf ("%s\n", command);
found = 1;
if (all == 0)
return (1);
}
/* Command is a builtin? */
if (((dflags & CDESC_FORCE_PATH) == 0) && find_shell_builtin (command))
{
if (dflags & CDESC_TYPE)
puts ("builtin");
else if (dflags & CDESC_SHORTDESC)
printf (_("%s is a shell builtin\n"), command);
else if (dflags & CDESC_REUSABLE)
printf ("%s\n", command);
found = 1;
if (all == 0)
return (1);
}
/* Command is a disk file? */
/* If the command name given is already an absolute command, just
check to see if it is executable. */
if (absolute_program (command))
{
f = file_status (command);
if (f & FS_EXECABLE)
{
if (dflags & CDESC_TYPE)
puts ("file");
else if (dflags & CDESC_SHORTDESC)
printf (_("%s is %s\n"), command, command);
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
printf ("%s\n", command);
/* There's no use looking in the hash table or in $PATH,
because they're not consulted when an absolute program
name is supplied. */
return (1);
}
}
/* If the user isn't doing "-a", then we might care about
whether the file is present in our hash table. */
if (all == 0 || (dflags & CDESC_FORCE_PATH))
{
if (full_path = phash_search (command))
{
if (dflags & CDESC_TYPE)
puts ("file");
else if (dflags & CDESC_SHORTDESC)
printf (_("%s is hashed (%s)\n"), command, full_path);
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
printf ("%s\n", full_path);
free (full_path);
return (1);
}
}
/* Now search through $PATH. */
while (1)
{
if (all == 0)
full_path = find_user_command (command);
else
full_path =
user_command_matches (command, FS_EXEC_ONLY, found_file);
/* XXX - should that be FS_EXEC_PREFERRED? */
if (!full_path)
break;
/* If we found the command as itself by looking through $PATH, it
probably doesn't exist. Check whether or not the command is an
executable file. If it's not, don't report a match. This is
the default posix mode behavior */
if (STREQ (full_path, command) || posixly_correct)
{
f = file_status (full_path);
if ((f & FS_EXECABLE) == 0)
{
free (full_path);
full_path = (char *)NULL;
if (all == 0)
break;
}
else if (ABSPATH (full_path))
; /* placeholder; don't need to do anything yet */
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY|CDESC_SHORTDESC))
{
f = MP_DOCWD | ((dflags & CDESC_ABSPATH) ? MP_RMDOT : 0);
full_path = sh_makepath ((char *)NULL, full_path, f);
}
}
/* If we require a full path and don't have one, make one */
else if ((dflags & CDESC_ABSPATH) && ABSPATH (full_path) == 0)
full_path = sh_makepath ((char *)NULL, full_path, MP_DOCWD|MP_RMDOT);
found_file++;
found = 1;
if (dflags & CDESC_TYPE)
puts ("file");
else if (dflags & CDESC_SHORTDESC)
printf ("%s is %s\n", command, full_path);
else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
printf ("%s\n", full_path);
free (full_path);
full_path = (char *)NULL;
if (all == 0)
break;
}
return (found);
}
+2 -2
View File
@@ -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.
@@ -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);
}
}
+1 -1
View File
@@ -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;
}
+2 -3
View File
@@ -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>
+175
View File
@@ -0,0 +1,175 @@
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.
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.
$BUILTIN wait
$FUNCTION wait_builtin
$DEPENDS_ON JOB_CONTROL
$PRODUCES wait.c
$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 may be a process ID or a job
specification; if a job spec is given, all processes in the job's
pipeline are waited for.
$END
$BUILTIN wait
$FUNCTION wait_builtin
$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 must be a process ID.
$END
#include <config.h>
#include "../bashtypes.h"
#include <signal.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include <chartypes.h>
#include "../bashansi.h"
#include "../shell.h"
#include "../jobs.h"
#include "common.h"
#include "bashgetopt.h"
extern int wait_signal_received;
procenv_t wait_intr_buf;
/* Wait for the pid in LIST to stop or die. If no arguments are given, then
wait for all of the active background processes of the shell and return
0. If a list of pids or job specs are given, return the exit status of
the last one waited for. */
#define WAIT_RETURN(s) \
do \
{ \
interrupt_immediately = old_interrupt_immediately;\
return (s);\
} \
while (0)
int
wait_builtin (list)
WORD_LIST *list;
{
int status, code;
volatile int old_interrupt_immediately;
USE_VAR(list);
if (no_options (list))
return (EX_USAGE);
list = loptend;
old_interrupt_immediately = interrupt_immediately;
interrupt_immediately++;
/* POSIX.2 says: When the shell is waiting (by means of the wait utility)
for asynchronous commands to complete, the reception of a signal for
which a trap has been set shall cause the wait utility to return
immediately with an exit status greater than 128, after which the trap
associated with the signal shall be taken.
We handle SIGINT here; it's the only one that needs to be treated
specially (I think), since it's handled specially in {no,}jobs.c. */
code = setjmp (wait_intr_buf);
if (code)
{
status = 128 + wait_signal_received;
WAIT_RETURN (status);
}
/* We support jobs or pids.
wait <pid-or-job> [pid-or-job ...] */
/* But wait without any arguments means to wait for all of the shell's
currently active background processes. */
if (list == 0)
{
wait_for_background_pids ();
WAIT_RETURN (EXECUTION_SUCCESS);
}
status = EXECUTION_SUCCESS;
while (list)
{
pid_t pid;
char *w;
intmax_t pid_value;
w = list->word->word;
if (DIGIT (*w))
{
if (legal_number (w, &pid_value) && pid_value == (pid_t)pid_value)
{
pid = (pid_t)pid_value;
status = wait_for_single_pid (pid);
}
else
{
sh_badpid (w);
WAIT_RETURN (EXECUTION_FAILURE);
}
}
#if defined (JOB_CONTROL)
else if (*w && *w == '%')
/* Must be a job spec. Check it out. */
{
int job;
sigset_t set, oset;
BLOCK_CHILD (set, oset);
job = get_job_spec (list);
if (INVALID_JOB (job))
{
if (job != DUP_JOB)
sh_badjob (list->word->word);
UNBLOCK_CHILD (oset);
status = 127; /* As per Posix.2, section 4.70.2 */
list = list->next;
continue;
}
/* Job spec used. Wait for the last pid in the pipeline. */
UNBLOCK_CHILD (oset);
status = wait_for_job (job);
}
#endif /* JOB_CONTROL */
else
{
sh_badpid (w);
status = EXECUTION_FAILURE;
}
list = list->next;
}
WAIT_RETURN (status);
}
+3 -3
View File
@@ -1,4 +1,4 @@
This is the Bash FAQ, version 3.34, for Bash version 3.2.
This is the Bash FAQ, version 3.35, for Bash version 3.2.
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
@@ -1791,8 +1791,8 @@ it in fine bookstores near you. This edition of the book has been updated
to cover bash-3.0.
The GNU Bash Reference Manual has been published as a printed book by
Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Feb 2003). It covers
bash-2.0 and is available from most online bookstores (see
Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Nov. 2006). It covers
bash-3.2 and is available from most online bookstores (see
http://www.network-theory.co.uk/bash/manual/ for details). The publisher
will donate $1 to the Free Software Foundation for each copy sold.
+90 -83
View File
@@ -1336,12 +1336,16 @@ EEXXPPAANNSSIIOONN
Note that a negative offset must be separated from the colon by
at least one space to avoid being confused with the :- expan-
sion. Substring indexing is zero-based unless the positional
parameters are used, in which case the indexing starts at 1.
parameters are used, in which case the indexing starts at 1 by
default. If _o_f_f_s_e_t is 0, and the positional parameters are
used, $$00 is prefixed to the list.
${!!_p_r_e_f_i_x**}
${!!_p_r_e_f_i_x@@}
Expands to the names of variables whose names begin with _p_r_e_f_i_x,
separated by the first character of the IIFFSS special variable.
separated by the first character of the IIFFSS special variable.
When _@ is used and the expansion appears within double quotes,
each variable name expands to a separate word.
${!!_n_a_m_e[_@]}
${!!_n_a_m_e[_*]}
@@ -3689,64 +3693,67 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
environment.
Using `+' instead of `-' turns off the attribute instead, with
the exception that ++aa may not be used to destroy an array vari-
able. When used in a function, makes each _n_a_m_e local, as with
the llooccaall command. If a variable name is followed by =_v_a_l_u_e,
the value of the variable is set to _v_a_l_u_e. The return value is
0 unless an invalid option is encountered, an attempt is made to
define a function using ``-f foo=bar'', an attempt is made to
assign a value to a readonly variable, an attempt is made to
assign a value to an array variable without using the compound
assignment syntax (see AArrrraayyss above), one of the _n_a_m_e_s is not a
valid shell variable name, an attempt is made to turn off read-
only status for a readonly variable, an attempt is made to turn
off array status for an array variable, or an attempt is made to
display a non-existent function with --ff.
the exceptions that ++aa may not be used to destroy an array vari-
able and ++rr wwiillll nnoott rreemmoovvee tthhee rreeaaddoonnllyy aattttrriibbuuttee.. WWhheenn uusseedd
iinn aa ffuunnccttiioonn,, mmaakkeess eeaacchh _n_a_m_e llooccaall,, aass wwiitthh tthhee llooccaall command.
If a variable name is followed by =_v_a_l_u_e, the value of the vari-
able is set to _v_a_l_u_e. The return value is 0 unless an invalid
option is encountered, an attempt is made to define a function
using ``-f foo=bar'', an attempt is made to assign a value to a
readonly variable, an attempt is made to assign a value to an
array variable without using the compound assignment syntax (see
AArrrraayyss above), one of the _n_a_m_e_s is not a valid shell variable
name, an attempt is made to turn off readonly status for a read-
only variable, an attempt is made to turn off array status for
an array variable, or an attempt is made to display a non-exis-
tent function with --ff.
ddiirrss [[--ccllppvv]] [[++_n]] [[--_n]]
Without options, displays the list of currently remembered
directories. The default display is on a single line with
directory names separated by spaces. Directories are added to
the list with the ppuusshhdd command; the ppooppdd command removes
ddiirrss [[++_n]] [[--_n]] [[--ccppllvv]]
Without options, displays the list of currently remembered
directories. The default display is on a single line with
directory names separated by spaces. Directories are added to
the list with the ppuusshhdd command; the ppooppdd command removes
entries from the list.
++_n Displays the _nth entry counting from the left of the list
shown by ddiirrss when invoked without options, starting with
zero.
--_n Displays the _nth entry counting from the right of the
--_n Displays the _nth entry counting from the right of the
list shown by ddiirrss when invoked without options, starting
with zero.
--cc Clears the directory stack by deleting all of the
entries.
--ll Produces a longer listing; the default listing format
--ll Produces a longer listing; the default listing format
uses a tilde to denote the home directory.
--pp Print the directory stack with one entry per line.
--vv Print the directory stack with one entry per line, pre-
--vv Print the directory stack with one entry per line, pre-
fixing each entry with its index in the stack.
The return value is 0 unless an invalid option is supplied or _n
The return value is 0 unless an invalid option is supplied or _n
indexes beyond the end of the directory stack.
ddiissoowwnn [--aarr] [--hh] [_j_o_b_s_p_e_c ...]
Without options, each _j_o_b_s_p_e_c is removed from the table of
active jobs. If the --hh option is given, each _j_o_b_s_p_e_c is not
removed from the table, but is marked so that SSIIGGHHUUPP is not sent
to the job if the shell receives a SSIIGGHHUUPP. If no _j_o_b_s_p_e_c is
present, and neither the --aa nor the --rr option is supplied, the
_c_u_r_r_e_n_t _j_o_b is used. If no _j_o_b_s_p_e_c is supplied, the --aa option
means to remove or mark all jobs; the --rr option without a _j_o_b_-
_s_p_e_c argument restricts operation to running jobs. The return
value is 0 unless a _j_o_b_s_p_e_c does not specify a valid job.
Without options, each _j_o_b_s_p_e_c is removed from the table of
active jobs. If _j_o_b_s_p_e_c is not present, and neither --aa nnoorr --rr
iiss ssuupppplliieedd,, tthhee sshheellll''ss nnoottiioonn ooff tthhee _c_u_r_r_e_n_t _j_o_b iiss uusseedd.. IIff
tthhee --hh ooppttiioonn iiss ggiivveenn,, eeaacchh _j_o_b_s_p_e_c is not removed from the ta-
ble, but is marked so that SSIIGGHHUUPP is not sent to the job if the
shell receives a SSIIGGHHUUPP. If no _j_o_b_s_p_e_c is present, and neither
the --aa nor the --rr option is supplied, the _c_u_r_r_e_n_t _j_o_b is used.
If no _j_o_b_s_p_e_c is supplied, the --aa option means to remove or mark
all jobs; the --rr option without a _j_o_b_s_p_e_c argument restricts
operation to running jobs. The return value is 0 unless a _j_o_b_-
_s_p_e_c does not specify a valid job.
eecchhoo [--nneeEE] [_a_r_g ...]
Output the _a_r_gs, separated by spaces, followed by a newline.
Output the _a_r_gs, separated by spaces, followed by a newline.
The return status is always 0. If --nn is specified, the trailing
newline is suppressed. If the --ee option is given, interpreta-
tion of the following backslash-escaped characters is enabled.
The --EE option disables the interpretation of these escape char-
acters, even on systems where they are interpreted by default.
The xxppgg__eecchhoo shell option may be used to dynamically determine
whether or not eecchhoo expands these escape characters by default.
eecchhoo does not interpret ---- to mean the end of options. eecchhoo
newline is suppressed. If the --ee option is given, interpreta-
tion of the following backslash-escaped characters is enabled.
The --EE option disables the interpretation of these escape char-
acters, even on systems where they are interpreted by default.
The xxppgg__eecchhoo shell option may be used to dynamically determine
whether or not eecchhoo expands these escape characters by default.
eecchhoo does not interpret ---- to mean the end of options. eecchhoo
interprets the following escape sequences:
\\aa alert (bell)
\\bb backspace
@@ -3758,52 +3765,52 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
\\tt horizontal tab
\\vv vertical tab
\\\\ backslash
\\00_n_n_n the eight-bit character whose value is the octal value
\\00_n_n_n the eight-bit character whose value is the octal value
_n_n_n (zero to three octal digits)
\\xx_H_H the eight-bit character whose value is the hexadecimal
\\xx_H_H the eight-bit character whose value is the hexadecimal
value _H_H (one or two hex digits)
eennaabbllee [--aaddnnppss] [--ff _f_i_l_e_n_a_m_e] [_n_a_m_e ...]
Enable and disable builtin shell commands. Disabling a builtin
Enable and disable builtin shell commands. Disabling a builtin
allows a disk command which has the same name as a shell builtin
to be executed without specifying a full pathname, even though
the shell normally searches for builtins before disk commands.
If --nn is used, each _n_a_m_e is disabled; otherwise, _n_a_m_e_s are
to be executed without specifying a full pathname, even though
the shell normally searches for builtins before disk commands.
If --nn is used, each _n_a_m_e is disabled; otherwise, _n_a_m_e_s are
enabled. For example, to use the tteesstt binary found via the PPAATTHH
instead of the shell builtin version, run ``enable -n test''.
The --ff option means to load the new builtin command _n_a_m_e from
instead of the shell builtin version, run ``enable -n test''.
The --ff option means to load the new builtin command _n_a_m_e from
shared object _f_i_l_e_n_a_m_e, on systems that support dynamic loading.
The --dd option will delete a builtin previously loaded with --ff.
The --dd option will delete a builtin previously loaded with --ff.
If no _n_a_m_e arguments are given, or if the --pp option is supplied,
a list of shell builtins is printed. With no other option argu-
ments, the list consists of all enabled shell builtins. If --nn
is supplied, only disabled builtins are printed. If --aa is sup-
plied, the list printed includes all builtins, with an indica-
tion of whether or not each is enabled. If --ss is supplied, the
output is restricted to the POSIX _s_p_e_c_i_a_l builtins. The return
value is 0 unless a _n_a_m_e is not a shell builtin or there is an
ments, the list consists of all enabled shell builtins. If --nn
is supplied, only disabled builtins are printed. If --aa is sup-
plied, the list printed includes all builtins, with an indica-
tion of whether or not each is enabled. If --ss is supplied, the
output is restricted to the POSIX _s_p_e_c_i_a_l builtins. The return
value is 0 unless a _n_a_m_e is not a shell builtin or there is an
error loading a new builtin from a shared object.
eevvaall [_a_r_g ...]
The _a_r_gs are read and concatenated together into a single com-
mand. This command is then read and executed by the shell, and
its exit status is returned as the value of eevvaall. If there are
The _a_r_gs are read and concatenated together into a single com-
mand. This command is then read and executed by the shell, and
its exit status is returned as the value of eevvaall. If there are
no _a_r_g_s, or only null arguments, eevvaall returns 0.
eexxeecc [--ccll] [--aa _n_a_m_e] [_c_o_m_m_a_n_d [_a_r_g_u_m_e_n_t_s]]
If _c_o_m_m_a_n_d is specified, it replaces the shell. No new process
is created. The _a_r_g_u_m_e_n_t_s become the arguments to _c_o_m_m_a_n_d. If
If _c_o_m_m_a_n_d is specified, it replaces the shell. No new process
is created. The _a_r_g_u_m_e_n_t_s become the arguments to _c_o_m_m_a_n_d. If
the --ll option is supplied, the shell places a dash at the begin-
ning of the zeroth arg passed to _c_o_m_m_a_n_d. This is what _l_o_g_i_n(1)
does. The --cc option causes _c_o_m_m_a_n_d to be executed with an empty
environment. If --aa is supplied, the shell passes _n_a_m_e as the
zeroth argument to the executed command. If _c_o_m_m_a_n_d cannot be
executed for some reason, a non-interactive shell exits, unless
the shell option eexxeeccffaaiill is enabled, in which case it returns
failure. An interactive shell returns failure if the file can-
not be executed. If _c_o_m_m_a_n_d is not specified, any redirections
take effect in the current shell, and the return status is 0.
If there is a redirection error, the return status is 1.
ning of the zeroth argument passed to _c_o_m_m_a_n_d. This is what
_l_o_g_i_n(1) does. The --cc option causes _c_o_m_m_a_n_d to be executed with
an empty environment. If --aa is supplied, the shell passes _n_a_m_e
as the zeroth argument to the executed command. If _c_o_m_m_a_n_d can-
not be executed for some reason, a non-interactive shell exits,
unless the shell option eexxeeccffaaiill is enabled, in which case it
returns failure. An interactive shell returns failure if the
file cannot be executed. If _c_o_m_m_a_n_d is not specified, any redi-
rections take effect in the current shell, and the return status
is 0. If there is a redirection error, the return status is 1.
eexxiitt [_n]
Cause the shell to exit with a status of _n. If _n is omitted,
@@ -4043,6 +4050,9 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
removes the top directory from the stack, and performs a ccdd to
the new top directory. Arguments, if supplied, have the follow-
ing meanings:
--nn Suppresses the normal change of directory when removing
directories from the stack, so that only the stack is
manipulated.
++_n Removes the _nth entry counting from the left of the list
shown by ddiirrss, starting with zero. For example: ``popd
+0'' removes the first directory, ``popd +1'' the second.
@@ -4050,9 +4060,6 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
shown by ddiirrss, starting with zero. For example: ``popd
-0'' removes the last directory, ``popd -1'' the next to
last.
--nn Suppresses the normal change of directory when removing
directories from the stack, so that only the stack is
manipulated.
If the ppooppdd command is successful, a ddiirrss is performed as well,
and the return status is 0. ppooppdd returns false if an invalid
@@ -4084,22 +4091,22 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
null string, as appropriate, had been supplied. The return
value is zero on success, non-zero on failure.
ppuusshhdd [--nn] [_d_i_r]
ppuusshhdd [--nn] [+_n] [-_n]
ppuusshhdd [--nn] [_d_i_r]
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
and returns 0, unless the directory stack is empty. Arguments,
if supplied, have the following meanings:
--nn Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is
manipulated.
++_n Rotates the stack so that the _nth directory (counting
from the left of the list shown by ddiirrss, 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 ddiirrss, starting with
zero) is at the top.
--nn Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is
manipulated.
_d_i_r Adds _d_i_r to the directory stack at the top, making it the
new current working directory.
@@ -4214,10 +4221,10 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
above) exits with a non-zero status. The shell does not
exit if the command that fails is part of the command
list immediately following a wwhhiillee or uunnttiill keyword,
part of the test in an _i_f statement, part of a &&&& or ||||
list, or if the command's return value is being inverted
via !!. A trap on EERRRR, if set, is executed before the
shell exits.
part of the test in an iiff statement, part of a &&&& or ||||
list, any command in a pipeline but the last, or if the
command's return value is being inverted via !!. A trap
on EERRRR, if set, is executed before the shell exits.
--ff Disable pathname expansion.
--hh Remember the location of commands as they are looked up
for execution. This is enabled by default.
@@ -4883,4 +4890,4 @@ BBUUGGSS
GNU Bash-3.2 2006 September 28 BASH(1)
GNU Bash-3.2 2006 November 27 BASH(1)
+13 -13
View File
@@ -6045,13 +6045,6 @@ that they can be re-read.
.B \-P
List current \fBreadline\fP function names and bindings.
.TP
.B \-v
Display \fBreadline\fP variable names and values in such a way that they
can be re-read.
.TP
.B \-V
List current \fBreadline\fP variable names and values.
.TP
.B \-s
Display \fBreadline\fP key sequences bound to macros and the strings
they output in such a way that they can be re-read.
@@ -6060,6 +6053,13 @@ they output in such a way that they can be re-read.
Display \fBreadline\fP key sequences bound to macros and the strings
they output.
.TP
.B \-v
Display \fBreadline\fP variable names and values in such a way that they
can be re-read.
.TP
.B \-V
List current \fBreadline\fP variable names and values.
.TP
.B \-f \fIfilename\fP
Read key bindings from \fIfilename\fP.
.TP
@@ -6232,9 +6232,9 @@ will be displayed.
The return value is true unless an invalid option is supplied, or no
matches were generated.
.TP
\fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
\fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP]
.br
[\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP]
[\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname ...\fP]
.PD 0
.TP
\fBcomplete\fP \fB\-pr\fP [\fIname\fP ...]
@@ -6664,7 +6664,7 @@ the eight-bit character whose value is the hexadecimal value \fIHH\fP
.PD
.RE
.TP
\fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
\fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
Enable and disable builtin shell commands.
Disabling a builtin allows a disk command which has the same name
as a shell builtin to be executed without specifying a full pathname,
@@ -6796,7 +6796,7 @@ is supplied with a
.I name
that is not a function.
.TP
\fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
\fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP]
.PD 0
.TP
\fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
@@ -7417,7 +7417,7 @@ The return status is 0 unless an error occurs while
reading the name of the current directory or an
invalid option is supplied.
.TP
\fBread\fP [\fB\-ers\fP] [\fB\-u\fP \fIfd\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...]
\fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...]
One line is read from the standard input, or from the file descriptor
\fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
is assigned to the first
@@ -7553,7 +7553,7 @@ the return status is false.
Any command associated with the \fBRETURN\fP trap is executed
before execution resumes after the function or script.
.TP
\fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
\fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
Without options, the name and value of each shell variable are displayed
in a format that can be reused as input
for setting or resetting the currently-set variables.
+40 -30
View File
@@ -6,12 +6,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Tue Nov 21 10:50:26 EST 2006
.\" Last Change: Mon Nov 27 12:02:01 EST 2006
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2006 November 21" "GNU Bash-3.2"
.TH BASH 1 "2006 November 27" "GNU Bash-3.2"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -5985,8 +5985,9 @@ no alias has been defined.
Resume each suspended job \fIjobspec\fP in the background, as if it
had been started with
.BR & .
If \fIjobspec\fP is not present, the shell's notion of the
\fIcurrent job\fP is used.
If
.I jobspec
is not present, the shell's notion of the \fIcurrent job\fP is used.
.B bg
.I jobspec
returns 0 unless run when job control is disabled or, when run with
@@ -6044,13 +6045,6 @@ that they can be re-read.
.B \-P
List current \fBreadline\fP function names and bindings.
.TP
.B \-v
Display \fBreadline\fP variable names and values in such a way that they
can be re-read.
.TP
.B \-V
List current \fBreadline\fP variable names and values.
.TP
.B \-s
Display \fBreadline\fP key sequences bound to macros and the strings
they output in such a way that they can be re-read.
@@ -6059,6 +6053,13 @@ they output in such a way that they can be re-read.
Display \fBreadline\fP key sequences bound to macros and the strings
they output.
.TP
.B \-v
Display \fBreadline\fP variable names and values in such a way that they
can be re-read.
.TP
.B \-V
List current \fBreadline\fP variable names and values.
.TP
.B \-f \fIfilename\fP
Read key bindings from \fIfilename\fP.
.TP
@@ -6231,9 +6232,9 @@ will be displayed.
The return value is true unless an invalid option is supplied, or no
matches were generated.
.TP
\fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
\fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP]
.br
[\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP]
[\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname ...\fP]
.PD 0
.TP
\fBcomplete\fP \fB\-pr\fP [\fIname\fP ...]
@@ -6499,8 +6500,11 @@ Mark \fIname\fPs for export to subsequent commands via the environment.
.PD
.PP
Using `+' instead of `\-'
turns off the attribute instead, with the exception that \fB+a\fP
may not be used to destroy an array variable. When used in a function,
turns off the attribute instead,
with the exceptions that \fB+a\fP
may not be used to destroy an array variable and \fB+r\fB will not
remove the readonly attribute.
When used in a function,
makes each
\fIname\fP local, as with the
.B local
@@ -6569,6 +6573,10 @@ of the directory stack.
Without options, each
.I jobspec
is removed from the table of active jobs.
If
.I jobspec
is not present, and neither \fB\-a\fB nor \fB\-r\fP is supplied,
the shell's notion of the \fIcurrent job\fP is used.
If the \fB\-h\fP option is given, each
.I jobspec
is not removed from the table, but is marked so that
@@ -6656,7 +6664,7 @@ the eight-bit character whose value is the hexadecimal value \fIHH\fP
.PD
.RE
.TP
\fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
\fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
Enable and disable builtin shell commands.
Disabling a builtin allows a disk command which has the same name
as a shell builtin to be executed without specifying a full pathname,
@@ -6788,7 +6796,7 @@ is supplied with a
.I name
that is not a function.
.TP
\fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
\fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP]
.PD 0
.TP
\fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
@@ -7274,6 +7282,10 @@ Arguments, if supplied, have the following meanings:
.RS
.PD 0
.TP
.B \-n
Suppresses the normal change of directory when removing directories
from the stack, so that only the stack is manipulated.
.TP
\fB+\fP\fIn\fP
Removes the \fIn\fPth entry counting from the left of the list
shown by
@@ -7297,10 +7309,6 @@ removes the last directory,
.if n ``popd -1''
.if t \f(CWpopd -1\fP
the next to last.
.TP
.B \-n
Suppresses the normal change of directory when removing directories
from the stack, so that only the stack is manipulated.
.PD
.PP
If the
@@ -7339,10 +7347,10 @@ extra format specifications behave as if a zero value or null string, as
appropriate, had been supplied. The return value is zero on success,
non-zero on failure.
.TP
\fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
\fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
.PD 0
.TP
\fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
\fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
.PD
Adds a directory to the top of the directory stack, or rotates
the stack, making the new top of the stack the current working
@@ -7352,6 +7360,10 @@ Arguments, if supplied, have the following meanings:
.RS
.PD 0
.TP
.B \-n
Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
.TP
\fB+\fP\fIn\fP
Rotates the stack so that the \fIn\fPth directory
(counting from the left of the list shown by
@@ -7365,10 +7377,6 @@ Rotates the stack so that the \fIn\fPth directory
.BR dirs ,
starting with zero) is at the top.
.TP
.B \-n
Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
.TP
.I dir
Adds
.I dir
@@ -7545,7 +7553,7 @@ the return status is false.
Any command associated with the \fBRETURN\fP trap is executed
before execution resumes after the function or script.
.TP
\fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
\fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
Without options, the name and value of each shell variable are displayed
in a format that can be reused as input
for setting or resetting the currently-set variables.
@@ -7584,12 +7592,14 @@ or
.B until
keyword,
part of the test in an
.I if
.B if
statement, part of a
.B &&
or
.B \(bv\(bv
list, or if the command's return value is
list,
any command in a pipeline but the last,
or if the command's return value is
being inverted via
.BR ! .
A trap on \fBERR\fP, if set, is executed before the shell exits.
+44 -26
View File
@@ -3,7 +3,7 @@
</HEAD>
<BODY><TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2006 September 28<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2006 November 27<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<BR><A HREF="#index">Index</A>
@@ -1829,7 +1829,9 @@ An array variable containing the names of all shell functions
currently in the execution call stack.
The element with index 0 is the name of any currently-executing
shell function.
The bottom-most element is &quot;main&quot;.
The bottom-most element is
<TT>&quot;main&quot;</TT>.
This variable exists only when a shell function is executing.
Assignments to
<FONT SIZE=-1><B>FUNCNAME</B>
@@ -3121,7 +3123,9 @@ index of the specified array.
Note that a negative offset must be separated from the colon by at least
one space to avoid being confused with the :- expansion.
Substring indexing is zero-based unless the positional parameters
are used, in which case the indexing starts at 1.
are used, in which case the indexing starts at 1 by default.
If <I>offset</I> is 0, and the positional parameters are used, <B>$0</B> is
prefixed to the list.
<DT>${<B>!</B><I>prefix</I><B>*</B>}<DD>
<DT>${<B>!</B><I>prefix</I><B>@</B>}<DD>
@@ -3132,6 +3136,8 @@ separated by the first character of the
</FONT>
special variable.
When <I>@</I> is used and the expansion appears within double quotes, each
variable name expands to a separate word.
<DT>${<B>!</B><I>name</I>[<I>@</I>]}<DD>
<DT>${<B>!</B><I>name</I>[<I>*</I>]}<DD>
@@ -7774,8 +7780,10 @@ Resume each suspended job <I>jobspec</I> in the background, as if it
had been started with
<B>&amp;</B>.
If <I>jobspec</I> is not present, the shell's notion of the
<I>current job</I> is used.
If
<I>jobspec</I>
is not present, the shell's notion of the <I>current job</I> is used.
<B>bg</B>
<I>jobspec</I>
@@ -8398,10 +8406,13 @@ Mark <I>name</I>s for export to subsequent commands via the environment.
<P>
Using `+' instead of `-'
turns off the attribute instead, with the exception that <B>+a</B>
may not be used to destroy an array variable. When used in a function,
turns off the attribute instead,
with the exceptions that <B>+a</B>
may not be used to destroy an array variable and <B>+r will not
remove the readonly attribute.
When used in a function,
makes each
<I>name</I> local, as with the
</B><I>name</I> local, as with the
<B>local</B>
command.
@@ -8422,7 +8433,7 @@ an attempt is made to turn off array status for an array variable,
or an attempt is made to display a non-existent function with <B>-f</B>.
</DL>
<DT><B>dirs [-clpv</B>] [+<I>n</I>] [-<I>n</I>]
<DT><B>dirs [+</B><I>n</I>] [-<I>n</I>] [<B>-cplv</B>]
<DD>
Without options, displays the list of currently remembered directories.
@@ -8482,6 +8493,11 @@ Without options, each
<I>jobspec</I>
is removed from the table of active jobs.
If
<I>jobspec</I>
is not present, and neither <B>-a nor -r</B> is supplied,
the shell's notion of the <I>current job</I> is used.
If the <B>-h</B> option is given, each
<I>jobspec</I>
@@ -8669,7 +8685,7 @@ If the
<B>-l</B>
option is supplied,
the shell places a dash at the beginning of the zeroth arg passed to
the shell places a dash at the beginning of the zeroth argument passed to
<I>command</I>.
This is what
@@ -9359,6 +9375,11 @@ Arguments, if supplied, have the following meanings:
<DL COMPACT><DT><DD>
<DL COMPACT>
<DT><B>-n</B>
<DD>
Suppresses the normal change of directory when removing directories
from the stack, so that only the stack is manipulated.
<DT><B>+</B><I>n</I><DD>
Removes the <I>n</I>th entry counting from the left of the list
shown by
@@ -9383,11 +9404,6 @@ removes the last directory,
<TT>popd -1</TT>
the next to last.
<DT><B>-n</B>
<DD>
Suppresses the normal change of directory when removing directories
from the stack, so that only the stack is manipulated.
</DL>
<P>
@@ -9430,10 +9446,10 @@ If the <I>format</I> requires more <I>arguments</I> than are supplied, the
extra format specifications behave as if a zero value or null string, as
appropriate, had been supplied. The return value is zero on success,
non-zero on failure.
<DT><B>pushd</B> [<B>-n</B>] [<I>dir</I>]<DD>
<DT><B>pushd</B> [<B>-n</B>] [+<I>n</I>] [-<I>n</I>]<DD>
<DT><B>pushd</B> [<B>-n</B>] [<I>dir</I>]<DD>
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
@@ -9442,6 +9458,11 @@ Arguments, if supplied, have the following meanings:
<DL COMPACT><DT><DD>
<DL COMPACT>
<DT><B>-n</B>
<DD>
Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
<DT><B>+</B><I>n</I><DD>
Rotates the stack so that the <I>n</I>th directory
(counting from the left of the list shown by
@@ -9455,11 +9476,6 @@ Rotates the stack so that the <I>n</I>th directory
<B>dirs</B>,
starting with zero) is at the top.
<DT><B>-n</B>
<DD>
Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
<DT><I>dir</I>
<DD>
@@ -9732,7 +9748,7 @@ or
keyword,
part of the test in an
<I>if</I>
<B>if</B>
statement, part of a
<B>&amp;&amp;</B>
@@ -9740,7 +9756,9 @@ statement, part of a
or
<B>||</B>
list, or if the command's return value is
list,
any command in a pipeline but the last,
or if the command's return value is
being inverted via
<B>!</B>.
@@ -11433,7 +11451,7 @@ Array variables may not (yet) be exported.
<HR>
<TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>GNU Bash-3.2<TH ALIGN=CENTER width=33%>2006 September 28<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>GNU Bash-3.2<TH ALIGN=CENTER width=33%>2006 November 27<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<HR>
@@ -11537,6 +11555,6 @@ Array variables may not (yet) be exported.
</DL>
<HR>
This document was created by man2html from bash.1.<BR>
Time: 03 October 2006 08:54:31 EDT
Time: 12 December 2006 14:43:32 EST
</BODY>
</HTML>
+1201 -1166
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -98,13 +98,13 @@
@xrdef{Process Substitution-pg}{22}
@xrdef{Process Substitution-snt}{Section@tie 3.5.6}
@xrdef{Word Splitting-title}{Word Splitting}
@xrdef{Word Splitting-pg}{22}
@xrdef{Word Splitting-pg}{23}
@xrdef{Word Splitting-snt}{Section@tie 3.5.7}
@xrdef{Filename Expansion-title}{Filename Expansion}
@xrdef{Filename Expansion-pg}{23}
@xrdef{Filename Expansion-snt}{Section@tie 3.5.8}
@xrdef{Pattern Matching-title}{Pattern Matching}
@xrdef{Pattern Matching-pg}{23}
@xrdef{Pattern Matching-pg}{24}
@xrdef{Pattern Matching-snt}{Section@tie 3.5.8.1}
@xrdef{Quote Removal-title}{Quote Removal}
@xrdef{Quote Removal-pg}{25}
@@ -122,10 +122,10 @@
@xrdef{Command Search and Execution-pg}{29}
@xrdef{Command Search and Execution-snt}{Section@tie 3.7.2}
@xrdef{Command Execution Environment-title}{Command Execution Environment}
@xrdef{Command Execution Environment-pg}{29}
@xrdef{Command Execution Environment-pg}{30}
@xrdef{Command Execution Environment-snt}{Section@tie 3.7.3}
@xrdef{Environment-title}{Environment}
@xrdef{Environment-pg}{30}
@xrdef{Environment-pg}{31}
@xrdef{Environment-snt}{Section@tie 3.7.4}
@xrdef{Exit Status-title}{Exit Status}
@xrdef{Exit Status-pg}{31}
+5 -5
View File
@@ -54,19 +54,19 @@
\entry{expansion, arithmetic}{22}{expansion, arithmetic}
\entry{arithmetic expansion}{22}{arithmetic expansion}
\entry{process substitution}{22}{process substitution}
\entry{word splitting}{22}{word splitting}
\entry{word splitting}{23}{word splitting}
\entry{expansion, filename}{23}{expansion, filename}
\entry{expansion, pathname}{23}{expansion, pathname}
\entry{filename expansion}{23}{filename expansion}
\entry{pathname expansion}{23}{pathname expansion}
\entry{pattern matching}{23}{pattern matching}
\entry{matching, pattern}{23}{matching, pattern}
\entry{pattern matching}{24}{pattern matching}
\entry{matching, pattern}{24}{matching, pattern}
\entry{redirection}{25}{redirection}
\entry{command expansion}{28}{command expansion}
\entry{command execution}{29}{command execution}
\entry{command search}{29}{command search}
\entry{execution environment}{29}{execution environment}
\entry{environment}{30}{environment}
\entry{execution environment}{30}{execution environment}
\entry{environment}{31}{environment}
\entry{exit status}{31}{exit status}
\entry{signal handling}{31}{signal handling}
\entry{shell script}{32}{shell script}
+5 -5
View File
@@ -35,10 +35,10 @@
\entry {directory stack}{77}
\initial {E}
\entry {editing command lines}{89}
\entry {environment}{30}
\entry {environment}{31}
\entry {evaluation, arithmetic}{74}
\entry {event designators}{117}
\entry {execution environment}{29}
\entry {execution environment}{30}
\entry {exit status}{3, 31}
\entry {expansion}{17}
\entry {expansion, arithmetic}{22}
@@ -79,7 +79,7 @@
\entry {localization}{7}
\entry {login shell}{69}
\initial {M}
\entry {matching, pattern}{23}
\entry {matching, pattern}{24}
\entry {metacharacter}{3}
\initial {N}
\entry {name}{3}
@@ -93,7 +93,7 @@
\entry {parameters, positional}{15}
\entry {parameters, special}{16}
\entry {pathname expansion}{23}
\entry {pattern matching}{23}
\entry {pattern matching}{24}
\entry {pipeline}{8}
\entry {POSIX}{3}
\entry {POSIX Mode}{80}
@@ -131,6 +131,6 @@
\entry {variables, readline}{93}
\initial {W}
\entry {word}{4}
\entry {word splitting}{22}
\entry {word splitting}{23}
\initial {Y}
\entry {yanking text}{91}
BIN
View File
Binary file not shown.
+35 -27
View File
@@ -1,6 +1,6 @@
<HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created on September, 28 2006 by texi2html 1.64 -->
<!-- Created on December, 12 2006 by texi2html 1.64 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
@@ -33,10 +33,10 @@ Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
<H1>Bash Reference Manual</H1></P><P>
This text is a brief description of the features that are present in
the Bash shell (version 3.2, 28 September 2006).
the Bash shell (version 3.2, 27 November 2006).
</P><P>
This is Edition 3.2, last updated 28 September 2006,
This is Edition 3.2, last updated 27 November 2006,
of <CITE>The GNU Bash Reference Manual</CITE>,
for <CODE>Bash</CODE>, Version 3.2.
</P><P>
@@ -176,7 +176,7 @@ and symbols are expanded to create larger expressions.
A Unix shell is both a command interpreter and a programming
language. As a command interpreter, the shell provides the user
interface to the rich set of GNU utilities. The programming
language features allow these utilitites to be combined.
language features allow these utilities to be combined.
Files containing commands can be created, and become
commands themselves. These new commands have the same status as
system commands in directories such as <TT>`/bin'</TT>, allowing users
@@ -334,7 +334,7 @@ group ID.
<DT><CODE>process group ID</CODE>
<DD><A NAME="IDX14"></A>
A unique identifer that represents a <CODE>process group</CODE>
A unique identifier that represents a <CODE>process group</CODE>
during its lifetime.
<P>
@@ -1236,7 +1236,7 @@ The list of words following <CODE>in</CODE> is expanded, generating a list
of items. The set of expanded words is printed on the standard
error output stream, each preceded by a number. If the
<SAMP>`in <VAR>words</VAR>'</SAMP> is omitted, the positional parameters are printed,
as if <SAMP>`in "$@"'</SAMP> had been specifed.
as if <SAMP>`in "$@"'</SAMP> had been specified.
The <CODE>PS3</CODE> prompt is then displayed and a line is read from the
standard input.
If the line consists of a number corresponding to one of the displayed
@@ -1865,7 +1865,7 @@ This mechanism is similar to
<VAR>filename expansion</VAR> (see section <A HREF="bashref.html#SEC35">3.5.8 Filename Expansion</A>),
but the file names generated need not exist.
Patterns to be brace expanded take the form of an optional <VAR>preamble</VAR>,
followed by either a series of comma-separated strings or a sequnce expression
followed by either a series of comma-separated strings or a seqeunce expression
between a pair of braces,
followed by an optional <VAR>postscript</VAR>.
The preamble is prefixed to each string contained within the braces, and
@@ -2139,13 +2139,17 @@ index of the specified array.
Note that a negative offset must be separated from the colon by at least
one space to avoid being confused with the <SAMP>`:-'</SAMP> expansion.
Substring indexing is zero-based unless the positional parameters
are used, in which case the indexing starts at 1.
are used, in which case the indexing starts at 1 by default.
If <VAR>offset</VAR> is 0, and the positional parameters are used, <CODE>$@</CODE> is
prefixed to the list.
</P><P>
<DT><CODE>${!<VAR>prefix</VAR>*}</CODE>
<DD><DT><CODE>${!<VAR>prefix</VAR>@}</CODE>
<DD>Expands to the names of variables whose names begin with <VAR>prefix</VAR>,
separated by the first character of the <CODE>IFS</CODE> special variable.
When <SAMP>`@'</SAMP> is used and the expansion appears within double quotes, each
variable name expands to a separate word.
<P>
<DT><CODE>${!<VAR>name</VAR>[@]}</CODE>
@@ -3713,7 +3717,7 @@ zero.
</pre></td></tr></table>If <VAR>command</VAR>
is supplied, it replaces the shell without creating a new process.
If the <SAMP>`-l'</SAMP> option is supplied, the shell places a dash at the
beginning of the zeroth arg passed to <VAR>command</VAR>.
beginning of the zeroth argument passed to <VAR>command</VAR>.
This is what the <CODE>login</CODE> program does.
The <SAMP>`-c'</SAMP> option causes <VAR>command</VAR> to be executed with an empty
environment.
@@ -4133,7 +4137,7 @@ key and function bindings,
bind a key sequence to a Readline function or macro,
or set a Readline variable.
Each non-option argument is a command as it would appear in a
a Readline initialization file (see section <A HREF="bashref.html#SEC99">8.3 Readline Init File</A>),
Readline initialization file (see section <A HREF="bashref.html#SEC99">8.3 Readline Init File</A>),
but each binding or command must be passed as a separate argument; e.g.,
<SAMP>`"\C-x\C-r":re-read-init-file'</SAMP>.
Options, if supplied, have the following meanings:
@@ -4328,7 +4332,10 @@ the environment.
</DL>
<P>
Using <SAMP>`+'</SAMP> instead of <SAMP>`-'</SAMP> turns off the attribute instead.
Using <SAMP>`+'</SAMP> instead of <SAMP>`-'</SAMP> turns off the attribute instead,
with the exceptions that <SAMP>`+a'</SAMP>
may not be used to destroy an array variable and <SAMP>`+r'</SAMP> will not
remove the readonly attribute.
When used in a function, <CODE>declare</CODE> makes each <VAR>name</VAR> local,
as with the <CODE>local</CODE> command. If a variable name is followed by
=<VAR>value</VAR>, the value of the variable is set to <VAR>value</VAR>.
@@ -5106,10 +5113,11 @@ immediately, rather than before printing the next primary prompt.
<DT><CODE>-e</CODE>
<DD>Exit immediately if a simple command (see section <A HREF="bashref.html#SEC16">3.2.1 Simple Commands</A>) exits
with a non-zero status, unless the command that fails is part of the
command list immediately following a <CODE>while</CODE> or <CODE>until</CODE>
keyword, part of the test in an <CODE>if</CODE> statement,
part of a <CODE>&#38;&#38;</CODE> or <CODE>||</CODE> list, or if the command's return
status is being inverted using <CODE>!</CODE>.
command list immediately following a <CODE>while</CODE> or <CODE>until</CODE> keyword,
part of the test in an <CODE>if</CODE> statement,
part of a <CODE>&#38;&#38;</CODE> or <CODE>||</CODE> list,
any command in a pipeline but the last,
or if the command's return status is being inverted using <CODE>!</CODE>.
A trap on <CODE>ERR</CODE>, if set, is executed before the shell exits.
<P>
@@ -5848,7 +5856,7 @@ An array variable containing the names of all shell functions
currently in the execution call stack.
The element with index 0 is the name of any currently-executing
shell function.
The bottom-most element is "main".
The bottom-most element is <CODE>"main"</CODE>.
This variable exists only when a shell function is executing.
Assignments to <CODE>FUNCNAME</CODE> have no effect and return an error status.
If <CODE>FUNCNAME</CODE> is unset, it loses its special properties, even if
@@ -6302,7 +6310,7 @@ if input does not arrive after <CODE>TMOUT</CODE> seconds when input is coming
from a terminal.
<P>
In an interative shell, the value is interpreted as
In an interactive shell, the value is interpreted as
the number of seconds to wait for input after issuing the primary
prompt when the shell is interactive.
Bash terminates after that number of seconds if input does
@@ -6415,7 +6423,7 @@ Equivalent to <SAMP>`-D'</SAMP> except for the output format.
<P>
<DT><CODE>--help</CODE>
<DD>Display a usage message on standard output and exit sucessfully.
<DD>Display a usage message on standard output and exit successfully.
<P>
<DT><CODE>--init-file <VAR>filename</VAR></CODE>
@@ -6582,7 +6590,7 @@ in the script. If no commands are executed, the exit status is 0.
<!--docid::SEC66::-->
<P>
This section describs how Bash executes its startup files.
This section describes how Bash executes its startup files.
If any of the files exist but cannot be read, Bash reports an error.
Tildes are expanded in file names as described above under
Tilde Expansion (see section <A HREF="bashref.html#SEC29">3.5.2 Tilde Expansion</A>).
@@ -6765,7 +6773,7 @@ the same, but the effective user id is not reset.
An interactive shell
is one started without non-option arguments, unless <SAMP>`-s'</SAMP> is
specified, without specifiying the <SAMP>`-c'</SAMP> option, and
specified, without specifying the <SAMP>`-c'</SAMP> option, and
whose input and error output are both
connected to terminals (as determined by <CODE>isatty(3)</CODE>),
or one started with the <SAMP>`-i'</SAMP> option.
@@ -6902,7 +6910,7 @@ In the absence of any traps, <CODE>SIGINT</CODE> is caught and handled
<LI>
An interactive login shell sends a <CODE>SIGHUP</CODE> to all jobs on exit
if the <CODE>hupoxexit</CODE> shell option has been enabled (see section <A HREF="bashref.html#SEC54">3.7.6 Signals</A>).
if the <CODE>huponexit</CODE> shell option has been enabled (see section <A HREF="bashref.html#SEC54">3.7.6 Signals</A>).
<P>
<LI>
@@ -7578,7 +7586,7 @@ from the stack, so that only the stack is manipulated.
<A NAME="IDX274"></A>
<DT><CODE>pushd</CODE>
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>pushd [<VAR>dir</VAR> | <VAR>+N</VAR> | <VAR>-N</VAR>] [-n]
<DD><TABLE><tr><td>&nbsp;</td><td class=example><pre>pushd [-n] [<VAR>+N</VAR> | <VAR>-N</VAR> | <VAR>dir</VAR> ]
</pre></td></tr></table><P>
Save the current directory on the top of the directory stack
@@ -7587,6 +7595,9 @@ With no arguments, <CODE>pushd</CODE> exchanges the top two directories.
</P><P>
<DL COMPACT>
<DT><CODE>-n</CODE>
<DD>Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
<DT><CODE>+<VAR>N</VAR></CODE>
<DD>Brings the <VAR>N</VAR>th directory (counting from the left of the
list printed by <CODE>dirs</CODE>, starting with zero) to the top of
@@ -7595,9 +7606,6 @@ the list by rotating the stack.
<DD>Brings the <VAR>N</VAR>th directory (counting from the right of the
list printed by <CODE>dirs</CODE>, starting with zero) to the top of
the list by rotating the stack.
<DT><CODE>-n</CODE>
<DD>Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
<DT><CODE><VAR>dir</VAR></CODE>
<DD>Makes the current working directory be the top of the stack, and then
executes the equivalent of `<CODE>cd</CODE> <VAR>dir</VAR>'.
@@ -15136,7 +15144,7 @@ to permit their use in free software.
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1>About this document</H1>
This document was generated by <I>Chet Ramey</I> on <I>September, 28 2006</I>
This document was generated by <I>Chet Ramey</I> on <I>December, 12 2006</I>
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
<P></P>
@@ -15298,7 +15306,7 @@ the following structure:
<BR>
<FONT SIZE="-1">
This document was generated
by <I>Chet Ramey</I> on <I>September, 28 2006</I>
by <I>Chet Ramey</I> on <I>December, 12 2006</I>
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
+184 -177
View File
@@ -1,11 +1,11 @@
This is bashref.info, produced by makeinfo version 4.7 from
This is bashref.info, produced by makeinfo version 4.8 from
/Users/chet/src/bash/src/doc/bashref.texi.
This text is a brief description of the features that are present in
the Bash shell (version 3.2, 28 September 2006).
the Bash shell (version 3.2, 27 November 2006).
This is Edition 3.2, last updated 28 September 2006, of `The GNU
Bash Reference Manual', for `Bash', Version 3.2.
This is Edition 3.2, last updated 27 November 2006, of `The GNU Bash
Reference Manual', for `Bash', Version 3.2.
Copyright (C) 1988-2005 Free Software Foundation, Inc.
@@ -37,10 +37,10 @@ Bash Features
*************
This text is a brief description of the features that are present in
the Bash shell (version 3.2, 28 September 2006).
the Bash shell (version 3.2, 27 November 2006).
This is Edition 3.2, last updated 28 September 2006, of `The GNU
Bash Reference Manual', for `Bash', Version 3.2.
This is Edition 3.2, last updated 27 November 2006, of `The GNU Bash
Reference Manual', for `Bash', Version 3.2.
Bash contains features that appear in other popular shells, and some
features that only appear in Bash. Some of the shells that Bash has
@@ -130,7 +130,7 @@ symbols are expanded to create larger expressions.
A Unix shell is both a command interpreter and a programming
language. As a command interpreter, the shell provides the user
interface to the rich set of GNU utilities. The programming language
features allow these utilitites to be combined. Files containing
features allow these utilities to be combined. Files containing
commands can be created, and become commands themselves. These new
commands have the same status as system commands in directories such as
`/bin', allowing users or groups to establish custom environments to
@@ -232,7 +232,7 @@ These definitions are used throughout the remainder of this manual.
group ID.
`process group ID'
A unique identifer that represents a `process group' during its
A unique identifier that represents a `process group' during its
lifetime.
`reserved word'
@@ -793,7 +793,7 @@ File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Pre
items. The set of expanded words is printed on the standard error
output stream, each preceded by a number. If the `in WORDS' is
omitted, the positional parameters are printed, as if `in "$@"'
had been specifed. The `PS3' prompt is then displayed and a line
had been specified. The `PS3' prompt is then displayed and a line
is read from the standard input. If the line consists of a number
corresponding to one of the displayed words, then the value of
NAME is set to that word. If the line is empty, the words and
@@ -1201,7 +1201,7 @@ Brace expansion is a mechanism by which arbitrary strings may be
generated. This mechanism is similar to FILENAME EXPANSION (*note
Filename Expansion::), but the file names generated need not exist.
Patterns to be brace expanded take the form of an optional PREAMBLE,
followed by either a series of comma-separated strings or a sequnce
followed by either a series of comma-separated strings or a seqeunce
expression between a pair of braces, followed by an optional POSTSCRIPT.
The preamble is prefixed to each string contained within the braces, and
the postscript is then appended to each resulting string, expanding left
@@ -1387,12 +1387,16 @@ if the colon is omitted, the operator tests only for existence.
that a negative offset must be separated from the colon by at least
one space to avoid being confused with the `:-' expansion.
Substring indexing is zero-based unless the positional parameters
are used, in which case the indexing starts at 1.
are used, in which case the indexing starts at 1 by default. If
OFFSET is 0, and the positional parameters are used, `$@' is
prefixed to the list.
`${!PREFIX*}'
`${!PREFIX@}'
Expands to the names of variables whose names begin with PREFIX,
separated by the first character of the `IFS' special variable.
When `@' is used and the expansion appears within double quotes,
each variable name expands to a separate word.
`${!NAME[@]}'
`${!NAME[*]}'
@@ -2348,11 +2352,11 @@ standard.
exec [-cl] [-a NAME] [COMMAND [ARGUMENTS]]
If COMMAND is supplied, it replaces the shell without creating a
new process. If the `-l' option is supplied, the shell places a
dash at the beginning of the zeroth arg passed to COMMAND. This
is what the `login' program does. The `-c' option causes COMMAND
to be executed with an empty environment. If `-a' is supplied,
the shell passes NAME as the zeroth argument to COMMAND. If no
COMMAND is specified, redirections may be used to affect the
dash at the beginning of the zeroth argument passed to COMMAND.
This is what the `login' program does. The `-c' option causes
COMMAND to be executed with an empty environment. If `-a' is
supplied, the shell passes NAME as the zeroth argument to COMMAND.
If no COMMAND is specified, redirections may be used to affect the
current shell environment. If there are no redirection errors, the
return status is zero; otherwise the return status is non-zero.
@@ -2655,7 +2659,7 @@ POSIX standard.
Display current Readline (*note Command Line Editing::) key and
function bindings, bind a key sequence to a Readline function or
macro, or set a Readline variable. Each non-option argument is a
command as it would appear in a a Readline initialization file
command as it would appear in a Readline initialization file
(*note Readline Init File::), but each binding or command must be
passed as a separate argument; e.g.,
`"\C-x\C-r":re-read-init-file'. Options, if supplied, have the
@@ -2799,10 +2803,12 @@ POSIX standard.
Mark each NAME for export to subsequent commands via the
environment.
Using `+' instead of `-' turns off the attribute instead. When
used in a function, `declare' makes each NAME local, as with the
`local' command. If a variable name is followed by =VALUE, the
value of the variable is set to VALUE.
Using `+' instead of `-' turns off the attribute instead, with the
exceptions that `+a' may not be used to destroy an array variable
and `+r' will not remove the readonly attribute. When used in a
function, `declare' makes each NAME local, as with the `local'
command. If a variable name is followed by =VALUE, the value of
the variable is set to VALUE.
The return status is zero unless an invalid option is encountered,
an attempt is made to define a function using `-f foo=bar', an
@@ -3402,9 +3408,10 @@ This builtin is so complicated that it deserves its own section.
Commands::) exits with a non-zero status, unless the command
that fails is part of the command list immediately following
a `while' or `until' keyword, part of the test in an `if'
statement, part of a `&&' or `||' list, or if the command's
return status is being inverted using `!'. A trap on `ERR',
if set, is executed before the shell exits.
statement, part of a `&&' or `||' list, any command in a
pipeline but the last, or if the command's return status is
being inverted using `!'. A trap on `ERR', if set, is
executed before the shell exits.
`-f'
Disable file name generation (globbing).
@@ -3892,7 +3899,7 @@ Variables::).
An array variable containing the names of all shell functions
currently in the execution call stack. The element with index 0
is the name of any currently-executing shell function. The
bottom-most element is "main". This variable exists only when a
bottom-most element is `"main"'. This variable exists only when a
shell function is executing. Assignments to `FUNCNAME' have no
effect and return an error status. If `FUNCNAME' is unset, it
loses its special properties, even if it is subsequently reset.
@@ -4191,7 +4198,7 @@ Variables::).
if input does not arrive after `TMOUT' seconds when input is coming
from a terminal.
In an interative shell, the value is interpreted as the number of
In an interactive shell, the value is interpreted as the number of
seconds to wait for input after issuing the primary prompt when
the shell is interactive. Bash terminates after that number of
seconds if input does not arrive.
@@ -4261,7 +4268,7 @@ the single-character options to be recognized.
Equivalent to `-D'.
`--help'
Display a usage message on standard output and exit sucessfully.
Display a usage message on standard output and exit successfully.
`--init-file FILENAME'
`--rcfile FILENAME'
@@ -4378,7 +4385,7 @@ File: bashref.info, Node: Bash Startup Files, Next: Interactive Shells, Prev:
6.2 Bash Startup Files
======================
This section describs how Bash executes its startup files. If any of
This section describes how Bash executes its startup files. If any of
the files exist but cannot be read, Bash reports an error. Tildes are
expanded in file names as described above under Tilde Expansion (*note
Tilde Expansion::).
@@ -4502,9 +4509,9 @@ File: bashref.info, Node: What is an Interactive Shell?, Next: Is this Shell I
-----------------------------------
An interactive shell is one started without non-option arguments,
unless `-s' is specified, without specifiying the `-c' option, and
whose input and error output are both connected to terminals (as
determined by `isatty(3)'), or one started with the `-i' option.
unless `-s' is specified, without specifying the `-c' option, and whose
input and error output are both connected to terminals (as determined
by `isatty(3)'), or one started with the `-i' option.
An interactive shell generally reads from and writes to a user's
terminal.
@@ -4581,7 +4588,7 @@ several ways.
((*note Signals::). `SIGINT' will interrupt some shell builtins.
11. An interactive login shell sends a `SIGHUP' to all jobs on exit if
the `hupoxexit' shell option has been enabled (*note Signals::).
the `huponexit' shell option has been enabled (*note Signals::).
12. The `-n' invocation option is ignored, and `set -n' has no effect
(*note The Set Builtin::).
@@ -5042,12 +5049,17 @@ File: bashref.info, Node: Directory Stack Builtins, Up: The Directory Stack
manipulated.
`pushd'
pushd [DIR | +N | -N] [-n]
pushd [-n] [+N | -N | DIR ]
Save the current directory on the top of the directory stack and
then `cd' to DIR. With no arguments, `pushd' exchanges the top
two directories.
`-n'
Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is
manipulated.
`+N'
Brings the Nth directory (counting from the left of the list
printed by `dirs', starting with zero) to the top of the list
@@ -5058,11 +5070,6 @@ File: bashref.info, Node: Directory Stack Builtins, Up: The Directory Stack
printed by `dirs', starting with zero) to the top of the list
by rotating the stack.
`-n'
Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is
manipulated.
`DIR'
Makes the current working directory be the top of the stack,
and then executes the equivalent of ``cd' DIR'. `cd's to DIR.
@@ -8994,8 +9001,8 @@ Index of Shell Builtin Commands
(line 7)
* disown: Job Control Builtins.
(line 83)
* echo: Bash Builtins. (line 191)
* enable: Bash Builtins. (line 243)
* echo: Bash Builtins. (line 193)
* enable: Bash Builtins. (line 245)
* eval: Bourne Shell Builtins.
(line 63)
* exec: Bourne Shell Builtins.
@@ -9012,24 +9019,24 @@ Index of Shell Builtin Commands
(line 103)
* hash: Bourne Shell Builtins.
(line 145)
* help: Bash Builtins. (line 271)
* help: Bash Builtins. (line 273)
* history: Bash History Builtins.
(line 39)
* jobs: Job Control Builtins.
(line 25)
* kill: Job Control Builtins.
(line 57)
* let: Bash Builtins. (line 280)
* local: Bash Builtins. (line 287)
* logout: Bash Builtins. (line 297)
* let: Bash Builtins. (line 282)
* local: Bash Builtins. (line 289)
* logout: Bash Builtins. (line 299)
* popd: Directory Stack Builtins.
(line 37)
* printf: Bash Builtins. (line 301)
* printf: Bash Builtins. (line 303)
* pushd: Directory Stack Builtins.
(line 58)
* pwd: Bourne Shell Builtins.
(line 163)
* read: Bash Builtins. (line 326)
* read: Bash Builtins. (line 328)
* readonly: Bourne Shell Builtins.
(line 172)
* return: Bourne Shell Builtins.
@@ -9037,8 +9044,8 @@ Index of Shell Builtin Commands
* set: The Set Builtin. (line 9)
* shift: Bourne Shell Builtins.
(line 200)
* shopt: Bash Builtins. (line 387)
* source: Bash Builtins. (line 618)
* shopt: Bash Builtins. (line 389)
* source: Bash Builtins. (line 620)
* suspend: Job Control Builtins.
(line 94)
* test: Bourne Shell Builtins.
@@ -9047,12 +9054,12 @@ Index of Shell Builtin Commands
(line 278)
* trap: Bourne Shell Builtins.
(line 283)
* type: Bash Builtins. (line 622)
* typeset: Bash Builtins. (line 653)
* ulimit: Bash Builtins. (line 659)
* type: Bash Builtins. (line 624)
* typeset: Bash Builtins. (line 655)
* ulimit: Bash Builtins. (line 661)
* umask: Bourne Shell Builtins.
(line 324)
* unalias: Bash Builtins. (line 737)
* unalias: Bash Builtins. (line 739)
* unset: Bourne Shell Builtins.
(line 341)
* wait: Job Control Builtins.
@@ -9524,129 +9531,129 @@ Concept Index

Tag Table:
Node: Top1359
Node: Introduction3442
Node: What is Bash?3670
Node: What is a shell?4783
Node: Definitions7324
Node: Basic Shell Features10091
Node: Shell Syntax11310
Node: Shell Operation12340
Node: Quoting13634
Node: Escape Character14937
Node: Single Quotes15422
Node: Double Quotes15770
Node: ANSI-C Quoting16895
Node: Locale Translation17851
Node: Comments18747
Node: Shell Commands19361
Node: Simple Commands20127
Node: Pipelines20758
Node: Lists22633
Node: Compound Commands24264
Node: Looping Constructs25048
Node: Conditional Constructs27495
Node: Command Grouping34954
Node: Shell Functions36403
Node: Shell Parameters40812
Node: Positional Parameters43142
Node: Special Parameters44042
Node: Shell Expansions47006
Node: Brace Expansion48931
Node: Tilde Expansion51256
Node: Shell Parameter Expansion53607
Node: Command Substitution61077
Node: Arithmetic Expansion62410
Node: Process Substitution63260
Node: Word Splitting64310
Node: Filename Expansion65771
Node: Pattern Matching67907
Node: Quote Removal71225
Node: Redirections71520
Node: Executing Commands79250
Node: Simple Command Expansion79920
Node: Command Search and Execution81850
Node: Command Execution Environment83856
Node: Environment86627
Node: Exit Status88287
Node: Signals89491
Node: Shell Scripts91455
Node: Shell Builtin Commands93973
Node: Bourne Shell Builtins95642
Node: Bash Builtins112744
Node: The Set Builtin142004
Node: Special Builtins150379
Node: Shell Variables151349
Node: Bourne Shell Variables151789
Node: Bash Variables153770
Node: Bash Features174084
Node: Invoking Bash174967
Node: Bash Startup Files180776
Node: Interactive Shells185634
Node: What is an Interactive Shell?186044
Node: Is this Shell Interactive?186694
Node: Interactive Shell Behavior187509
Node: Bash Conditional Expressions190785
Node: Shell Arithmetic194364
Node: Aliases197110
Node: Arrays199678
Node: The Directory Stack203027
Node: Directory Stack Builtins203741
Node: Printing a Prompt206632
Node: The Restricted Shell209346
Node: Bash POSIX Mode211178
Node: Job Control218937
Node: Job Control Basics219404
Node: Job Control Builtins223780
Node: Job Control Variables228107
Node: Command Line Editing229265
Node: Introduction and Notation230264
Node: Readline Interaction231886
Node: Readline Bare Essentials233077
Node: Readline Movement Commands234866
Node: Readline Killing Commands235831
Node: Readline Arguments237751
Node: Searching238795
Node: Readline Init File240981
Node: Readline Init File Syntax242128
Node: Conditional Init Constructs254459
Node: Sample Init File256992
Node: Bindable Readline Commands260109
Node: Commands For Moving261316
Node: Commands For History262177
Node: Commands For Text265332
Node: Commands For Killing268005
Node: Numeric Arguments270147
Node: Commands For Completion271286
Node: Keyboard Macros274879
Node: Miscellaneous Commands275450
Node: Readline vi Mode280761
Node: Programmable Completion281675
Node: Programmable Completion Builtins287467
Node: Using History Interactively295063
Node: Bash History Facilities295743
Node: Bash History Builtins298438
Node: History Interaction302295
Node: Event Designators304851
Node: Word Designators305866
Node: Modifiers307505
Node: Installing Bash308911
Node: Basic Installation310041
Node: Compilers and Options312733
Node: Compiling For Multiple Architectures313474
Node: Installation Names315138
Node: Specifying the System Type315956
Node: Sharing Defaults316672
Node: Operation Controls317345
Node: Optional Features318303
Node: Reporting Bugs327234
Node: Major Differences From The Bourne Shell328428
Node: Copying This Manual345093
Node: GNU Free Documentation License345369
Node: Builtin Index367775
Node: Reserved Word Index374324
Node: Variable Index376760
Node: Function Index387693
Node: Concept Index394413
Node: Top1357
Node: Introduction3438
Node: What is Bash?3666
Node: What is a shell?4779
Node: Definitions7319
Node: Basic Shell Features10087
Node: Shell Syntax11306
Node: Shell Operation12336
Node: Quoting13630
Node: Escape Character14933
Node: Single Quotes15418
Node: Double Quotes15766
Node: ANSI-C Quoting16891
Node: Locale Translation17847
Node: Comments18743
Node: Shell Commands19357
Node: Simple Commands20123
Node: Pipelines20754
Node: Lists22629
Node: Compound Commands24260
Node: Looping Constructs25044
Node: Conditional Constructs27491
Node: Command Grouping34951
Node: Shell Functions36400
Node: Shell Parameters40809
Node: Positional Parameters43139
Node: Special Parameters44039
Node: Shell Expansions47003
Node: Brace Expansion48928
Node: Tilde Expansion51254
Node: Shell Parameter Expansion53605
Node: Command Substitution61305
Node: Arithmetic Expansion62638
Node: Process Substitution63488
Node: Word Splitting64538
Node: Filename Expansion65999
Node: Pattern Matching68135
Node: Quote Removal71453
Node: Redirections71748
Node: Executing Commands79478
Node: Simple Command Expansion80148
Node: Command Search and Execution82078
Node: Command Execution Environment84084
Node: Environment86855
Node: Exit Status88515
Node: Signals89719
Node: Shell Scripts91683
Node: Shell Builtin Commands94201
Node: Bourne Shell Builtins95870
Node: Bash Builtins112975
Node: The Set Builtin142367
Node: Special Builtins150792
Node: Shell Variables151762
Node: Bourne Shell Variables152202
Node: Bash Variables154183
Node: Bash Features174500
Node: Invoking Bash175383
Node: Bash Startup Files181193
Node: Interactive Shells186052
Node: What is an Interactive Shell?186462
Node: Is this Shell Interactive?187111
Node: Interactive Shell Behavior187926
Node: Bash Conditional Expressions191202
Node: Shell Arithmetic194781
Node: Aliases197527
Node: Arrays200095
Node: The Directory Stack203444
Node: Directory Stack Builtins204158
Node: Printing a Prompt207050
Node: The Restricted Shell209764
Node: Bash POSIX Mode211596
Node: Job Control219355
Node: Job Control Basics219822
Node: Job Control Builtins224198
Node: Job Control Variables228525
Node: Command Line Editing229683
Node: Introduction and Notation230682
Node: Readline Interaction232304
Node: Readline Bare Essentials233495
Node: Readline Movement Commands235284
Node: Readline Killing Commands236249
Node: Readline Arguments238169
Node: Searching239213
Node: Readline Init File241399
Node: Readline Init File Syntax242546
Node: Conditional Init Constructs254877
Node: Sample Init File257410
Node: Bindable Readline Commands260527
Node: Commands For Moving261734
Node: Commands For History262595
Node: Commands For Text265750
Node: Commands For Killing268423
Node: Numeric Arguments270565
Node: Commands For Completion271704
Node: Keyboard Macros275297
Node: Miscellaneous Commands275868
Node: Readline vi Mode281179
Node: Programmable Completion282093
Node: Programmable Completion Builtins287885
Node: Using History Interactively295481
Node: Bash History Facilities296161
Node: Bash History Builtins298856
Node: History Interaction302713
Node: Event Designators305269
Node: Word Designators306284
Node: Modifiers307923
Node: Installing Bash309329
Node: Basic Installation310459
Node: Compilers and Options313151
Node: Compiling For Multiple Architectures313892
Node: Installation Names315556
Node: Specifying the System Type316374
Node: Sharing Defaults317090
Node: Operation Controls317763
Node: Optional Features318721
Node: Reporting Bugs327652
Node: Major Differences From The Bourne Shell328846
Node: Copying This Manual345511
Node: GNU Free Documentation License345787
Node: Builtin Index368193
Node: Reserved Word Index374742
Node: Variable Index377178
Node: Function Index388111
Node: Concept Index394831

End Tag Table
+24 -24
View File
@@ -1,4 +1,4 @@
This is TeX, Version 3.14159 (Web2C 7.4.5) (format=tex 2005.3.22) 28 SEP 2006 10:26
This is TeX, Version 3.141592 (Web2C 7.5.4) (format=tex 2006.11.28) 12 DEC 2006 14:43
**/Users/chet/src/bash/src/doc/bashref.texi
(/Users/chet/src/bash/src/doc/bashref.texi (./texinfo.tex
Loading texinfo [version 2003-02-03.16]: Basics,
@@ -106,7 +106,7 @@ cross references,
\auxfile=\write2
\savesfregister=\count46
\footnoteno=\count47
(/sw/share/texmf/tex/generic/misc/epsf.tex
(/sw/share/texmf-dist/tex/generic/epsf/epsf.tex
\epsffilein=\read0
\epsfframemargin=\dimen39
\epsfframethickness=\dimen40
@@ -119,18 +119,19 @@ cross references,
\epsfnoopenhelp=\toks24
)
\noepsfhelp=\toks25
localization,
localization,
\nolanghelp=\toks26
\defaultparindent=\dimen47
and turning on texinfo input format.) (./bashref.aux)
and turning on texinfo input format.) (./bashref.aux)
@cpindfile=@write3
@fnindfile=@write4
@vrindfile=@write5
@tpindfile=@write6
@kyindfile=@write7
@pgindfile=@write8
(./version.texi)
(./version.texi)
@btindfile=@write9
@rwindfile=@write10
[1
@@ -152,12 +153,11 @@ and turning on texinfo input format.) (./bashref.aux)
\openout10 = `bashref.rw'.
]
[2] (./bashref.toc [-1] [-2] [-3]) [-4] Chapter 1
] [2] (./bashref.toc [-1] [-2] [-3]) [-4] Chapter 1
\openout0 = `bashref.toc'.
[1] Chapter 2 [2] [3]
Chapter 3 [4] [5] [6] [7] [8] [9] [10]
[1]
Chapter 2 [2] [3] Chapter 3 [4] [5] [6] [7] [8] [9] [10]
Overfull \hbox (43.33539pt too wide) in paragraph at lines 845--845
[]@texttt case @textttsl word @texttt in [ [(] @textttsl pat-tern @texttt [| @
textttsl pat-tern@texttt ][]) @textttsl command-list @texttt ;;][] esac[][]
@@ -173,7 +173,7 @@ textttsl pat-tern@texttt ][]) @textttsl command-list @texttt ;;][] esac[][]
[11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25]
[26] [27] [28] [29] [30] [31] [32] Chapter 4 [33] [34] [35] [36] [37] [38]
[39] [40] [41]
Underfull \hbox (badness 5231) in paragraph at lines 3120--3133
Underfull \hbox (badness 5231) in paragraph at lines 3124--3137
@texttt emacs-meta[]@textrm , @texttt emacs-ctlx[]@textrm , @texttt vi[]@textr
m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
@@ -186,7 +186,7 @@ m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
.etc.
[42] [43] [44] [45]
Overfull \hbox (43.33536pt too wide) in paragraph at lines 3460--3460
Overfull \hbox (43.33536pt too wide) in paragraph at lines 3467--3467
[]@texttt read [-ers] [-a @textttsl aname@texttt ] [-d @textttsl de-lim@texttt
] [-n @textttsl nchars@texttt ] [-p @textttsl prompt@texttt ] [-t @textttsl ti
me-
@@ -200,7 +200,7 @@ me-
.etc.
[46] [47] [48]
Underfull \hbox (badness 2573) in paragraph at lines 3644--3648
Underfull \hbox (badness 2573) in paragraph at lines 3651--3655
[] []@textrm Error trac-ing is en-abled: com-mand sub-sti-tu-tion, shell
@hbox(7.60416+2.12917)x433.62, glue set 2.95305
@@ -217,7 +217,7 @@ Underfull \hbox (badness 2573) in paragraph at lines 3644--3648
[49] [50] [51] [52] [53] [54] [55] Chapter 5 [56] [57] [58] [59] [60] [61]
[62] [63] [64] Chapter 6 [65] [66]
Overfull \hbox (51.96864pt too wide) in paragraph at lines 4840--4840
Overfull \hbox (51.96864pt too wide) in paragraph at lines 4848--4848
[]@texttt bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@t
exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
@@ -230,7 +230,7 @@ exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
.etc.
Overfull \hbox (76.23077pt too wide) in paragraph at lines 4841--4841
Overfull \hbox (76.23077pt too wide) in paragraph at lines 4849--4849
[]@texttt bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@texttt
] [-O @textttsl shopt_option@texttt ] -c @textttsl string @texttt [@textttsl ar
-
@@ -244,7 +244,7 @@ Overfull \hbox (76.23077pt too wide) in paragraph at lines 4841--4841
.etc.
Overfull \hbox (34.72258pt too wide) in paragraph at lines 4842--4842
Overfull \hbox (34.72258pt too wide) in paragraph at lines 4850--4850
[]@texttt bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@text
tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
@@ -257,7 +257,7 @@ tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
.etc.
[67] [68]
Underfull \hbox (badness 2245) in paragraph at lines 5016--5018
Underfull \hbox (badness 2245) in paragraph at lines 5024--5026
[]@textrm When a lo-gin shell ex-its, Bash reads and ex-e-cutes com-mands from
the file
@@ -270,7 +270,7 @@ the file
.etc.
[69] [70] [71] [72] [73] [74] [75] [76] [77] [78] [79] [80] [81] [82]
Underfull \hbox (badness 2521) in paragraph at lines 6130--6133
Underfull \hbox (badness 2521) in paragraph at lines 6138--6141
@textrm `@texttt --enable-strict-posix-default[]@textrm '[] to @texttt configur
e[] @textrm when build-ing (see Sec-tion 10.8
@@ -337,7 +337,7 @@ Underfull \hbox (badness 2753) in paragraph at lines 1768--1771
[113]) (/Users/chet/src/bash/src/lib/readline/doc/hsuser.texi Chapter 9
[114] [115] [116] [117] [118]) Chapter 10 [119] [120] [121] [122] [123]
Underfull \hbox (badness 2772) in paragraph at lines 6724--6728
Underfull \hbox (badness 2772) in paragraph at lines 6732--6736
[]@textrm Enable sup-port for large files (@texttt http://www.sas.com/standard
s/large_
@@ -374,12 +374,12 @@ Overfull \vbox (42.26959pt too high) has occurred while \output is active
(./bashref.vrs [149]) (Function Index) [150] (./bashref.fns [151])
(Concept Index) [152] (./bashref.cps [153]) [154] )
Here is how much of TeX's memory you used:
1726 strings out of 98002
23501 string characters out of 1221987
52380 words of memory out of 1000001
1726 strings out of 97980
23516 string characters out of 1221004
52378 words of memory out of 1000000
2577 multiletter control sequences out of 10000+50000
31953 words of font info for 111 fonts, out of 500000 for 1000
31953 words of font info for 111 fonts, out of 500000 for 2000
19 hyphenation exceptions out of 1000
15i,8n,11p,269b,465s stack positions out of 1500i,500n,5000p,200000b,5000s
Output written on bashref.dvi (160 pages, 591312 bytes).
Output written on bashref.dvi (160 pages, 606064 bytes).
+1529 -1187
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1600,7 +1600,7 @@ Note that a negative offset must be separated from the colon by at least
one space to avoid being confused with the @samp{:-} expansion.
Substring indexing is zero-based unless the positional parameters
are used, in which case the indexing starts at 1 by default.
If @var{offset}} is 0, and the positional parameters are used, @code{$@@} is
If @var{offset} is 0, and the positional parameters are used, @code{$@@} is
prefixed to the list.
@item $@{!@var{prefix}*@}
@@ -2592,8 +2592,8 @@ under another shell.
* Bourne Shell Builtins:: Builtin commands inherited from the Bourne
Shell.
* Bash Builtins:: Table of builtins specific to Bash.
* The Set Builtin:: This builtin is so overloaded it
deserves its own section.
* The Set Builtin:: Change the values of shell attributes and
positional parameters.
* Special Builtins:: Builtin commands classified specially by
POSIX.
@end menu
@@ -3356,7 +3356,7 @@ the eight-bit character whose value is the hexadecimal value @var{HH}
@item enable
@btindex enable
@example
enable [-n] [-p] [-f @var{filename}] [-ads] [@var{name} @dots{}]
enable [-a] [-dnps] [-f @var{filename}] [@var{name} @dots{}]
@end example
Enable and disable builtin shell commands.
Disabling a builtin allows a disk command which has the same name
@@ -3942,7 +3942,7 @@ This builtin is so complicated that it deserves its own section.
@item set
@btindex set
@example
set [--abefhkmnptuvxBCHP] [-o @var{option}] [@var{argument} @dots{}]
set [--abefhkmnptuvxBCEHPT] [-o @var{option}] [@var{argument} @dots{}]
@end example
If no options or arguments are supplied, @code{set} displays the names
+17 -13
View File
@@ -1600,7 +1600,7 @@ Note that a negative offset must be separated from the colon by at least
one space to avoid being confused with the @samp{:-} expansion.
Substring indexing is zero-based unless the positional parameters
are used, in which case the indexing starts at 1 by default.
If @var{offset}} is 0, and the positional parameters are used, @code{$@@} is
If @var{offset} is 0, and the positional parameters are used, @code{$@@} is
prefixed to the list.
@item $@{!@var{prefix}*@}
@@ -2592,8 +2592,8 @@ under another shell.
* Bourne Shell Builtins:: Builtin commands inherited from the Bourne
Shell.
* Bash Builtins:: Table of builtins specific to Bash.
* The Set Builtin:: This builtin is so overloaded it
deserves its own section.
* The Set Builtin:: Change the values of shell attributes and
positional parameters.
* Special Builtins:: Builtin commands classified specially by
POSIX.
@end menu
@@ -3287,7 +3287,10 @@ Mark each @var{name} for export to subsequent commands via
the environment.
@end table
Using @samp{+} instead of @samp{-} turns off the attribute instead.
Using @samp{+} instead of @samp{-} turns off the attribute instead,
with the exceptions that @samp{+a}
may not be used to destroy an array variable and @samp{+r} will not
remove the readonly attribute.
When used in a function, @code{declare} makes each @var{name} local,
as with the @code{local} command. If a variable name is followed by
=@var{value}, the value of the variable is set to @var{value}.
@@ -3939,7 +3942,7 @@ This builtin is so complicated that it deserves its own section.
@item set
@btindex set
@example
set [--abefhkmnptuvxBCHP] [-o @var{option}] [@var{argument} @dots{}]
set [--abefhkmnptuvxBCEHPT] [-o @var{option}] [@var{argument} @dots{}]
@end example
If no options or arguments are supplied, @code{set} displays the names
@@ -3964,10 +3967,11 @@ immediately, rather than before printing the next primary prompt.
@item -e
Exit immediately if a simple command (@pxref{Simple Commands}) exits
with a non-zero status, unless the command that fails is part of the
command list immediately following a @code{while} or @code{until}
keyword, part of the test in an @code{if} statement,
part of a @code{&&} or @code{||} list, or if the command's return
status is being inverted using @code{!}.
command list immediately following a @code{while} or @code{until} keyword,
part of the test in an @code{if} statement,
part of a @code{&&} or @code{||} list,
any command in a pipeline but the last,
or if the command's return status is being inverted using @code{!}.
A trap on @code{ERR}, if set, is executed before the shell exits.
@item -f
@@ -5738,7 +5742,7 @@ from the stack, so that only the stack is manipulated.
@btindex pushd
@item pushd
@example
pushd [@var{dir} | @var{+N} | @var{-N}] [-n]
pushd [-n] [@var{+N} | @var{-N} | @var{dir} ]
@end example
Save the current directory on the top of the directory stack
@@ -5746,6 +5750,9 @@ and then @code{cd} to @var{dir}.
With no arguments, @code{pushd} exchanges the top two directories.
@table @code
@item -n
Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
@item +@var{N}
Brings the @var{N}th directory (counting from the left of the
list printed by @code{dirs}, starting with zero) to the top of
@@ -5754,9 +5761,6 @@ the list by rotating the stack.
Brings the @var{N}th directory (counting from the right of the
list printed by @code{dirs}, starting with zero) to the top of
the list by rotating the stack.
@item -n
Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
@item @var{dir}
Makes the current working directory be the top of the stack, and then
executes the equivalent of `@code{cd} @var{dir}'.
+1 -1
View File
@@ -34,7 +34,7 @@
\subsecentry{Word Splitting}{3}{5}{7}{22}
\subsecentry{Filename Expansion}{3}{5}{8}{23}
\subsubsecentry{Pattern Matching}{3}{5}{8}{1}{23}
\subsecentry{Quote Removal}{3}{5}{9}{24}
\subsecentry{Quote Removal}{3}{5}{9}{25}
\secentry{Redirections}{3}{6}{25}
\subsecentry{Redirecting Input}{3}{6}{1}{26}
\subsecentry{Redirecting Output}{3}{6}{2}{26}
+83 -80
View File
@@ -338,64 +338,67 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
environment.
Using `+' instead of `-' turns off the attribute instead, with
the exception that ++aa may not be used to destroy an array vari-
able. When used in a function, makes each _n_a_m_e local, as with
the llooccaall command. If a variable name is followed by =_v_a_l_u_e,
the value of the variable is set to _v_a_l_u_e. The return value is
0 unless an invalid option is encountered, an attempt is made to
define a function using ``-f foo=bar'', an attempt is made to
assign a value to a readonly variable, an attempt is made to
assign a value to an array variable without using the compound
assignment syntax (see AArrrraayyss above), one of the _n_a_m_e_s is not a
valid shell variable name, an attempt is made to turn off read-
only status for a readonly variable, an attempt is made to turn
off array status for an array variable, or an attempt is made to
display a non-existent function with --ff.
the exceptions that ++aa may not be used to destroy an array vari-
able and ++rr wwiillll nnoott rreemmoovvee tthhee rreeaaddoonnllyy aattttrriibbuuttee.. WWhheenn uusseedd
iinn aa ffuunnccttiioonn,, mmaakkeess eeaacchh _n_a_m_e llooccaall,, aass wwiitthh tthhee llooccaall command.
If a variable name is followed by =_v_a_l_u_e, the value of the vari-
able is set to _v_a_l_u_e. The return value is 0 unless an invalid
option is encountered, an attempt is made to define a function
using ``-f foo=bar'', an attempt is made to assign a value to a
readonly variable, an attempt is made to assign a value to an
array variable without using the compound assignment syntax (see
AArrrraayyss above), one of the _n_a_m_e_s is not a valid shell variable
name, an attempt is made to turn off readonly status for a read-
only variable, an attempt is made to turn off array status for
an array variable, or an attempt is made to display a non-exis-
tent function with --ff.
ddiirrss [[--ccllppvv]] [[++_n]] [[--_n]]
Without options, displays the list of currently remembered
directories. The default display is on a single line with
directory names separated by spaces. Directories are added to
the list with the ppuusshhdd command; the ppooppdd command removes
ddiirrss [[++_n]] [[--_n]] [[--ccppllvv]]
Without options, displays the list of currently remembered
directories. The default display is on a single line with
directory names separated by spaces. Directories are added to
the list with the ppuusshhdd command; the ppooppdd command removes
entries from the list.
++_n Displays the _nth entry counting from the left of the list
shown by ddiirrss when invoked without options, starting with
zero.
--_n Displays the _nth entry counting from the right of the
--_n Displays the _nth entry counting from the right of the
list shown by ddiirrss when invoked without options, starting
with zero.
--cc Clears the directory stack by deleting all of the
entries.
--ll Produces a longer listing; the default listing format
--ll Produces a longer listing; the default listing format
uses a tilde to denote the home directory.
--pp Print the directory stack with one entry per line.
--vv Print the directory stack with one entry per line, pre-
--vv Print the directory stack with one entry per line, pre-
fixing each entry with its index in the stack.
The return value is 0 unless an invalid option is supplied or _n
The return value is 0 unless an invalid option is supplied or _n
indexes beyond the end of the directory stack.
ddiissoowwnn [--aarr] [--hh] [_j_o_b_s_p_e_c ...]
Without options, each _j_o_b_s_p_e_c is removed from the table of
active jobs. If the --hh option is given, each _j_o_b_s_p_e_c is not
removed from the table, but is marked so that SSIIGGHHUUPP is not sent
to the job if the shell receives a SSIIGGHHUUPP. If no _j_o_b_s_p_e_c is
present, and neither the --aa nor the --rr option is supplied, the
_c_u_r_r_e_n_t _j_o_b is used. If no _j_o_b_s_p_e_c is supplied, the --aa option
means to remove or mark all jobs; the --rr option without a _j_o_b_-
_s_p_e_c argument restricts operation to running jobs. The return
value is 0 unless a _j_o_b_s_p_e_c does not specify a valid job.
Without options, each _j_o_b_s_p_e_c is removed from the table of
active jobs. If _j_o_b_s_p_e_c is not present, and neither --aa nnoorr --rr
iiss ssuupppplliieedd,, tthhee sshheellll''ss nnoottiioonn ooff tthhee _c_u_r_r_e_n_t _j_o_b iiss uusseedd.. IIff
tthhee --hh ooppttiioonn iiss ggiivveenn,, eeaacchh _j_o_b_s_p_e_c is not removed from the ta-
ble, but is marked so that SSIIGGHHUUPP is not sent to the job if the
shell receives a SSIIGGHHUUPP. If no _j_o_b_s_p_e_c is present, and neither
the --aa nor the --rr option is supplied, the _c_u_r_r_e_n_t _j_o_b is used.
If no _j_o_b_s_p_e_c is supplied, the --aa option means to remove or mark
all jobs; the --rr option without a _j_o_b_s_p_e_c argument restricts
operation to running jobs. The return value is 0 unless a _j_o_b_-
_s_p_e_c does not specify a valid job.
eecchhoo [--nneeEE] [_a_r_g ...]
Output the _a_r_gs, separated by spaces, followed by a newline.
Output the _a_r_gs, separated by spaces, followed by a newline.
The return status is always 0. If --nn is specified, the trailing
newline is suppressed. If the --ee option is given, interpreta-
tion of the following backslash-escaped characters is enabled.
The --EE option disables the interpretation of these escape char-
acters, even on systems where they are interpreted by default.
The xxppgg__eecchhoo shell option may be used to dynamically determine
whether or not eecchhoo expands these escape characters by default.
eecchhoo does not interpret ---- to mean the end of options. eecchhoo
newline is suppressed. If the --ee option is given, interpreta-
tion of the following backslash-escaped characters is enabled.
The --EE option disables the interpretation of these escape char-
acters, even on systems where they are interpreted by default.
The xxppgg__eecchhoo shell option may be used to dynamically determine
whether or not eecchhoo expands these escape characters by default.
eecchhoo does not interpret ---- to mean the end of options. eecchhoo
interprets the following escape sequences:
\\aa alert (bell)
\\bb backspace
@@ -407,52 +410,52 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
\\tt horizontal tab
\\vv vertical tab
\\\\ backslash
\\00_n_n_n the eight-bit character whose value is the octal value
\\00_n_n_n the eight-bit character whose value is the octal value
_n_n_n (zero to three octal digits)
\\xx_H_H the eight-bit character whose value is the hexadecimal
\\xx_H_H the eight-bit character whose value is the hexadecimal
value _H_H (one or two hex digits)
eennaabbllee [--aaddnnppss] [--ff _f_i_l_e_n_a_m_e] [_n_a_m_e ...]
Enable and disable builtin shell commands. Disabling a builtin
Enable and disable builtin shell commands. Disabling a builtin
allows a disk command which has the same name as a shell builtin
to be executed without specifying a full pathname, even though
the shell normally searches for builtins before disk commands.
If --nn is used, each _n_a_m_e is disabled; otherwise, _n_a_m_e_s are
to be executed without specifying a full pathname, even though
the shell normally searches for builtins before disk commands.
If --nn is used, each _n_a_m_e is disabled; otherwise, _n_a_m_e_s are
enabled. For example, to use the tteesstt binary found via the PPAATTHH
instead of the shell builtin version, run ``enable -n test''.
The --ff option means to load the new builtin command _n_a_m_e from
instead of the shell builtin version, run ``enable -n test''.
The --ff option means to load the new builtin command _n_a_m_e from
shared object _f_i_l_e_n_a_m_e, on systems that support dynamic loading.
The --dd option will delete a builtin previously loaded with --ff.
The --dd option will delete a builtin previously loaded with --ff.
If no _n_a_m_e arguments are given, or if the --pp option is supplied,
a list of shell builtins is printed. With no other option argu-
ments, the list consists of all enabled shell builtins. If --nn
is supplied, only disabled builtins are printed. If --aa is sup-
plied, the list printed includes all builtins, with an indica-
tion of whether or not each is enabled. If --ss is supplied, the
output is restricted to the POSIX _s_p_e_c_i_a_l builtins. The return
value is 0 unless a _n_a_m_e is not a shell builtin or there is an
ments, the list consists of all enabled shell builtins. If --nn
is supplied, only disabled builtins are printed. If --aa is sup-
plied, the list printed includes all builtins, with an indica-
tion of whether or not each is enabled. If --ss is supplied, the
output is restricted to the POSIX _s_p_e_c_i_a_l builtins. The return
value is 0 unless a _n_a_m_e is not a shell builtin or there is an
error loading a new builtin from a shared object.
eevvaall [_a_r_g ...]
The _a_r_gs are read and concatenated together into a single com-
mand. This command is then read and executed by the shell, and
its exit status is returned as the value of eevvaall. If there are
The _a_r_gs are read and concatenated together into a single com-
mand. This command is then read and executed by the shell, and
its exit status is returned as the value of eevvaall. If there are
no _a_r_g_s, or only null arguments, eevvaall returns 0.
eexxeecc [--ccll] [--aa _n_a_m_e] [_c_o_m_m_a_n_d [_a_r_g_u_m_e_n_t_s]]
If _c_o_m_m_a_n_d is specified, it replaces the shell. No new process
is created. The _a_r_g_u_m_e_n_t_s become the arguments to _c_o_m_m_a_n_d. If
If _c_o_m_m_a_n_d is specified, it replaces the shell. No new process
is created. The _a_r_g_u_m_e_n_t_s become the arguments to _c_o_m_m_a_n_d. If
the --ll option is supplied, the shell places a dash at the begin-
ning of the zeroth arg passed to _c_o_m_m_a_n_d. This is what _l_o_g_i_n(1)
does. The --cc option causes _c_o_m_m_a_n_d to be executed with an empty
environment. If --aa is supplied, the shell passes _n_a_m_e as the
zeroth argument to the executed command. If _c_o_m_m_a_n_d cannot be
executed for some reason, a non-interactive shell exits, unless
the shell option eexxeeccffaaiill is enabled, in which case it returns
failure. An interactive shell returns failure if the file can-
not be executed. If _c_o_m_m_a_n_d is not specified, any redirections
take effect in the current shell, and the return status is 0.
If there is a redirection error, the return status is 1.
ning of the zeroth argument passed to _c_o_m_m_a_n_d. This is what
_l_o_g_i_n(1) does. The --cc option causes _c_o_m_m_a_n_d to be executed with
an empty environment. If --aa is supplied, the shell passes _n_a_m_e
as the zeroth argument to the executed command. If _c_o_m_m_a_n_d can-
not be executed for some reason, a non-interactive shell exits,
unless the shell option eexxeeccffaaiill is enabled, in which case it
returns failure. An interactive shell returns failure if the
file cannot be executed. If _c_o_m_m_a_n_d is not specified, any redi-
rections take effect in the current shell, and the return status
is 0. If there is a redirection error, the return status is 1.
eexxiitt [_n]
Cause the shell to exit with a status of _n. If _n is omitted,
@@ -692,6 +695,9 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
removes the top directory from the stack, and performs a ccdd to
the new top directory. Arguments, if supplied, have the follow-
ing meanings:
--nn Suppresses the normal change of directory when removing
directories from the stack, so that only the stack is
manipulated.
++_n Removes the _nth entry counting from the left of the list
shown by ddiirrss, starting with zero. For example: ``popd
+0'' removes the first directory, ``popd +1'' the second.
@@ -699,9 +705,6 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
shown by ddiirrss, starting with zero. For example: ``popd
-0'' removes the last directory, ``popd -1'' the next to
last.
--nn Suppresses the normal change of directory when removing
directories from the stack, so that only the stack is
manipulated.
If the ppooppdd command is successful, a ddiirrss is performed as well,
and the return status is 0. ppooppdd returns false if an invalid
@@ -733,22 +736,22 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
null string, as appropriate, had been supplied. The return
value is zero on success, non-zero on failure.
ppuusshhdd [--nn] [_d_i_r]
ppuusshhdd [--nn] [+_n] [-_n]
ppuusshhdd [--nn] [_d_i_r]
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
and returns 0, unless the directory stack is empty. Arguments,
if supplied, have the following meanings:
--nn Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is
manipulated.
++_n Rotates the stack so that the _nth directory (counting
from the left of the list shown by ddiirrss, 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 ddiirrss, starting with
zero) is at the top.
--nn Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is
manipulated.
_d_i_r Adds _d_i_r to the directory stack at the top, making it the
new current working directory.
@@ -863,10 +866,10 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
above) exits with a non-zero status. The shell does not
exit if the command that fails is part of the command
list immediately following a wwhhiillee or uunnttiill keyword,
part of the test in an _i_f statement, part of a &&&& or ||||
list, or if the command's return value is being inverted
via !!. A trap on EERRRR, if set, is executed before the
shell exits.
part of the test in an iiff statement, part of a &&&& or ||||
list, any command in a pipeline but the last, or if the
command's return value is being inverted via !!. A trap
on EERRRR, if set, is executed before the shell exits.
--ff Disable pathname expansion.
--hh Remember the location of commands as they are looked up
for execution. This is enabled by default.
+1163 -1160
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,5 +1,5 @@
From: chet@po.cwru.edu (Chet Ramey)
To: bug-bash@gnu.org
Subject: BASH Frequently-Asked Questions (FAQ version 3.34)
Subject: BASH Frequently-Asked Questions (FAQ version 3.35)
Reply-To: chet@po.cwru.edu
+1 -1
View File
@@ -1,7 +1,7 @@
Newsgroups: comp.unix.shell,comp.unix.questions
Distribution: world
From: chet@po.cwru.edu (Chet Ramey)
Subject: BASH Frequently-Asked Questions (FAQ version 3.34)
Subject: BASH Frequently-Asked Questions (FAQ version 3.35)
Organization: Case Western Reserve University
Summary: A's to Q's about BASH, the Bourne-Again SHell
Reply-To: chet@po.cwru.edu
+1 -1
View File
@@ -1,6 +1,6 @@
Newsgroups: comp.unix.shell,comp.unix.questions,comp.answers,news.answers
From: chet@po.cwru.edu (Chet Ramey)
Subject: [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.34)
Subject: [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.35)
Organization: Case Western Reserve University
Summary: A's to Q's about BASH, the Bourne-Again SHell
Reply-To: chet@po.cwru.edu
+6 -6
View File
@@ -1,18 +1,18 @@
From: chet@po.cwru.edu (Chet Ramey)
To: bug-bash@gnu.org
Subject: BASH Frequently-Asked Questions (FAQ version 3.34)
Subject: BASH Frequently-Asked Questions (FAQ version 3.35)
Reply-To: chet@po.cwru.edu
Archive-name: unix-faq/shell/bash
Posting-Frequency: monthly
Submitted-By: chet@po.cwru.edu (Chet Ramey)
Last-Modified: Tue Oct 10 10:15:38 EDT 2006
FAQ-Version: 3.34
Last-Modified: Thu Dec 14 11:34:54 EST 2006
FAQ-Version: 3.35
Bash-Version: 3.2
URL: ftp://ftp.cwru.edu/pub/bash/FAQ
Maintainer: chet@po.cwru.edu (Chet Ramey)
This is the Bash FAQ, version 3.34, for Bash version 3.2.
This is the Bash FAQ, version 3.35, for Bash version 3.2.
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
@@ -1805,8 +1805,8 @@ it in fine bookstores near you. This edition of the book has been updated
to cover bash-3.0.
The GNU Bash Reference Manual has been published as a printed book by
Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Feb 2003). It covers
bash-2.0 and is available from most online bookstores (see
Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Nov. 2006). It covers
bash-3.2 and is available from most online bookstores (see
http://www.network-theory.co.uk/bash/manual/ for details). The publisher
will donate $1 to the Free Software Foundation for each copy sold.
+6 -6
View File
@@ -1,7 +1,7 @@
Newsgroups: comp.unix.shell,comp.unix.questions
Distribution: world
From: chet@po.cwru.edu (Chet Ramey)
Subject: BASH Frequently-Asked Questions (FAQ version 3.34)
Subject: BASH Frequently-Asked Questions (FAQ version 3.35)
Organization: Case Western Reserve University
Summary: A's to Q's about BASH, the Bourne-Again SHell
Reply-To: chet@po.cwru.edu
@@ -10,13 +10,13 @@ Followup-To: poster
Archive-name: unix-faq/shell/bash
Posting-Frequency: monthly
Submitted-By: chet@po.cwru.edu (Chet Ramey)
Last-Modified: Tue Oct 10 10:15:38 EDT 2006
FAQ-Version: 3.34
Last-Modified: Thu Dec 14 11:34:54 EST 2006
FAQ-Version: 3.35
Bash-Version: 3.2
URL: ftp://ftp.cwru.edu/pub/bash/FAQ
Maintainer: chet@po.cwru.edu (Chet Ramey)
This is the Bash FAQ, version 3.34, for Bash version 3.2.
This is the Bash FAQ, version 3.35, for Bash version 3.2.
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
@@ -1809,8 +1809,8 @@ it in fine bookstores near you. This edition of the book has been updated
to cover bash-3.0.
The GNU Bash Reference Manual has been published as a printed book by
Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Feb 2003). It covers
bash-2.0 and is available from most online bookstores (see
Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Nov. 2006). It covers
bash-3.2 and is available from most online bookstores (see
http://www.network-theory.co.uk/bash/manual/ for details). The publisher
will donate $1 to the Free Software Foundation for each copy sold.
+6 -6
View File
@@ -1,6 +1,6 @@
Newsgroups: comp.unix.shell,comp.unix.questions,comp.answers,news.answers
From: chet@po.cwru.edu (Chet Ramey)
Subject: [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.34)
Subject: [gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.35)
Organization: Case Western Reserve University
Summary: A's to Q's about BASH, the Bourne-Again SHell
Reply-To: chet@po.cwru.edu
@@ -10,13 +10,13 @@ Approved: news-answers-request@MIT.EDU
Archive-name: unix-faq/shell/bash
Posting-Frequency: monthly
Submitted-By: chet@po.cwru.edu (Chet Ramey)
Last-Modified: Tue Oct 10 10:15:38 EDT 2006
FAQ-Version: 3.34
Last-Modified: Thu Dec 14 11:34:54 EST 2006
FAQ-Version: 3.35
Bash-Version: 3.2
URL: ftp://ftp.cwru.edu/pub/bash/FAQ
Maintainer: chet@po.cwru.edu (Chet Ramey)
This is the Bash FAQ, version 3.34, for Bash version 3.2.
This is the Bash FAQ, version 3.35, for Bash version 3.2.
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
@@ -1809,8 +1809,8 @@ it in fine bookstores near you. This edition of the book has been updated
to cover bash-3.0.
The GNU Bash Reference Manual has been published as a printed book by
Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Feb 2003). It covers
bash-2.0 and is available from most online bookstores (see
Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Nov. 2006). It covers
bash-3.2 and is available from most online bookstores (see
http://www.network-theory.co.uk/bash/manual/ for details). The publisher
will donate $1 to the Free Software Foundation for each copy sold.
+2 -2
View File
@@ -1,8 +1,8 @@
Archive-name: unix-faq/shell/bash
Posting-Frequency: monthly
Submitted-By: chet@po.cwru.edu (Chet Ramey)
Last-Modified: Tue Oct 10 10:15:38 EDT 2006
FAQ-Version: 3.34
Last-Modified: Thu Dec 14 11:34:54 EST 2006
FAQ-Version: 3.35
Bash-Version: 3.2
URL: ftp://ftp.cwru.edu/pub/bash/FAQ
Maintainer: chet@po.cwru.edu (Chet Ramey)
+1 -1
View File
@@ -1,6 +1,6 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.19.1
%%CreationDate: Tue Oct 3 08:54:30 2006
%%CreationDate: Tue Dec 12 14:43:07 2006
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%DocumentSuppliedResources: procset grops 1.19 1
+5 -5
View File
@@ -1,5 +1,5 @@
/* error.c -- Functions for handling errors. */
/* Copyright (C) 1993-2003 Free Software Foundation, Inc.
/* Copyright (C) 1993-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -85,7 +85,7 @@ error_prolog (print_lineno)
line = (print_lineno && interactive_shell == 0) ? executing_line_number () : -1;
if (line > 0)
fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : " line ", line);
fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : _(" line "), line);
else
fprintf (stderr, "%s: ", ename);
}
@@ -315,11 +315,11 @@ parser_error (lineno, format, va_alist)
if (interactive)
fprintf (stderr, "%s: ", ename);
else if (interactive_shell)
fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : " line ", lineno);
fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : _(" line "), lineno);
else if (STREQ (ename, iname))
fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : " line ", lineno);
fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : _(" line "), lineno);
else
fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : " line ", lineno);
fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : _(" line "), lineno);
SH_VA_START (args, format);
+452
View File
@@ -0,0 +1,452 @@
/* error.c -- Functions for handling errors. */
/* Copyright (C) 1993-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. */
#include "config.h"
#include "bashtypes.h"
#include <fcntl.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined (PREFER_STDARG)
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include <stdio.h>
#include <errno.h>
#if !defined (errno)
extern int errno;
#endif /* !errno */
#include "bashansi.h"
#include "bashintl.h"
#include "shell.h"
#include "flags.h"
#include "input.h"
#if defined (HISTORY)
# include "bashhist.h"
#endif
extern int executing_line_number __P((void));
extern char *shell_name;
#if defined (JOB_CONTROL)
extern pid_t shell_pgrp;
extern int give_terminal_to __P((pid_t, int));
#endif /* JOB_CONTROL */
#if defined (ARRAY_VARS)
extern char *bash_badsub_errmsg;
#endif
static void error_prolog __P((int));
/* The current maintainer of the shell. You change this in the
Makefile. */
#if !defined (MAINTAINER)
#define MAINTAINER "bash-maintainers@gnu.org"
#endif
char *the_current_maintainer = MAINTAINER;
int gnu_error_format = 0;
static void
error_prolog (print_lineno)
int print_lineno;
{
char *ename;
int line;
ename = get_name_for_error ();
line = (print_lineno && interactive_shell == 0) ? executing_line_number () : -1;
if (line > 0)
fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : " line ", line);
else
fprintf (stderr, "%s: ", ename);
}
/* Return the name of the shell or the shell script for error reporting. */
char *
get_name_for_error ()
{
char *name;
#if defined (ARRAY_VARS)
SHELL_VAR *bash_source_v;
ARRAY *bash_source_a;
#endif
name = (char *)NULL;
if (interactive_shell == 0)
{
#if defined (ARRAY_VARS)
bash_source_v = find_variable ("BASH_SOURCE");
if (bash_source_v && array_p (bash_source_v) &&
(bash_source_a = array_cell (bash_source_v)))
name = array_reference (bash_source_a, 0);
if (name == 0)
#endif
name = dollar_vars[0];
}
if (name == 0 && shell_name && *shell_name)
name = base_pathname (shell_name);
if (name == 0)
#if defined (PROGRAM)
name = PROGRAM;
#else
name = "bash";
#endif
return (name);
}
/* Report an error having to do with FILENAME. This does not use
sys_error so the filename is not interpreted as a printf-style
format string. */
void
file_error (filename)
const char *filename;
{
report_error ("%s: %s", filename, strerror (errno));
}
void
#if defined (PREFER_STDARG)
programming_error (const char *format, ...)
#else
programming_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
char *h;
#if defined (JOB_CONTROL)
give_terminal_to (shell_pgrp, 0);
#endif /* JOB_CONTROL */
SH_VA_START (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
va_end (args);
#if defined (HISTORY)
if (remember_on_history)
{
h = last_history_line ();
fprintf (stderr, _("last command: %s\n"), h ? h : "(null)");
}
#endif
#if 0
fprintf (stderr, "Report this to %s\n", the_current_maintainer);
#endif
fprintf (stderr, _("Aborting..."));
fflush (stderr);
abort ();
}
/* Print an error message and, if `set -e' has been executed, exit the
shell. Used in this file by file_error and programming_error. Used
outside this file mostly to report substitution and expansion errors,
and for bad invocation options. */
void
#if defined (PREFER_STDARG)
report_error (const char *format, ...)
#else
report_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
error_prolog (1);
SH_VA_START (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
va_end (args);
if (exit_immediately_on_error)
exit_shell (1);
}
void
#if defined (PREFER_STDARG)
fatal_error (const char *format, ...)
#else
fatal_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
error_prolog (0);
SH_VA_START (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
va_end (args);
sh_exit (2);
}
void
#if defined (PREFER_STDARG)
internal_error (const char *format, ...)
#else
internal_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
error_prolog (1);
SH_VA_START (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
va_end (args);
}
void
#if defined (PREFER_STDARG)
internal_warning (const char *format, ...)
#else
internal_warning (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
fprintf (stderr, _("%s: warning: "), get_name_for_error ());
SH_VA_START (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
va_end (args);
}
void
#if defined (PREFER_STDARG)
sys_error (const char *format, ...)
#else
sys_error (format, va_alist)
const char *format;
va_dcl
#endif
{
int e;
va_list args;
e = errno;
error_prolog (0);
SH_VA_START (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, ": %s\n", strerror (e));
va_end (args);
}
/* An error from the parser takes the general form
shell_name: input file name: line number: message
The input file name and line number are omitted if the shell is
currently interactive. If the shell is not currently interactive,
the input file name is inserted only if it is different from the
shell name. */
void
#if defined (PREFER_STDARG)
parser_error (int lineno, const char *format, ...)
#else
parser_error (lineno, format, va_alist)
int lineno;
const char *format;
va_dcl
#endif
{
va_list args;
char *ename, *iname;
ename = get_name_for_error ();
iname = yy_input_name ();
if (interactive)
fprintf (stderr, "%s: ", ename);
else if (interactive_shell)
fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : " line ", lineno);
else if (STREQ (ename, iname))
fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : " line ", lineno);
else
fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : " line ", lineno);
SH_VA_START (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
va_end (args);
if (exit_immediately_on_error)
exit_shell (2);
}
#ifdef DEBUG
void
#if defined (PREFER_STDARG)
itrace (const char *format, ...)
#else
itrace (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
fprintf(stderr, "TRACE: pid %ld: ", (long)getpid());
SH_VA_START (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
va_end (args);
fflush(stderr);
}
/* A trace function for silent debugging -- doesn't require a control
terminal. */
void
#if defined (PREFER_STDARG)
trace (const char *format, ...)
#else
trace (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
static FILE *tracefp = (FILE *)NULL;
if (tracefp == NULL)
tracefp = fopen("/tmp/bash-trace.log", "a+");
if (tracefp == NULL)
tracefp = stderr;
else
fcntl (fileno (tracefp), F_SETFD, 1); /* close-on-exec */
fprintf(tracefp, "TRACE: pid %ld: ", (long)getpid());
SH_VA_START (args, format);
vfprintf (tracefp, format, args);
fprintf (tracefp, "\n");
va_end (args);
fflush(tracefp);
}
#endif /* DEBUG */
/* **************************************************************** */
/* */
/* Common error reporting */
/* */
/* **************************************************************** */
static char *cmd_error_table[] = {
N_("unknown command error"), /* CMDERR_DEFAULT */
N_("bad command type"), /* CMDERR_BADTYPE */
N_("bad connector"), /* CMDERR_BADCONN */
N_("bad jump"), /* CMDERR_BADJUMP */
0
};
void
command_error (func, code, e, flags)
const char *func;
int code, e, flags; /* flags currently unused */
{
if (code > CMDERR_LAST)
code = CMDERR_DEFAULT;
programming_error ("%s: %s: %d", func, _(cmd_error_table[code]), e);
}
char *
command_errstr (code)
int code;
{
if (code > CMDERR_LAST)
code = CMDERR_DEFAULT;
return (_(cmd_error_table[code]));
}
#ifdef ARRAY_VARS
void
err_badarraysub (s)
const char *s;
{
report_error ("%s: %s", s, _(bash_badsub_errmsg));
}
#endif
void
err_unboundvar (s)
const char *s;
{
report_error (_("%s: unbound variable"), s);
}
void
err_readonly (s)
const char *s;
{
report_error (_("%s: readonly variable"), s);
}
+2 -2
View File
@@ -1,6 +1,6 @@
/* execute_cmd.c -- Execute a COMMAND structure. */
/* 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.
@@ -1396,7 +1396,7 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close)
/* Make a pipeline between the two commands. */
if (pipe (fildes) < 0)
{
sys_error ("pipe error");
sys_error (_("pipe error"));
#if defined (JOB_CONTROL)
terminate_current_pipeline ();
kill_current_pipeline ();
+4144
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1,6 +1,6 @@
/* expr.c -- arithmetic expression evaluation. */
/* Copyright (C) 1990-2004 Free Software Foundation, Inc.
/* Copyright (C) 1990-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -1194,7 +1194,7 @@ evalerror (msg)
name = this_command_name;
for (t = expression; whitespace (*t); t++)
;
internal_error ("%s%s%s: %s (error token is \"%s\")",
internal_error (_("%s%s%s: %s (error token is \"%s\")"),
name ? name : "", name ? ": " : "", t,
msg, (lasttp && *lasttp) ? lasttp : "");
longjmp (evalbuf, 1);
@@ -1321,7 +1321,7 @@ main (argc, argv)
{
v = evalexp (argv[i], &expok);
if (expok == 0)
fprintf (stderr, "%s: expression error\n", argv[i]);
fprintf (stderr, _("%s: expression error\n"), argv[i]);
else
printf ("'%s' -> %ld\n", argv[i], v);
}
+1348
View File
File diff suppressed because it is too large Load Diff
+21 -21
View File
@@ -462,7 +462,7 @@ start_pipeline ()
if (job_control)
{
if (pipe (pgrp_pipe) == -1)
sys_error ("start_pipeline: pgrp pipe");
sys_error (_("start_pipeline: pgrp pipe"));
}
#endif
}
@@ -1085,7 +1085,7 @@ add_process (name, pid)
{
# ifdef DEBUG
if (j == NO_JOB)
internal_warning ("add_process: process %5ld (%s) in the_pipeline", (long)p->pid, p->command);
internal_warning (_("add_process: process %5ld (%s) in the_pipeline"), (long)p->pid, p->command);
# endif
if (PALIVE (p))
internal_warning ("add_process: pid %5ld (%s) marked as still alive", (long)p->pid, p->command);
@@ -1391,7 +1391,7 @@ j_strsignal (s)
if (x == 0)
{
x = retcode_name_buffer;
sprintf (x, "Signal %d", s);
sprintf (x, _("Signal %d"), s);
}
return x;
}
@@ -1405,20 +1405,20 @@ printable_job_status (j, p, format)
static char *temp;
int es;
temp = "Done";
temp = _("Done");
if (STOPPED (j) && format == 0)
{
if (posixly_correct == 0 || p == 0 || (WIFSTOPPED (p->status) == 0))
temp = "Stopped";
temp = _("Stopped");
else
{
temp = retcode_name_buffer;
sprintf (temp, "Stopped(%s)", signal_name (WSTOPSIG (p->status)));
sprintf (temp, _("Stopped(%s)"), signal_name (WSTOPSIG (p->status)));
}
}
else if (RUNNING (j))
temp = "Running";
temp = _("Running");
else
{
if (WIFSTOPPED (p->status))
@@ -1430,14 +1430,14 @@ printable_job_status (j, p, format)
temp = retcode_name_buffer;
es = WEXITSTATUS (p->status);
if (es == 0)
strcpy (temp, "Done");
strcpy (temp, _("Done"));
else if (posixly_correct)
sprintf (temp, "Done(%d)", es);
sprintf (temp, _("Done(%d)"), es);
else
sprintf (temp, "Exit %d", es);
sprintf (temp, _("Exit %d"), es);
}
else
temp = "Unknown status";
temp = _("Unknown status");
}
return temp;
@@ -1524,7 +1524,7 @@ print_pipeline (p, job_index, format, stream)
if ((WIFSTOPPED (show->status) == 0) &&
(WIFCONTINUED (show->status) == 0) &&
WIFCORED (show->status))
fprintf (stream, "(core dumped) ");
fprintf (stream, _("(core dumped) "));
}
}
@@ -1543,7 +1543,7 @@ print_pipeline (p, job_index, format, stream)
if (strcmp (temp, jobs[job_index]->wd) != 0)
fprintf (stream,
" (wd: %s)", polite_directory_format (jobs[job_index]->wd));
_(" (wd: %s)"), polite_directory_format (jobs[job_index]->wd));
}
if (format || (p == last))
@@ -1735,7 +1735,7 @@ make_child (command, async_p)
B.4.3.3, p. 237 also covers this, in the context of job control
shells. */
if (setpgid (mypid, pipeline_pgrp) < 0)
sys_error ("child setpgid (%ld to %ld)", (long)mypid, (long)pipeline_pgrp);
sys_error (_("child setpgid (%ld to %ld)"), (long)mypid, (long)pipeline_pgrp);
/* By convention (and assumption above), if
pipeline_pgrp == shell_pgrp, we are making a child for
@@ -3399,7 +3399,7 @@ notify_of_job_status ()
signal_is_trapped (termsig) == 0)
{
/* Don't print `0' for a line number. */
fprintf (stderr, "%s: line %d: ", get_name_for_error (), (line_number == 0) ? 1 : line_number);
fprintf (stderr, _("%s: line %d: "), get_name_for_error (), (line_number == 0) ? 1 : line_number);
pretty_print_job (job, JLIST_NONINTERACTIVE, stderr);
}
else if (IS_FOREGROUND (job))
@@ -3413,7 +3413,7 @@ notify_of_job_status ()
fprintf (stderr, "%s", j_strsignal (termsig));
if (WIFCORED (s))
fprintf (stderr, " (core dumped)");
fprintf (stderr, _(" (core dumped)"));
fprintf (stderr, "\n");
}
@@ -3425,7 +3425,7 @@ notify_of_job_status ()
pretty_print_job (job, JLIST_STANDARD, stderr);
if (dir && strcmp (dir, jobs[job]->wd) != 0)
fprintf (stderr,
"(wd now: %s)\n", polite_directory_format (dir));
_("(wd now: %s)\n"), polite_directory_format (dir));
}
jobs[job]->flags |= J_NOTIFIED;
@@ -3438,7 +3438,7 @@ notify_of_job_status ()
pretty_print_job (job, JLIST_STANDARD, stderr);
if (dir && (strcmp (dir, jobs[job]->wd) != 0))
fprintf (stderr,
"(wd now: %s)\n", polite_directory_format (dir));
_("(wd now: %s)\n"), polite_directory_format (dir));
jobs[job]->flags |= J_NOTIFIED;
break;
@@ -3466,7 +3466,7 @@ initialize_job_control (force)
if (shell_pgrp == -1)
{
sys_error ("initialize_job_control: getpgrp failed");
sys_error (_("initialize_job_control: getpgrp failed"));
exit (1);
}
@@ -3512,7 +3512,7 @@ initialize_job_control (force)
/* Make sure that we are using the new line discipline. */
if (set_new_line_discipline (shell_tty) < 0)
{
sys_error ("initialize_job_control: line discipline");
sys_error (_("initialize_job_control: line discipline"));
job_control = 0;
}
else
@@ -3522,7 +3522,7 @@ initialize_job_control (force)
if ((original_pgrp != shell_pgrp) && (setpgid (0, shell_pgrp) < 0))
{
sys_error ("initialize_job_control: setpgid");
sys_error (_("initialize_job_control: setpgid"));
shell_pgrp = original_pgrp;
}
+4 -2
View File
@@ -462,7 +462,7 @@ start_pipeline ()
if (job_control)
{
if (pipe (pgrp_pipe) == -1)
sys_error ("start_pipeline: pgrp pipe");
sys_error (_("start_pipeline: pgrp pipe"));
}
#endif
}
@@ -1085,7 +1085,7 @@ add_process (name, pid)
{
# ifdef DEBUG
if (j == NO_JOB)
internal_warning ("add_process: process %5ld (%s) in the_pipeline", (long)p->pid, p->command);
internal_warning (_("add_process: process %5ld (%s) in the_pipeline"), (long)p->pid, p->command);
# endif
if (PALIVE (p))
internal_warning ("add_process: pid %5ld (%s) marked as still alive", (long)p->pid, p->command);
@@ -1772,8 +1772,10 @@ make_child (command, async_p)
pipe_close (pgrp_pipe);
#endif /* PGRP_PIPE */
#if 0
if (async_p)
last_asynchronous_pid = mypid; /* XXX */
#endif
#if defined (RECYCLES_PIDS)
else if (last_asynchronous_pid == mypid)
/* Avoid pid aliasing. 1 seems like a safe, unusual pid value. */
+2 -2
View File
@@ -921,10 +921,10 @@ _rl_init_file_error (msg)
const char *msg;
{
if (currently_reading_init_file)
fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
_rl_errmsg ("%s: line %d: %s\n", current_readline_init_file,
current_readline_init_lineno, msg);
else
fprintf (stderr, "readline: %s\n", msg);
_rl_errmsg ("%s", msg);
}
/* **************************************************************** */
+1 -1
View File
@@ -111,7 +111,7 @@ rl_callback_read_char ()
if (rl_linefunc == NULL)
{
fprintf (stderr, "readline: readline_callback_read_char() called with no handler!\r\n");
_rl_errmsg ("readline_callback_read_char() called with no handler!");
abort ();
}
+1 -1
View File
@@ -1749,7 +1749,7 @@ rl_complete_internal (what_to_do)
break;
default:
fprintf (stderr, "\r\nreadline: bad value %d for what_to_do in rl_complete\n", what_to_do);
_rl_ttymsg ("bad value %d for what_to_do in rl_complete", what_to_do);
rl_ding ();
FREE (saved_line_buffer);
RL_UNSETSTATE(RL_STATE_COMPLETING);
+2 -2
View File
@@ -2169,7 +2169,7 @@ insert_some_chars (string, count, col)
/* DEBUGGING */
if (MB_CUR_MAX == 1 || rl_byte_oriented)
if (count != col)
fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col);
_rl_ttymsg ("debug: insert_some_chars: count (%d) != col (%d)", count, col);
/* If IC is defined, then we do not have to "enter" insert mode. */
if (_rl_term_IC)
@@ -2410,7 +2410,7 @@ _rl_col_width (str, start, end)
return 0;
if (MB_CUR_MAX == 1 || rl_byte_oriented)
{
fprintf (stderr, "_rl_col_width: called with MB_CUR_MAX == 1\n");
_rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1");
return (end - start);
}
+2 -2
View File
@@ -133,7 +133,7 @@ history list and history file.
@item fc
@btindex fc
@example
@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]}
@code{fc [-e @var{ename}] [-lnr] [@var{first}] [@var{last}]}
@code{fc -s [@var{pat}=@var{rep}] [@var{command}]}
@end example
@@ -412,7 +412,7 @@ of the following modifiers, each preceded by a @samp{:}.
Remove a trailing pathname component, leaving only the head.
@item t
Remove all leading pathname components, leaving the tail.
Remove all leading pathname components, leaving the tail.
@item r
Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving
+457
View File
@@ -0,0 +1,457 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988-2006 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
provided the copyright notice and this permission notice are preserved on
all copies.
Permission is granted to process this file through Tex and print the
results, provided the printed document carries copying permission notice
identical to this one except for the removal of this paragraph (this
paragraph not being relevant to the printed manual).
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
GNU Copyright statement is available to the distributee, and provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
@end ignore
@node Using History Interactively
@chapter Using History Interactively
@ifclear BashFeatures
@defcodeindex bt
@end ifclear
@ifset BashFeatures
This chapter describes how to use the @sc{gnu} History Library
interactively, from a user's standpoint.
It should be considered a user's guide.
For information on using the @sc{gnu} History Library in other programs,
see the @sc{gnu} Readline Library Manual.
@end ifset
@ifclear BashFeatures
This chapter describes how to use the @sc{gnu} History Library interactively,
from a user's standpoint. It should be considered a user's guide. For
information on using the @sc{gnu} History Library in your own programs,
@pxref{Programming with GNU History}.
@end ifclear
@ifset BashFeatures
@menu
* Bash History Facilities:: How Bash lets you manipulate your command
history.
* Bash History Builtins:: The Bash builtin commands that manipulate
the command history.
* History Interaction:: What it feels like using History as a user.
@end menu
@end ifset
@ifclear BashFeatures
@menu
* History Interaction:: What it feels like using History as a user.
@end menu
@end ifclear
@ifset BashFeatures
@node Bash History Facilities
@section Bash History Facilities
@cindex command history
@cindex history list
When the @option{-o history} option to the @code{set} builtin
is enabled (@pxref{The Set Builtin}),
the shell provides access to the @dfn{command history},
the list of commands previously typed.
The value of the @env{HISTSIZE} shell variable is used as the
number of commands to save in a history list.
The text of the last @env{$HISTSIZE}
commands (default 500) is saved.
The shell stores each command in the history list prior to
parameter and variable expansion
but after history expansion is performed, subject to the
values of the shell variables
@env{HISTIGNORE} and @env{HISTCONTROL}.
When the shell starts up, the history is initialized from the
file named by the @env{HISTFILE} variable (default @file{~/.bash_history}).
The file named by the value of @env{HISTFILE} is truncated, if
necessary, to contain no more than the number of lines specified by
the value of the @env{HISTFILESIZE} variable.
When an interactive shell exits, the last
@env{$HISTSIZE} lines are copied from the history list to the file
named by @env{$HISTFILE}.
If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
the lines are appended to the history file,
otherwise the history file is overwritten.
If @env{HISTFILE}
is unset, or if the history file is unwritable, the history is
not saved. After saving the history, the history file is truncated
to contain no more than @env{$HISTFILESIZE}
lines. If @env{HISTFILESIZE} is not set, no truncation is performed.
If the @env{HISTTIMEFORMAT} is set, the time stamp information
associated with each history entry is written to the history file.
The builtin command @code{fc} may be used to list or edit and re-execute
a portion of the history list.
The @code{history} builtin may be used to display or modify the history
list and manipulate the history file.
When using command-line editing, search commands
are available in each editing mode that provide access to the
history list (@pxref{Commands For History}).
The shell allows control over which commands are saved on the history
list. The @env{HISTCONTROL} and @env{HISTIGNORE}
variables may be set to cause the shell to save only a subset of the
commands entered.
The @code{cmdhist}
shell option, if enabled, causes the shell to attempt to save each
line of a multi-line command in the same history entry, adding
semicolons where necessary to preserve syntactic correctness.
The @code{lithist}
shell option causes the shell to save the command with embedded newlines
instead of semicolons.
The @code{shopt} builtin is used to set these options.
@xref{Bash Builtins}, for a description of @code{shopt}.
@node Bash History Builtins
@section Bash History Builtins
@cindex history builtins
Bash provides two builtin commands which manipulate the
history list and history file.
@table @code
@item fc
@btindex fc
@example
@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]}
@code{fc -s [@var{pat}=@var{rep}] [@var{command}]}
@end example
Fix Command. In the first form, a range of commands from @var{first} to
@var{last} is selected from the history list. Both @var{first} and
@var{last} may be specified as a string (to locate the most recent
command beginning with that string) or as a number (an index into the
history list, where a negative number is used as an offset from the
current command number). If @var{last} is not specified it is set to
@var{first}. If @var{first} is not specified it is set to the previous
command for editing and @minus{}16 for listing. If the @option{-l} flag is
given, the commands are listed on standard output. The @option{-n} flag
suppresses the command numbers when listing. The @option{-r} flag
reverses the order of the listing. Otherwise, the editor given by
@var{ename} is invoked on a file containing those commands. If
@var{ename} is not given, the value of the following variable expansion
is used: @code{$@{FCEDIT:-$@{EDITOR:-vi@}@}}. This says to use the
value of the @env{FCEDIT} variable if set, or the value of the
@env{EDITOR} variable if that is set, or @code{vi} if neither is set.
When editing is complete, the edited commands are echoed and executed.
In the second form, @var{command} is re-executed after each instance
of @var{pat} in the selected command is replaced by @var{rep}.
A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so
that typing @samp{r cc} runs the last command beginning with @code{cc}
and typing @samp{r} re-executes the last command (@pxref{Aliases}).
@item history
@btindex history
@example
history [@var{n}]
history -c
history -d @var{offset}
history [-anrw] [@var{filename}]
history -ps @var{arg}
@end example
With no options, display the history list with line numbers.
Lines prefixed with a @samp{*} have been modified.
An argument of @var{n} lists only the last @var{n} lines.
If the shell variable @env{HISTTIMEFORMAT} is set and not null,
it is used as a format string for @var{strftime} to display
the time stamp associated with each displayed history entry.
No intervening blank is printed between the formatted time stamp
and the history line.
Options, if supplied, have the following meanings:
@table @code
@item -c
Clear the history list. This may be combined
with the other options to replace the history list completely.
@item -d @var{offset}
Delete the history entry at position @var{offset}.
@var{offset} should be specified as it appears when the history is
displayed.
@item -a
Append the new
history lines (history lines entered since the beginning of the
current Bash session) to the history file.
@item -n
Append the history lines not already read from the history file
to the current history list. These are lines appended to the history
file since the beginning of the current Bash session.
@item -r
Read the current history file and append its contents to
the history list.
@item -w
Write out the current history to the history file.
@item -p
Perform history substitution on the @var{arg}s and display the result
on the standard output, without storing the results in the history list.
@item -s
The @var{arg}s are added to the end of
the history list as a single entry.
@end table
When any of the @option{-w}, @option{-r}, @option{-a}, or @option{-n} options is
used, if @var{filename}
is given, then it is used as the history file. If not, then
the value of the @env{HISTFILE} variable is used.
@end table
@end ifset
@node History Interaction
@section History Expansion
@cindex history expansion
The History library provides a history expansion feature that is similar
to the history expansion provided by @code{csh}. This section
describes the syntax used to manipulate the history information.
History expansions introduce words from the history list into
the input stream, making it easy to repeat commands, insert the
arguments to a previous command into the current input line, or
fix errors in previous commands quickly.
History expansion takes place in two parts. The first is to determine
which line from the history list should be used during substitution.
The second is to select portions of that line for inclusion into the
current one. The line selected from the history is called the
@dfn{event}, and the portions of that line that are acted upon are
called @dfn{words}. Various @dfn{modifiers} are available to manipulate
the selected words. The line is broken into words in the same fashion
that Bash does, so that several words
surrounded by quotes are considered one word.
History expansions are introduced by the appearance of the
history expansion character, which is @samp{!} by default.
@ifset BashFeatures
Only @samp{\} and @samp{'} may be used to escape the history expansion
character.
@end ifset
@ifset BashFeatures
Several shell options settable with the @code{shopt}
builtin (@pxref{Bash Builtins}) may be used to tailor
the behavior of history expansion. If the
@code{histverify} shell option is enabled, and Readline
is being used, history substitutions are not immediately passed to
the shell parser.
Instead, the expanded line is reloaded into the Readline
editing buffer for further modification.
If Readline is being used, and the @code{histreedit}
shell option is enabled, a failed history expansion will be
reloaded into the Readline editing buffer for correction.
The @option{-p} option to the @code{history} builtin command
may be used to see what a history expansion will do before using it.
The @option{-s} option to the @code{history} builtin may be used to
add commands to the end of the history list without actually executing
them, so that they are available for subsequent recall.
This is most useful in conjunction with Readline.
The shell allows control of the various characters used by the
history expansion mechanism with the @code{histchars} variable.
@end ifset
@menu
* Event Designators:: How to specify which history line to use.
* Word Designators:: Specifying which words are of interest.
* Modifiers:: Modifying the results of substitution.
@end menu
@node Event Designators
@subsection Event Designators
@cindex event designators
An event designator is a reference to a command line entry in the
history list.
@cindex history events
@table @asis
@item @code{!}
@ifset BashFeatures
Start a history substitution, except when followed by a space, tab,
the end of the line, @samp{=} or @samp{(} (when the
@code{extglob} shell option is enabled using the @code{shopt} builtin).
@end ifset
@ifclear BashFeatures
Start a history substitution, except when followed by a space, tab,
the end of the line, or @samp{=}.
@end ifclear
@item @code{!@var{n}}
Refer to command line @var{n}.
@item @code{!-@var{n}}
Refer to the command @var{n} lines back.
@item @code{!!}
Refer to the previous command. This is a synonym for @samp{!-1}.
@item @code{!@var{string}}
Refer to the most recent command starting with @var{string}.
@item @code{!?@var{string}[?]}
Refer to the most recent command containing @var{string}. The trailing
@samp{?} may be omitted if the @var{string} is followed immediately by
a newline.
@item @code{^@var{string1}^@var{string2}^}
Quick Substitution. Repeat the last command, replacing @var{string1}
with @var{string2}. Equivalent to
@code{!!:s/@var{string1}/@var{string2}/}.
@item @code{!#}
The entire command line typed so far.
@end table
@node Word Designators
@subsection Word Designators
Word designators are used to select desired words from the event.
A @samp{:} separates the event specification from the word designator. It
may be omitted if the word designator begins with a @samp{^}, @samp{$},
@samp{*}, @samp{-}, or @samp{%}. Words are numbered from the beginning
of the line, with the first word being denoted by 0 (zero). Words are
inserted into the current line separated by single spaces.
@need 0.75
For example,
@table @code
@item !!
designates the preceding command. When you type this, the preceding
command is repeated in toto.
@item !!:$
designates the last argument of the preceding command. This may be
shortened to @code{!$}.
@item !fi:2
designates the second argument of the most recent command starting with
the letters @code{fi}.
@end table
@need 0.75
Here are the word designators:
@table @code
@item 0 (zero)
The @code{0}th word. For many applications, this is the command word.
@item @var{n}
The @var{n}th word.
@item ^
The first argument; that is, word 1.
@item $
The last argument.
@item %
The word matched by the most recent @samp{?@var{string}?} search.
@item @var{x}-@var{y}
A range of words; @samp{-@var{y}} abbreviates @samp{0-@var{y}}.
@item *
All of the words, except the @code{0}th. This is a synonym for @samp{1-$}.
It is not an error to use @samp{*} if there is just one word in the event;
the empty string is returned in that case.
@item @var{x}*
Abbreviates @samp{@var{x}-$}
@item @var{x}-
Abbreviates @samp{@var{x}-$} like @samp{@var{x}*}, but omits the last word.
@end table
If a word designator is supplied without an event specification, the
previous command is used as the event.
@node Modifiers
@subsection Modifiers
After the optional word designator, you can add a sequence of one or more
of the following modifiers, each preceded by a @samp{:}.
@table @code
@item h
Remove a trailing pathname component, leaving only the head.
@item t
Remove all leading pathname components, leaving the tail.
@item r
Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving
the basename.
@item e
Remove all but the trailing suffix.
@item p
Print the new command but do not execute it.
@ifset BashFeatures
@item q
Quote the substituted words, escaping further substitutions.
@item x
Quote the substituted words as with @samp{q},
but break into words at spaces, tabs, and newlines.
@end ifset
@item s/@var{old}/@var{new}/
Substitute @var{new} for the first occurrence of @var{old} in the
event line. Any delimiter may be used in place of @samp{/}.
The delimiter may be quoted in @var{old} and @var{new}
with a single backslash. If @samp{&} appears in @var{new},
it is replaced by @var{old}. A single backslash will quote
the @samp{&}. The final delimiter is optional if it is the last
character on the input line.
@item &
Repeat the previous substitution.
@item g
@itemx a
Cause changes to be applied over the entire event line. Used in
conjunction with @samp{s}, as in @code{gs/@var{old}/@var{new}/},
or with @samp{&}.
@item G
Apply the following @samp{s} modifier once to each word in the event.
@end table
+2 -2
View File
@@ -1662,8 +1662,8 @@ matches were generated.
@btindex complete
@example
@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
[-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}]
[-C @var{command}] @var{name} [@var{name} @dots{}]}
[-F @var{function}] [-C @var{command}] [-X @var{filterpat}]
[-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]}
@code{complete -pr [@var{name} @dots{}]}
@end example
File diff suppressed because it is too large Load Diff
+9 -1
View File
@@ -1,7 +1,7 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
/* Copyright (C) 1999-2005 Free Software Foundation, Inc.
/* Copyright (C) 1999-2006 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
@@ -316,6 +316,14 @@ extern UNDO_LIST *_rl_copy_undo_entry PARAMS((UNDO_LIST *));
extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *));
/* util.c */
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
extern void _rl_ttymsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
extern void _rl_errmsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
#else
extern void _rl_ttymsg ();
extern void _rl_errmsg ();
#endif
extern int _rl_abort_internal PARAMS((void));
extern char *_rl_strindex PARAMS((const char *, const char *));
extern int _rl_qsort_string_compare PARAMS((char **, char **));
+3 -3
View File
@@ -464,7 +464,7 @@ static void
rltty_warning (msg)
char *msg;
{
fprintf (stderr, "readline: warning: %s\n", msg);
_rl_errmsg ("warning: %s", msg);
}
#endif
@@ -475,7 +475,7 @@ TIOTYPE *tp;
{
if ((tp->c_oflag & OPOST) == 0)
{
rltty_warning ("turning on OPOST for terminal\r");
_rl_errmsg ("warning: turning on OPOST for terminal\r");
tp->c_oflag |= OPOST|ONLCR;
}
}
@@ -501,7 +501,7 @@ _get_tty_settings (tty, tiop)
if (OUTPUT_BEING_FLUSHED (tiop))
{
#if defined (FLUSHO) && defined (_AIX41)
rltty_warning ("turning off output flushing");
_rl_errmsg ("warning: turning off output flushing");
tiop->c_lflag &= ~FLUSHO;
break;
#else
+80
View File
@@ -220,6 +220,86 @@ rl_tilde_expand (ignore, key)
return (0);
}
#if defined (USE_VARARGS)
void
#if defined (PREFER_STDARG)
_rl_ttymsg (const char *format, ...)
#else
_rl_ttymsg (va_alist)
va_dcl
#endif
{
va_list args;
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
fprintf (stderr, "readline: ");
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
fflush (stderr);
va_end (args);
rl_forced_update_display ();
}
void
#if defined (PREFER_STDARG)
_rl_errmsg (const char *format, ...)
#else
_rl_errmsg (va_alist)
va_dcl
#endif
{
va_list args;
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
fprintf (stderr, "readline: ");
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
fflush (stderr);
va_end (args);
}
#else /* !USE_VARARGS */
void
_rl_ttymsg (format, arg1, arg2)
char *format;
{
fprintf (stderr, "readline: ");
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
rl_forced_update_display ();
}
void
_rl_errmsg (format, arg1, arg2)
char *format;
{
fprintf (stderr, "readline: ");
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
}
#endif /* !USE_VARARGS */
/* **************************************************************** */
/* */
/* String Utility Functions */
+3
View File
@@ -91,6 +91,9 @@ get_tmpdir (flags)
char *tdir;
tdir = (flags & MT_USETMPDIR) ? get_string_value ("TMPDIR") : (char *)NULL;
if (tdir && (file_iswdir (tdir) == 0 || strlen (tdir) > PATH_MAX))
tdir = 0;
if (tdir == 0)
tdir = get_sys_tmpdir ();
+417
View File
@@ -0,0 +1,417 @@
/*
* mksyntax.c - construct shell syntax table for fast char attribute lookup.
*/
/* Copyright (C) 2000-2002 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. */
#include "config.h"
#include <stdio.h>
#include "bashansi.h"
#include "chartypes.h"
#include <errno.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "bashintl.h"
#include "syntax.h"
extern int optind;
extern char *optarg;
#ifndef errno
extern int errno;
#endif
#ifndef HAVE_STRERROR
extern char *strerror();
#endif
struct wordflag {
int flag;
char *fstr;
} wordflags[] = {
{ CWORD, "CWORD" },
{ CSHMETA, "CSHMETA" },
{ CSHBRK, "CSHBRK" },
{ CBACKQ, "CBACKQ" },
{ CQUOTE, "CQUOTE" },
{ CSPECL, "CSPECL" },
{ CEXP, "CEXP" },
{ CBSDQUOTE, "CBSDQUOTE" },
{ CBSHDOC, "CBSHDOC" },
{ CGLOB, "CGLOB" },
{ CXGLOB, "CXGLOB" },
{ CXQUOTE, "CXQUOTE" },
{ CSPECVAR, "CSPECVAR" },
{ CSUBSTOP, "CSUBSTOP" },
{ CBLANK, "CBLANK" },
};
#define N_WFLAGS (sizeof (wordflags) / sizeof (wordflags[0]))
#define SYNSIZE 256
int lsyntax[SYNSIZE];
int debug;
char *progname;
char preamble[] = "\
/*\n\
* This file was generated by mksyntax. DO NOT EDIT.\n\
*/\n\
\n";
char includes[] = "\
#include \"config.h\"\n\
#include \"stdc.h\"\n\
#include \"syntax.h\"\n\n";
static void
usage()
{
fprintf (stderr, _("%s: usage: %s [-d] [-o filename]\n"), progname, progname);
exit (2);
}
#ifdef INCLUDE_UNUSED
static int
getcflag (s)
char *s;
{
int i;
for (i = 0; i < N_WFLAGS; i++)
if (strcmp (s, wordflags[i].fstr) == 0)
return wordflags[i].flag;
return -1;
}
#endif
static char *
cdesc (i)
int i;
{
static char xbuf[16];
if (i == ' ')
return "SPC";
else if (ISPRINT (i))
{
xbuf[0] = i;
xbuf[1] = '\0';
return (xbuf);
}
else if (i == CTLESC)
return "CTLESC";
else if (i == CTLNUL)
return "CTLNUL";
else if (i == '\033') /* ASCII */
return "ESC";
xbuf[0] = '\\';
xbuf[2] = '\0';
switch (i)
{
#ifdef __STDC__
case '\a': xbuf[1] = 'a'; break;
case '\v': xbuf[1] = 'v'; break;
#else
case '\007': xbuf[1] = 'a'; break;
case 0x0B: xbuf[1] = 'v'; break;
#endif
case '\b': xbuf[1] = 'b'; break;
case '\f': xbuf[1] = 'f'; break;
case '\n': xbuf[1] = 'n'; break;
case '\r': xbuf[1] = 'r'; break;
case '\t': xbuf[1] = 't'; break;
default: sprintf (xbuf, "%d", i); break;
}
return xbuf;
}
static char *
getcstr (f)
int f;
{
int i;
for (i = 0; i < N_WFLAGS; i++)
if (f == wordflags[i].flag)
return (wordflags[i].fstr);
return ((char *)NULL);
}
static void
addcstr (str, flag)
char *str;
int flag;
{
char *s, *fstr;
unsigned char uc;
for (s = str; s && *s; s++)
{
uc = *s;
if (debug)
{
fstr = getcstr (flag);
fprintf(stderr, _("added %s for character %s\n"), fstr, cdesc(uc));
}
lsyntax[uc] |= flag;
}
}
static void
addcchar (c, flag)
unsigned char c;
int flag;
{
char *fstr;
if (debug)
{
fstr = getcstr (flag);
fprintf (stderr, _("added %s for character %s\n"), fstr, cdesc(c));
}
lsyntax[c] |= flag;
}
static void
addblanks ()
{
register int i;
unsigned char uc;
for (i = 0; i < SYNSIZE; i++)
{
uc = i;
/* Since we don't call setlocale(), this defaults to the "C" locale, and
the default blank characters will be space and tab. */
if (isblank (uc))
lsyntax[uc] |= CBLANK;
}
}
/* load up the correct flag values in lsyntax */
static void
load_lsyntax ()
{
/* shell metacharacters */
addcstr (shell_meta_chars, CSHMETA);
/* shell word break characters */
addcstr (shell_break_chars, CSHBRK);
addcchar ('`', CBACKQ);
addcstr (shell_quote_chars, CQUOTE);
addcchar (CTLESC, CSPECL);
addcchar (CTLNUL, CSPECL);
addcstr (shell_exp_chars, CEXP);
addcstr (slashify_in_quotes, CBSDQUOTE);
addcstr (slashify_in_here_document, CBSHDOC);
addcstr (shell_glob_chars, CGLOB);
#if defined (EXTENDED_GLOB)
addcstr (ext_glob_chars, CXGLOB);
#endif
addcstr (shell_quote_chars, CXQUOTE);
addcchar ('\\', CXQUOTE);
addcstr ("@*#?-$!", CSPECVAR); /* omits $0...$9 and $_ */
addcstr ("-=?+", CSUBSTOP); /* OP in ${paramOPword} */
addblanks ();
}
static void
dump_lflags (fp, ind)
FILE *fp;
int ind;
{
int xflags, first, i;
xflags = lsyntax[ind];
first = 1;
if (xflags == 0)
fputs (wordflags[0].fstr, fp);
else
{
for (i = 1; i < N_WFLAGS; i++)
if (xflags & wordflags[i].flag)
{
if (first)
first = 0;
else
putc ('|', fp);
fputs (wordflags[i].fstr, fp);
}
}
}
static void
wcomment (fp, i)
FILE *fp;
int i;
{
fputs ("\t\t/* ", fp);
fprintf (fp, "%s", cdesc(i));
fputs (" */", fp);
}
static void
dump_lsyntax (fp)
FILE *fp;
{
int i;
fprintf (fp, "int sh_syntabsiz = %d;\n", SYNSIZE);
fprintf (fp, "int sh_syntaxtab[%d] = {\n", SYNSIZE);
for (i = 0; i < SYNSIZE; i++)
{
putc ('\t', fp);
dump_lflags (fp, i);
putc (',', fp);
wcomment (fp, i);
putc ('\n', fp);
}
fprintf (fp, "};\n");
}
int
main(argc, argv)
int argc;
char **argv;
{
int opt, i;
char *filename;
FILE *fp;
if ((progname = strrchr (argv[0], '/')) == 0)
progname = argv[0];
else
progname++;
filename = (char *)NULL;
debug = 0;
while ((opt = getopt (argc, argv, "do:")) != EOF)
{
switch (opt)
{
case 'd':
debug = 1;
break;
case 'o':
filename = optarg;
break;
default:
usage();
}
}
argc -= optind;
argv += optind;
if (filename)
{
fp = fopen (filename, "w");
if (fp == 0)
{
fprintf (stderr, _("%s: %s: cannot open: %s\n"), progname, filename, strerror(errno));
exit (1);
}
}
else
{
filename = "stdout";
fp = stdout;
}
for (i = 0; i < SYNSIZE; i++)
lsyntax[i] = CWORD;
load_lsyntax ();
fprintf (fp, "%s\n", preamble);
fprintf (fp, "%s\n", includes);
dump_lsyntax (fp);
if (fp != stdout)
fclose (fp);
exit (0);
}
#if !defined (HAVE_STRERROR)
#include <bashtypes.h>
#ifndef _MINIX
# include <sys/param.h>
#endif
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
/* Return a string corresponding to the error number E. From
the ANSI C spec. */
#if defined (strerror)
# undef strerror
#endif
char *
strerror (e)
int e;
{
static char emsg[40];
#if defined (HAVE_SYS_ERRLIST)
extern int sys_nerr;
extern char *sys_errlist[];
if (e > 0 && e < sys_nerr)
return (sys_errlist[e]);
else
#endif /* HAVE_SYS_ERRLIST */
{
sprintf (emsg, _("Unknown system error %d"), e);
return (&emsg[0]);
}
}
#endif /* HAVE_STRERROR */
+415
View File
@@ -0,0 +1,415 @@
/*
* mksyntax.c - construct shell syntax table for fast char attribute lookup.
*/
/* Copyright (C) 2000-2002 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. */
#include "config.h"
#include <stdio.h>
#include "bashansi.h"
#include "chartypes.h"
#include <errno.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "syntax.h"
extern int optind;
extern char *optarg;
#ifndef errno
extern int errno;
#endif
#ifndef HAVE_STRERROR
extern char *strerror();
#endif
struct wordflag {
int flag;
char *fstr;
} wordflags[] = {
{ CWORD, "CWORD" },
{ CSHMETA, "CSHMETA" },
{ CSHBRK, "CSHBRK" },
{ CBACKQ, "CBACKQ" },
{ CQUOTE, "CQUOTE" },
{ CSPECL, "CSPECL" },
{ CEXP, "CEXP" },
{ CBSDQUOTE, "CBSDQUOTE" },
{ CBSHDOC, "CBSHDOC" },
{ CGLOB, "CGLOB" },
{ CXGLOB, "CXGLOB" },
{ CXQUOTE, "CXQUOTE" },
{ CSPECVAR, "CSPECVAR" },
{ CSUBSTOP, "CSUBSTOP" },
{ CBLANK, "CBLANK" },
};
#define N_WFLAGS (sizeof (wordflags) / sizeof (wordflags[0]))
#define SYNSIZE 256
int lsyntax[SYNSIZE];
int debug;
char *progname;
char preamble[] = "\
/*\n\
* This file was generated by mksyntax. DO NOT EDIT.\n\
*/\n\
\n";
char includes[] = "\
#include \"config.h\"\n\
#include \"stdc.h\"\n\
#include \"syntax.h\"\n\n";
static void
usage()
{
fprintf (stderr, _("%s: usage: %s [-d] [-o filename]\n"), progname, progname);
exit (2);
}
#ifdef INCLUDE_UNUSED
static int
getcflag (s)
char *s;
{
int i;
for (i = 0; i < N_WFLAGS; i++)
if (strcmp (s, wordflags[i].fstr) == 0)
return wordflags[i].flag;
return -1;
}
#endif
static char *
cdesc (i)
int i;
{
static char xbuf[16];
if (i == ' ')
return "SPC";
else if (ISPRINT (i))
{
xbuf[0] = i;
xbuf[1] = '\0';
return (xbuf);
}
else if (i == CTLESC)
return "CTLESC";
else if (i == CTLNUL)
return "CTLNUL";
else if (i == '\033') /* ASCII */
return "ESC";
xbuf[0] = '\\';
xbuf[2] = '\0';
switch (i)
{
#ifdef __STDC__
case '\a': xbuf[1] = 'a'; break;
case '\v': xbuf[1] = 'v'; break;
#else
case '\007': xbuf[1] = 'a'; break;
case 0x0B: xbuf[1] = 'v'; break;
#endif
case '\b': xbuf[1] = 'b'; break;
case '\f': xbuf[1] = 'f'; break;
case '\n': xbuf[1] = 'n'; break;
case '\r': xbuf[1] = 'r'; break;
case '\t': xbuf[1] = 't'; break;
default: sprintf (xbuf, "%d", i); break;
}
return xbuf;
}
static char *
getcstr (f)
int f;
{
int i;
for (i = 0; i < N_WFLAGS; i++)
if (f == wordflags[i].flag)
return (wordflags[i].fstr);
return ((char *)NULL);
}
static void
addcstr (str, flag)
char *str;
int flag;
{
char *s, *fstr;
unsigned char uc;
for (s = str; s && *s; s++)
{
uc = *s;
if (debug)
{
fstr = getcstr (flag);
fprintf(stderr, _("added %s for character %s\n"), fstr, cdesc(uc));
}
lsyntax[uc] |= flag;
}
}
static void
addcchar (c, flag)
unsigned char c;
int flag;
{
char *fstr;
if (debug)
{
fstr = getcstr (flag);
fprintf (stderr, _("added %s for character %s\n"), fstr, cdesc(c));
}
lsyntax[c] |= flag;
}
static void
addblanks ()
{
register int i;
unsigned char uc;
for (i = 0; i < SYNSIZE; i++)
{
uc = i;
/* Since we don't call setlocale(), this defaults to the "C" locale, and
the default blank characters will be space and tab. */
if (isblank (uc))
lsyntax[uc] |= CBLANK;
}
}
/* load up the correct flag values in lsyntax */
static void
load_lsyntax ()
{
/* shell metacharacters */
addcstr (shell_meta_chars, CSHMETA);
/* shell word break characters */
addcstr (shell_break_chars, CSHBRK);
addcchar ('`', CBACKQ);
addcstr (shell_quote_chars, CQUOTE);
addcchar (CTLESC, CSPECL);
addcchar (CTLNUL, CSPECL);
addcstr (shell_exp_chars, CEXP);
addcstr (slashify_in_quotes, CBSDQUOTE);
addcstr (slashify_in_here_document, CBSHDOC);
addcstr (shell_glob_chars, CGLOB);
#if defined (EXTENDED_GLOB)
addcstr (ext_glob_chars, CXGLOB);
#endif
addcstr (shell_quote_chars, CXQUOTE);
addcchar ('\\', CXQUOTE);
addcstr ("@*#?-$!", CSPECVAR); /* omits $0...$9 and $_ */
addcstr ("-=?+", CSUBSTOP); /* OP in ${paramOPword} */
addblanks ();
}
static void
dump_lflags (fp, ind)
FILE *fp;
int ind;
{
int xflags, first, i;
xflags = lsyntax[ind];
first = 1;
if (xflags == 0)
fputs (wordflags[0].fstr, fp);
else
{
for (i = 1; i < N_WFLAGS; i++)
if (xflags & wordflags[i].flag)
{
if (first)
first = 0;
else
putc ('|', fp);
fputs (wordflags[i].fstr, fp);
}
}
}
static void
wcomment (fp, i)
FILE *fp;
int i;
{
fputs ("\t\t/* ", fp);
fprintf (fp, "%s", cdesc(i));
fputs (" */", fp);
}
static void
dump_lsyntax (fp)
FILE *fp;
{
int i;
fprintf (fp, "int sh_syntabsiz = %d;\n", SYNSIZE);
fprintf (fp, "int sh_syntaxtab[%d] = {\n", SYNSIZE);
for (i = 0; i < SYNSIZE; i++)
{
putc ('\t', fp);
dump_lflags (fp, i);
putc (',', fp);
wcomment (fp, i);
putc ('\n', fp);
}
fprintf (fp, "};\n");
}
int
main(argc, argv)
int argc;
char **argv;
{
int opt, i;
char *filename;
FILE *fp;
if ((progname = strrchr (argv[0], '/')) == 0)
progname = argv[0];
else
progname++;
filename = (char *)NULL;
debug = 0;
while ((opt = getopt (argc, argv, "do:")) != EOF)
{
switch (opt)
{
case 'd':
debug = 1;
break;
case 'o':
filename = optarg;
break;
default:
usage();
}
}
argc -= optind;
argv += optind;
if (filename)
{
fp = fopen (filename, "w");
if (fp == 0)
{
fprintf (stderr, _("%s: %s: cannot open: %s\n"), progname, filename, strerror(errno));
exit (1);
}
}
else
{
filename = "stdout";
fp = stdout;
}
for (i = 0; i < SYNSIZE; i++)
lsyntax[i] = CWORD;
load_lsyntax ();
fprintf (fp, "%s\n", preamble);
fprintf (fp, "%s\n", includes);
dump_lsyntax (fp);
if (fp != stdout)
fclose (fp);
exit (0);
}
#if !defined (HAVE_STRERROR)
#include <bashtypes.h>
#ifndef _MINIX
# include <sys/param.h>
#endif
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
/* Return a string corresponding to the error number E. From
the ANSI C spec. */
#if defined (strerror)
# undef strerror
#endif
char *
strerror (e)
int e;
{
static char emsg[40];
#if defined (HAVE_SYS_ERRLIST)
extern int sys_nerr;
extern char *sys_errlist[];
if (e > 0 && e < sys_nerr)
return (sys_errlist[e]);
else
#endif /* HAVE_SYS_ERRLIST */
{
sprintf (emsg, _("Unknown system error %d"), e);
return (&emsg[0]);
}
}
#endif /* HAVE_STRERROR */
+1 -1
View File
@@ -803,7 +803,7 @@ wait_for (pid)
{
fprintf (stderr, "%s", j_strsignal (WTERMSIG (status)));
if (WIFCORED (status))
fprintf (stderr, " (core dumped)");
fprintf (stderr, _(" (core dumped)"));
fprintf (stderr, "\n");
}
+2
View File
@@ -518,9 +518,11 @@ make_child (command, async_p)
sigprocmask (SIG_SETMASK, &top_level_mask, (sigset_t *)NULL);
#endif
#if 0
/* Ignore INT and QUIT in asynchronous children. */
if (async_p)
last_asynchronous_pid = getpid ();
#endif
default_tty_job_signals ();
}
+1 -1
View File
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
#define PATCHLEVEL 5
#define PATCHLEVEL 9
#endif /* _PATCHLEVEL_H_ */
+30
View File
@@ -0,0 +1,30 @@
/* patchlevel.h -- current bash patch level */
/* Copyright (C) 2001-2006 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. */
#if !defined (_PATCHLEVEL_H_)
#define _PATCHLEVEL_H_
/* It's important that there be no other strings in this file that match the
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
#define PATCHLEVEL 5
#endif /* _PATCHLEVEL_H_ */
+2 -2
View File
@@ -1,6 +1,6 @@
/* shell.c -- GNU's idea of the POSIX shell specification. */
/* 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.
@@ -1731,7 +1731,7 @@ show_shell_usage (fp, extra)
char *set_opts, *s, *t;
if (extra)
fprintf (fp, "GNU bash, version %s-(%s)\n", shell_version_string (), MACHTYPE);
fprintf (fp, _("GNU bash, version %s-(%s)\n"), shell_version_string (), MACHTYPE);
fprintf (fp, _("Usage:\t%s [GNU long option] [option] ...\n\t%s [GNU long option] [option] script-file ...\n"),
shell_name, shell_name);
fputs (_("GNU long options:\n"), fp);
+1 -1
View File
@@ -1416,7 +1416,7 @@ open_shell_script (script_name)
}
else if (sample_len > 0 && (check_binary_file (sample, sample_len)))
{
internal_error ("%s: cannot execute binary file", filename);
internal_error (_("%s: cannot execute binary file"), filename);
exit (EX_BINARY_FILE);
}
/* Now rewind the file back to the beginning. */
+43 -43
View File
@@ -44,26 +44,26 @@ initialize_siglist ()
for (i = 0; i < NSIG; i++)
sys_siglist[i] = (char *)0x0;
sys_siglist[0] = "Bogus signal";
sys_siglist[0] = _("Bogus signal");
#if defined (SIGHUP)
sys_siglist[SIGHUP] = "Hangup";
sys_siglist[SIGHUP] = _("Hangup");
#endif
#if defined (SIGINT)
sys_siglist[SIGINT] = "Interrupt";
sys_siglist[SIGINT] = _("Interrupt");
#endif
#if defined (SIGQUIT)
sys_siglist[SIGQUIT] = "Quit";
sys_siglist[SIGQUIT] = _("Quit");
#endif
#if defined (SIGILL)
sys_siglist[SIGILL] = "Illegal instruction";
sys_siglist[SIGILL] = _("Illegal instruction");
#endif
#if defined (SIGTRAP)
sys_siglist[SIGTRAP] = "BPT trace/trap";
sys_siglist[SIGTRAP] = _("BPT trace/trap");
#endif
#if defined (SIGIOT) && !defined (SIGABRT)
@@ -71,59 +71,59 @@ initialize_siglist ()
#endif
#if defined (SIGABRT)
sys_siglist[SIGABRT] = "ABORT instruction";
sys_siglist[SIGABRT] = _("ABORT instruction");
#endif
#if defined (SIGEMT)
sys_siglist[SIGEMT] = "EMT instruction";
sys_siglist[SIGEMT] = _("EMT instruction");
#endif
#if defined (SIGFPE)
sys_siglist[SIGFPE] = "Floating point exception";
sys_siglist[SIGFPE] = _("Floating point exception");
#endif
#if defined (SIGKILL)
sys_siglist[SIGKILL] = "Killed";
sys_siglist[SIGKILL] = _("Killed");
#endif
#if defined (SIGBUS)
sys_siglist[SIGBUS] = "Bus error";
sys_siglist[SIGBUS] = _("Bus error");
#endif
#if defined (SIGSEGV)
sys_siglist[SIGSEGV] = "Segmentation fault";
sys_siglist[SIGSEGV] = _("Segmentation fault");
#endif
#if defined (SIGSYS)
sys_siglist[SIGSYS] = "Bad system call";
sys_siglist[SIGSYS] = _("Bad system call");
#endif
#if defined (SIGPIPE)
sys_siglist[SIGPIPE] = "Broken pipe";
sys_siglist[SIGPIPE] = _("Broken pipe");
#endif
#if defined (SIGALRM)
sys_siglist[SIGALRM] = "Alarm clock";
sys_siglist[SIGALRM] = _("Alarm clock");
#endif
#if defined (SIGTERM)
sys_siglist[SIGTERM] = "Terminated";
sys_siglist[SIGTERM] = _("Terminated");
#endif
#if defined (SIGURG)
sys_siglist[SIGURG] = "Urgent IO condition";
sys_siglist[SIGURG] = _("Urgent IO condition");
#endif
#if defined (SIGSTOP)
sys_siglist[SIGSTOP] = "Stopped (signal)";
sys_siglist[SIGSTOP] = _("Stopped (signal)");
#endif
#if defined (SIGTSTP)
sys_siglist[SIGTSTP] = "Stopped";
sys_siglist[SIGTSTP] = _("Stopped");
#endif
#if defined (SIGCONT)
sys_siglist[SIGCONT] = "Continue";
sys_siglist[SIGCONT] = _("Continue");
#endif
#if !defined (SIGCHLD) && defined (SIGCLD)
@@ -131,87 +131,87 @@ initialize_siglist ()
#endif
#if defined (SIGCHLD)
sys_siglist[SIGCHLD] = "Child death or stop";
sys_siglist[SIGCHLD] = _("Child death or stop");
#endif
#if defined (SIGTTIN)
sys_siglist[SIGTTIN] = "Stopped (tty input)";
sys_siglist[SIGTTIN] = _("Stopped (tty input)");
#endif
#if defined (SIGTTOU)
sys_siglist[SIGTTOU] = "Stopped (tty output)";
sys_siglist[SIGTTOU] = _("Stopped (tty output)");
#endif
#if defined (SIGIO)
sys_siglist[SIGIO] = "I/O ready";
sys_siglist[SIGIO] = _("I/O ready");
#endif
#if defined (SIGXCPU)
sys_siglist[SIGXCPU] = "CPU limit";
sys_siglist[SIGXCPU] = _("CPU limit");
#endif
#if defined (SIGXFSZ)
sys_siglist[SIGXFSZ] = "File limit";
sys_siglist[SIGXFSZ] = _("File limit");
#endif
#if defined (SIGVTALRM)
sys_siglist[SIGVTALRM] = "Alarm (virtual)";
sys_siglist[SIGVTALRM] = _("Alarm (virtual)");
#endif
#if defined (SIGPROF)
sys_siglist[SIGPROF] = "Alarm (profile)";
sys_siglist[SIGPROF] = _("Alarm (profile)");
#endif
#if defined (SIGWINCH)
sys_siglist[SIGWINCH] = "Window changed";
sys_siglist[SIGWINCH] = _("Window changed");
#endif
#if defined (SIGLOST)
sys_siglist[SIGLOST] = "Record lock";
sys_siglist[SIGLOST] = _("Record lock");
#endif
#if defined (SIGUSR1)
sys_siglist[SIGUSR1] = "User signal 1";
sys_siglist[SIGUSR1] = _("User signal 1");
#endif
#if defined (SIGUSR2)
sys_siglist[SIGUSR2] = "User signal 2";
sys_siglist[SIGUSR2] = _("User signal 2");
#endif
#if defined (SIGMSG)
sys_siglist[SIGMSG] = "HFT input data pending";
sys_siglist[SIGMSG] = _("HFT input data pending");
#endif
#if defined (SIGPWR)
sys_siglist[SIGPWR] = "power failure imminent";
sys_siglist[SIGPWR] = _("power failure imminent");
#endif
#if defined (SIGDANGER)
sys_siglist[SIGDANGER] = "system crash imminent";
sys_siglist[SIGDANGER] = _("system crash imminent");
#endif
#if defined (SIGMIGRATE)
sys_siglist[SIGMIGRATE] = "migrate process to another CPU";
sys_siglist[SIGMIGRATE] = _("migrate process to another CPU");
#endif
#if defined (SIGPRE)
sys_siglist[SIGPRE] = "programming error";
sys_siglist[SIGPRE] = _("programming error");
#endif
#if defined (SIGGRANT)
sys_siglist[SIGGRANT] = "HFT monitor mode granted";
sys_siglist[SIGGRANT] = _("HFT monitor mode granted");
#endif
#if defined (SIGRETRACT)
sys_siglist[SIGRETRACT] = "HFT monitor mode retracted";
sys_siglist[SIGRETRACT] = _("HFT monitor mode retracted");
#endif
#if defined (SIGSOUND)
sys_siglist[SIGSOUND] = "HFT sound sequence has completed";
sys_siglist[SIGSOUND] = _("HFT sound sequence has completed");
#endif
#if defined (SIGINFO)
sys_siglist[SIGINFO] = "Information request";
sys_siglist[SIGINFO] = _("Information request");
#endif
for (i = 0; i < NSIG; i++)
@@ -219,9 +219,9 @@ initialize_siglist ()
if (!sys_siglist[i])
{
sys_siglist[i] =
(char *)xmalloc (10 + strlen ("Unknown Signal #"));
(char *)xmalloc (10 + strlen (_("Unknown Signal #")));
sprintf (sys_siglist[i], "Unknown Signal #%d", i);
sprintf (sys_siglist[i], _("Unknown Signal #%d"), i);
}
}
}

Some files were not shown because too many files have changed in this diff Show More