commit bash-20061221 snapshot

This commit is contained in:
Chet Ramey
2011-12-07 09:01:57 -05:00
parent 258e3d4698
commit f37c27ea61
101 changed files with 36488 additions and 1145 deletions
+126
View File
@@ -14048,3 +14048,129 @@ 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>
12/19
-----
builtins/common.c
- change display_signal_list (used by `trap -l' and `kill -l') to use
five columns instead of 4 to display signal names
builtins/help.def
- use the true terminal width instead of assuming 80 when displaying
help topics, leaving two characters of whitespace between horizontal
descriptions instead of 1
- change to print in columns with entries sorted down rather than across
(that is, like `ls' rather than `ls -x'). Change inspired by Benno
Schulenberg <bensberg@justemail.net>
jobs.h
- give values to the JOB_STATE enumerations so they can be used as
bitmasks, too
12/22
-----
doc/{bash.1,bashref.texi}
- change description of `set' to make it clearer that you can use
`+' to turn off options
- clarify in the description of word splitting that sequences of
IFS whitespace at the beginning or end of the string are ignored
12/26
-----
doc/bashref.texi
- move `shopt' builtin to its own section; change internal references
from `Bash Builtins' to the new shopt builtin
- new section for builtins that modify shell behavior in `Shell
Builtin Commands'; move set and shopt to new section. Changes
inspired by Benno Schulenberg <bensberg@justemail.net>
{redir,subst}.c
- add MT_USETMPDIR flag to calls to sh_mktmpfd and sh_mktmpname. Bug
reported by Eric Blake <ebb9@byu.net>
{configure,Makefile}.in
- changes so that the pathname for DEBUGGER_START_FILE is substituted
into pathnames.h at make time (allowing more flexibility in setting
`prefix' or `datadir') instead of at configure time. Suggested by
Nick Brown <nickbroon@blueyonder.co.uk>
shell.c
- declaration for have_devfd; initialized from HAVE_DEV_FD
- declaration for check_jobs_at_exit; initialized to 0
- declaration for autocd; initialized to 0
variables.c
- new dynamic variable, BASHPID, always set from return value from
getpid() (changes even when $$ doesn't change). Idea from Bruce
Korb <bruce.corb@3pardata.com>
builtins/exit.def
- if check_jobs_at_exit is non-zero, list jobs if there are any stopped
or running background jobs; don't exit shell if any running jobs
execute_cmd.c
- in execute_simple_command, if the first word of a simple command is
a directory name (after looking for builtins, so `.' isn't caught)
that isn't found in $PATH, and `autocd' is non-zero, prefix a "cd"
to the command words
builtins/shopt.def
- new `checkjobs' option, changes value of check_jobs_at_exit
- new `autocd' option, changes value of autocd
pcomplete.c
- add COMP_TYPE, set to rl_completion_type, to list of variables set
by bind_compfunc_variables and unset by unbind_compfunc_variables
doc/{bash.1,bashref.texi}
- document BASHPID
- document new shopt `checkjobs' option
- document new shopt `autocd' option
- document COMP_TYPE completion variable
12/29
-----
aclocal.m4
- in BASH_SYS_SIGLIST, check HAVE_DECL_SYS_SIGLIST instead of the
obsolete and no-longer-supported SYS_SIGLIST_DECLARED
12/30
-----
lib/readline/vi_mode.c
- add ` (backquote) to the list of vi motion characters
- in rl_vi_delete_to, rl_vi_change_to, and rl_vi_yank_to, don't delete
character under the cursor if the motion command moves the cursor
backward, so add F and T to the commands that don't cause the
mark to be adjusted
- add ` to the characters that don't cause the mark to be adjusted
when used as a motion command, since it's defined to behave that way
- when a motion character that may adjust the mark moves point
backward, don't adjust the mark so the character under the cursor
isn't deleted
lib/readline/complete.c
- add variable rl_sort_completion_matches; allows application to
inhibit match list sorting
- add variable rl_completion_invoking_key; allows applications to
discover the key that invoked rl_complete or rl_menu_complete
lib/readline/readline.h
- extern declarations for rl_completion_invoking_key and
rl_sort_completion_matches
lib/readline/doc/rltech.texi
- documented rl_completion_invoking_key and rl_sort_completion_matches
pcomplete.c
- export variable COMP_KEY to completion functions; initialized from
rl_completion_invoking_key; unset along with rest of completion
variables
doc/{bash.1,bashref.texi},lib/readline/doc/rluser.texi
- document COMP_KEY
[many files]
- changes to make variables and function parameters `const' for better
text sharing. Changes originally from Andreas Mohr
<andi@rhlx01.fht-esslingen.de>
+126 -1
View File
@@ -14045,6 +14045,131 @@ doc/{bash.1,bashref.texi}
builtins/{break,exit,fg_bg,hash,jobs,type,ulimit}.def
builtins/{common,evalfile}.c
{error,expr,jobs,mksyntax,nojobs,shell,subst,version}.c
{error,expr,jobs,mksyntax,nojobs,shell,subst,version,siglist}.c
- add gettextizing marks to untranslated strings
From Benno Schulenberg <bensberg@justemail.net>
12/19
-----
builtins/common.c
- change display_signal_list (used by `trap -l' and `kill -l') to use
five columns instead of 4 to display signal names
builtins/help.def
- use the true terminal width instead of assuming 80 when displaying
help topics, leaving two characters of whitespace between horizontal
descriptions instead of 1
- change to print in columns with entries sorted down rather than across
(that is, like `ls' rather than `ls -x'). Change inspired by Benno
Schulenberg <bensberg@justemail.net>
jobs.h
- give values to the JOB_STATE enumerations so they can be used as
bitmasks, too
12/22
-----
doc/{bash.1,bashref.texi}
- change description of `set' to make it clearer that you can use
`+' to turn off options
- clarify in the description of word splitting that sequences of
IFS whitespace at the beginning or end of the string are ignored
12/26
-----
doc/bashref.texi
- move `shopt' builtin to its own section; change internal references
from `Bash Builtins' to the new shopt builtin
- new section for builtins that modify shell behavior in `Shell
Builtin Commands'; move set and shopt to new section. Changes
inspired by Benno Schulenberg <bensberg@justemail.net>
{redir,subst}.c
- add MT_USETMPDIR flag to calls to sh_mktmpfd and sh_mktmpname. Bug
reported by Eric Blake <ebb9@byu.net>
{configure,Makefile}.in
- changes so that the pathname for DEBUGGER_START_FILE is substituted
into pathnames.h at make time (allowing more flexibility in setting
`prefix' or `datadir') instead of at configure time. Suggested by
Nick Brown <nickbroon@blueyonder.co.uk>
shell.c
- declaration for have_devfd; initialized from HAVE_DEV_FD
- declaration for check_jobs_at_exit; initialized to 0
- declaration for autocd; initialized to 0
variables.c
- new dynamic variable, BASHPID, always set from return value from
getpid() (changes even when $$ doesn't change). Idea from Bruce
Korb <bruce.corb@3pardata.com>
builtins/exit.def
- if check_jobs_at_exit is non-zero, list jobs if there are any stopped
or running background jobs; don't exit shell if any running jobs
execute_cmd.c
- in execute_simple_command, if the first word of a simple command is
a directory name (after looking for builtins, so `.' isn't caught)
that isn't found in $PATH, and `autocd' is non-zero, prefix a "cd"
to the command words
builtins/shopt.def
- new `checkjobs' option, changes value of check_jobs_at_exit
- new `autocd' option, changes value of autocd
pcomplete.c
- add COMP_TYPE, set to rl_completion_type, to list of variables set
by bind_compfunc_variables and unset by unbind_compfunc_variables
doc/{bash.1,bashref.texi}
- document BASHPID
- document new shopt `checkjobs' option
- document new shopt `autocd' option
- document COMP_TYPE completion variable
12/29
-----
aclocal.m4
- in BASH_SYS_SIGLIST, check HAVE_DECL_SYS_SIGLIST instead of the
obsolete and no-longer-supported SYS_SIGLIST_DECLARED
12/30
-----
lib/readline/vi_mode.c
- add ` (backquote) to the list of vi motion characters
- in rl_vi_delete_to, rl_vi_change_to, and rl_vi_yank_to, don't delete
character under the cursor if the motion command moves the cursor
backward, so add F and T to the commands that don't cause the
mark to be adjusted
- add ` to the characters that don't cause the mark to be adjusted
when used as a motion command, since it's defined to behave that way
- when a motion character that may adjust the mark moves point
backward, don't adjust the mark so the character under the cursor
isn't deleted
lib/readline/complete.c
- add variable rl_sort_completion_matches; allows application to
inhibit match list sorting
- add variable rl_completion_invoking_key; allows applications to
discover the key that invoked rl_complete or rl_menu_complete
lib/readline/readline.h
- extern declarations for rl_completion_invoking_key and
rl_sort_completion_matches
lib/readline/doc/rltech.texi
- documented rl_completion_invoking_key and rl_sort_completion_matches
pcomplete.c
- export variable COMP_KEY to completion functions; initialized from
rl_completion_invoking_key; unset along with rest of completion
variables
doc/{bash.1,bashref.texi},lib/readline/doc/rluser.texi
- document COMP_KEY
[many files]
- changes to make variables and function parameters `const' for better
text sharing
+11 -3
View File
@@ -78,6 +78,8 @@ INSTALLMODE2 = -m 0555
TESTSCRIPT = @TESTSCRIPT@
DEBUGGER_START_FILE = @DEBUGGER_START_FILE@
#If you have purify, and want to use it, uncomment this definition or
# run the make as `make PURIFY=purify'
# or run configure with the --with-purify argument.
@@ -670,9 +672,6 @@ ${DEFDIR}/builtext.h: $(BUILTIN_DEFS)
Makefile makefile: config.status $(srcdir)/Makefile.in
CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
pathnames.h: config.status $(srcdir)/Makefile.in
CONFIG_HEADERS= $(SHELL) ./config.status
Makefiles makefiles: config.status $(srcdir)/Makefile.in
@for mf in $(CREATED_MAKEFILES); do \
CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status ; \
@@ -686,6 +685,15 @@ stamp-h: config.status $(srcdir)/config.h.in $(srcdir)/config-top.h $(srcdir)/co
config.status: $(srcdir)/configure
$(SHELL) ./config.status --recheck
pathnames.h: Makefile $(srcdir)/pathnames.h.in
@sed -e 's|@DEBUGGER_START_FILE\@|${DEBUGGER_START_FILE}|g' $(srcdir)/pathnames.h.in > pathnames.tmp
@if test -f $@; then \
cmp -s pathnames.tmp $@ || mv pathnames.tmp $@; \
else \
mv pathnames.tmp $@; \
fi
@${RM} pathnames.tmp
# comment out for distribution
$(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
cd $(srcdir) && autoconf
+1461
View File
File diff suppressed because it is too large Load Diff
+1469
View File
File diff suppressed because it is too large Load Diff
Vendored
+1 -1
View File
@@ -215,7 +215,7 @@ AC_CACHE_VAL(bash_cv_sys_siglist,
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifndef SYS_SIGLIST_DECLARED
#if !HAVE_DECL_SYS_SIGLIST
extern char *sys_siglist[];
#endif
main()
Vendored
+6 -9
View File
@@ -1541,24 +1541,21 @@ AC_DEFUN(BASH_CHECK_DEV_FD,
[AC_MSG_CHECKING(whether /dev/fd is available)
AC_CACHE_VAL(bash_cv_dev_fd,
[bash_cv_dev_fd=""
if test -d /dev/fd && test -r /dev/fd/0 < /dev/null; then
if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then
# check for systems like FreeBSD 5 that only provide /dev/fd/[012]
exec 3</dev/null
if test -r /dev/fd/3; then
if (exec test -r /dev/fd/3 3</dev/null) ; then
bash_cv_dev_fd=standard
else
bash_cv_dev_fd=absent
fi
exec 3<&-
fi
if test -z "$bash_cv_dev_fd" ; then
if test -d /proc/self/fd && test -r /proc/self/fd/0 < /dev/null; then
if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
bash_cv_dev_fd=whacky
else
bash_cv_dev_fd=absent
fi
fi
set +x
])
AC_MSG_RESULT($bash_cv_dev_fd)
if test $bash_cv_dev_fd = "standard"; then
@@ -1573,9 +1570,9 @@ fi
AC_DEFUN(BASH_CHECK_DEV_STDIN,
[AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
AC_CACHE_VAL(bash_cv_dev_stdin,
[if test -d /dev/fd && test -r /dev/stdin < /dev/null; then
[if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present
elif test -d /proc/self/fd && test -r /dev/stdin < /dev/null; then
elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present
else
bash_cv_dev_stdin=absent
@@ -2367,7 +2364,7 @@ AC_DEFUN([AM_INTL_SUBDIR],
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
stdlib.h string.h unistd.h sys/param.h])
AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
geteuid getgid getuid mempcpy munmap putenv setenv setlocale localeconv stpcpy \
strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next \
__fsetlocking])
+1 -1
View File
@@ -45,7 +45,7 @@ static void quote_array_assignment_chars __P((WORD_LIST *));
static char *array_value_internal __P((char *, int, int, int *));
/* Standard error message to use when encountering an invalid array subscript */
char *bash_badsub_errmsg = N_("bad array subscript");
const char * const bash_badsub_errmsg = N_("bad array subscript");
/* **************************************************************** */
/* */
+837
View File
@@ -0,0 +1,837 @@
/* arrayfunc.c -- High-level array functions used by other parts of the shell. */
/* 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. */
#include "config.h"
#if defined (ARRAY_VARS)
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include <stdio.h>
#include "bashintl.h"
#include "shell.h"
#include "shmbutil.h"
#include "builtins/common.h"
extern char *this_command_name;
extern int last_command_exit_value;
extern int array_needs_making;
static SHELL_VAR *bind_array_var_internal __P((SHELL_VAR *, arrayind_t, char *, int));
static void quote_array_assignment_chars __P((WORD_LIST *));
static char *array_value_internal __P((char *, int, int, int *));
/* Standard error message to use when encountering an invalid array subscript */
char *bash_badsub_errmsg = N_("bad array subscript");
/* **************************************************************** */
/* */
/* Functions to manipulate array variables and perform assignments */
/* */
/* **************************************************************** */
/* Convert a shell variable to an array variable. The original value is
saved as array[0]. */
SHELL_VAR *
convert_var_to_array (var)
SHELL_VAR *var;
{
char *oldval;
ARRAY *array;
oldval = value_cell (var);
array = array_create ();
if (oldval)
array_insert (array, 0, oldval);
FREE (value_cell (var));
var_setarray (var, array);
/* these aren't valid anymore */
var->dynamic_value = (sh_var_value_func_t *)NULL;
var->assign_func = (sh_var_assign_func_t *)NULL;
INVALIDATE_EXPORTSTR (var);
if (exported_p (var))
array_needs_making++;
VSETATTR (var, att_array);
VUNSETATTR (var, att_invisible);
return var;
}
static SHELL_VAR *
bind_array_var_internal (entry, ind, value, flags)
SHELL_VAR *entry;
arrayind_t ind;
char *value;
int flags;
{
SHELL_VAR *dentry;
char *newval;
/* If we're appending, we need the old value of the array reference, so
fake out make_variable_value with a dummy SHELL_VAR */
if (flags & ASS_APPEND)
{
dentry = (SHELL_VAR *)xmalloc (sizeof (SHELL_VAR));
dentry->name = savestring (entry->name);
newval = array_reference (array_cell (entry), ind);
if (newval)
dentry->value = savestring (newval);
else
{
dentry->value = (char *)xmalloc (1);
dentry->value[0] = '\0';
}
dentry->exportstr = 0;
dentry->attributes = entry->attributes & ~(att_array|att_exported);
/* Leave the rest of the members uninitialized; the code doesn't look
at them. */
newval = make_variable_value (dentry, value, flags);
dispose_variable (dentry);
}
else
newval = make_variable_value (entry, value, flags);
if (entry->assign_func)
(*entry->assign_func) (entry, newval, ind);
else
array_insert (array_cell (entry), ind, newval);
FREE (newval);
return (entry);
}
/* Perform an array assignment name[ind]=value. If NAME already exists and
is not an array, and IND is 0, perform name=value instead. If NAME exists
and is not an array, and IND is not 0, convert it into an array with the
existing value as name[0].
If NAME does not exist, just create an array variable, no matter what
IND's value may be. */
SHELL_VAR *
bind_array_variable (name, ind, value, flags)
char *name;
arrayind_t ind;
char *value;
int flags;
{
SHELL_VAR *entry;
entry = var_lookup (name, shell_variables);
if (entry == (SHELL_VAR *) 0)
entry = make_new_array_variable (name);
else if (readonly_p (entry) || noassign_p (entry))
{
if (readonly_p (entry))
err_readonly (name);
return (entry);
}
else if (array_p (entry) == 0)
entry = convert_var_to_array (entry);
/* ENTRY is an array variable, and ARRAY points to the value. */
return (bind_array_var_internal (entry, ind, value, flags));
}
/* Parse NAME, a lhs of an assignment statement of the form v[s], and
assign VALUE to that array element by calling bind_array_variable(). */
SHELL_VAR *
assign_array_element (name, value, flags)
char *name, *value;
int flags;
{
char *sub, *vname;
arrayind_t ind;
int sublen;
SHELL_VAR *entry;
vname = array_variable_name (name, &sub, &sublen);
if (vname == 0)
return ((SHELL_VAR *)NULL);
if ((ALL_ELEMENT_SUB (sub[0]) && sub[1] == ']') || (sublen <= 1))
{
free (vname);
err_badarraysub (name);
return ((SHELL_VAR *)NULL);
}
ind = array_expand_index (sub, sublen);
if (ind < 0)
{
free (vname);
err_badarraysub (name);
return ((SHELL_VAR *)NULL);
}
entry = bind_array_variable (vname, ind, value, flags);
free (vname);
return (entry);
}
/* Find the array variable corresponding to NAME. If there is no variable,
create a new array variable. If the variable exists but is not an array,
convert it to an indexed array. If CHECK_FLAGS is non-zero, an existing
variable is checked for the readonly or noassign attribute in preparation
for assignment (e.g., by the `read' builtin). */
SHELL_VAR *
find_or_make_array_variable (name, check_flags)
char *name;
int check_flags;
{
SHELL_VAR *var;
var = find_variable (name);
if (var == 0)
var = make_new_array_variable (name);
else if (check_flags && (readonly_p (var) || noassign_p (var)))
{
if (readonly_p (var))
err_readonly (name);
return ((SHELL_VAR *)NULL);
}
else if (array_p (var) == 0)
var = convert_var_to_array (var);
return (var);
}
/* Perform a compound assignment statement for array NAME, where VALUE is
the text between the parens: NAME=( VALUE ) */
SHELL_VAR *
assign_array_from_string (name, value, flags)
char *name, *value;
int flags;
{
SHELL_VAR *var;
var = find_or_make_array_variable (name, 1);
if (var == 0)
return ((SHELL_VAR *)NULL);
return (assign_array_var_from_string (var, value, flags));
}
/* Sequentially assign the indices of indexed array variable VAR from the
words in LIST. */
SHELL_VAR *
assign_array_var_from_word_list (var, list, flags)
SHELL_VAR *var;
WORD_LIST *list;
int flags;
{
register arrayind_t i;
register WORD_LIST *l;
ARRAY *a;
a = array_cell (var);
i = (flags & ASS_APPEND) ? array_max_index (a) + 1 : 0;
for (l = list; l; l = l->next, i++)
if (var->assign_func)
(*var->assign_func) (var, l->word->word, i);
else
array_insert (a, i, l->word->word);
return var;
}
WORD_LIST *
expand_compound_array_assignment (value, flags)
char *value;
int flags;
{
WORD_LIST *list, *nlist;
char *val;
int ni;
/* I don't believe this condition is ever true any more. */
if (*value == '(') /*)*/
{
ni = 1;
val = extract_array_assignment_list (value, &ni);
if (val == 0)
return (WORD_LIST *)NULL;
}
else
val = value;
/* Expand the value string into a list of words, performing all the
shell expansions including pathname generation and word splitting. */
/* First we split the string on whitespace, using the shell parser
(ksh93 seems to do this). */
list = parse_string_to_word_list (val, 1, "array assign");
/* If we're using [subscript]=value, we need to quote each [ and ] to
prevent unwanted filename expansion. */
if (list)
quote_array_assignment_chars (list);
/* Now that we've split it, perform the shell expansions on each
word in the list. */
nlist = list ? expand_words_no_vars (list) : (WORD_LIST *)NULL;
dispose_words (list);
if (val != value)
free (val);
return nlist;
}
void
assign_compound_array_list (var, nlist, flags)
SHELL_VAR *var;
WORD_LIST *nlist;
int flags;
{
ARRAY *a;
WORD_LIST *list;
char *w, *val, *nval;
int len, iflags;
arrayind_t ind, last_ind;
a = array_cell (var);
/* Now that we are ready to assign values to the array, kill the existing
value. */
if (a && (flags & ASS_APPEND) == 0)
array_flush (a);
last_ind = (flags & ASS_APPEND) ? array_max_index (a) + 1 : 0;
for (list = nlist; list; list = list->next)
{
iflags = flags;
w = list->word->word;
/* We have a word of the form [ind]=value */
if ((list->word->flags & W_ASSIGNMENT) && w[0] == '[')
{
len = skipsubscript (w, 0);
/* XXX - changes for `+=' */
if (w[len] != ']' || (w[len+1] != '=' && (w[len+1] != '+' || w[len+2] != '=')))
{
nval = make_variable_value (var, w, flags);
if (var->assign_func)
(*var->assign_func) (var, nval, last_ind);
else
array_insert (a, last_ind, nval);
FREE (nval);
last_ind++;
continue;
}
if (len == 1)
{
err_badarraysub (w);
continue;
}
if (ALL_ELEMENT_SUB (w[1]) && len == 2)
{
report_error (_("%s: cannot assign to non-numeric index"), w);
continue;
}
ind = array_expand_index (w + 1, len);
if (ind < 0)
{
err_badarraysub (w);
continue;
}
last_ind = ind;
/* XXX - changes for `+=' -- just accept the syntax. ksh93 doesn't do this */
if (w[len + 1] == '+' && w[len + 2] == '=')
{
iflags |= ASS_APPEND;
val = w + len + 3;
}
else
val = w + len + 2;
}
else /* No [ind]=value, just a stray `=' */
{
ind = last_ind;
val = w;
}
if (integer_p (var))
this_command_name = (char *)NULL; /* no command name for errors */
bind_array_var_internal (var, ind, val, iflags);
last_ind++;
}
}
/* Perform a compound array assignment: VAR->name=( VALUE ). The
VALUE has already had the parentheses stripped. */
SHELL_VAR *
assign_array_var_from_string (var, value, flags)
SHELL_VAR *var;
char *value;
int flags;
{
WORD_LIST *nlist;
if (value == 0)
return var;
nlist = expand_compound_array_assignment (value, flags);
assign_compound_array_list (var, nlist, flags);
if (nlist)
dispose_words (nlist);
return (var);
}
/* For each word in a compound array assignment, if the word looks like
[ind]=value, quote the `[' and `]' before the `=' to protect them from
unwanted filename expansion. */
static void
quote_array_assignment_chars (list)
WORD_LIST *list;
{
char *s, *t, *nword;
int saw_eq;
WORD_LIST *l;
for (l = list; l; l = l->next)
{
if (l->word == 0 || l->word->word == 0 || l->word->word[0] == '\0')
continue; /* should not happen, but just in case... */
/* Don't bother if it doesn't look like [ind]=value */
if (l->word->word[0] != '[' || xstrchr (l->word->word, '=') == 0) /* ] */
continue;
s = nword = (char *)xmalloc (strlen (l->word->word) * 2 + 1);
saw_eq = 0;
for (t = l->word->word; *t; )
{
if (*t == '=')
saw_eq = 1;
if (saw_eq == 0 && (*t == '[' || *t == ']'))
*s++ = '\\';
*s++ = *t++;
}
*s = '\0';
free (l->word->word);
l->word->word = nword;
}
}
/* This function assumes s[i] == '['; returns with s[ret] == ']' if
an array subscript is correctly parsed. */
int
skipsubscript (s, i)
const char *s;
int i;
{
int count, c;
#if defined (HANDLE_MULTIBYTE)
mbstate_t state, state_bak;
size_t slength, mblength;
#endif
#if defined (HANDLE_MULTIBYTE)
memset (&state, '\0', sizeof (mbstate_t));
slength = strlen (s + i);
#endif
count = 1;
while (count)
{
/* Advance one (possibly multibyte) character in S starting at I. */
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1)
{
state_bak = state;
mblength = mbrlen (s + i, slength, &state);
if (MB_INVALIDCH (mblength))
{
state = state_bak;
i++;
slength--;
}
else if (MB_NULLWCH (mblength))
return i;
else
{
i += mblength;
slength -= mblength;
}
}
else
#endif
++i;
c = s[i];
if (c == 0)
break;
else if (c == '[')
count++;
else if (c == ']')
count--;
}
return i;
}
/* This function is called with SUB pointing to just after the beginning
`[' of an array subscript and removes the array element to which SUB
expands from array VAR. A subscript of `*' or `@' unsets the array. */
int
unbind_array_element (var, sub)
SHELL_VAR *var;
char *sub;
{
int len;
arrayind_t ind;
ARRAY_ELEMENT *ae;
len = skipsubscript (sub, 0);
if (sub[len] != ']' || len == 0)
{
builtin_error ("%s[%s: %s", var->name, sub, _(bash_badsub_errmsg));
return -1;
}
sub[len] = '\0';
if (ALL_ELEMENT_SUB (sub[0]) && sub[1] == 0)
{
unbind_variable (var->name);
return (0);
}
ind = array_expand_index (sub, len+1);
if (ind < 0)
{
builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg));
return -1;
}
ae = array_remove (array_cell (var), ind);
if (ae)
array_dispose_element (ae);
return 0;
}
/* Format and output an array assignment in compound form VAR=(VALUES),
suitable for re-use as input. */
void
print_array_assignment (var, quoted)
SHELL_VAR *var;
int quoted;
{
char *vstr;
vstr = array_to_assign (array_cell (var), quoted);
if (vstr == 0)
printf ("%s=%s\n", var->name, quoted ? "'()'" : "()");
else
{
printf ("%s=%s\n", var->name, vstr);
free (vstr);
}
}
/***********************************************************************/
/* */
/* Utility functions to manage arrays and their contents for expansion */
/* */
/***********************************************************************/
/* Return 1 if NAME is a properly-formed array reference v[sub]. */
int
valid_array_reference (name)
char *name;
{
char *t;
int r, len;
t = xstrchr (name, '['); /* ] */
if (t)
{
*t = '\0';
r = legal_identifier (name);
*t = '[';
if (r == 0)
return 0;
/* Check for a properly-terminated non-blank subscript. */
len = skipsubscript (t, 0);
if (t[len] != ']' || len == 1)
return 0;
for (r = 1; r < len; r++)
if (whitespace (t[r]) == 0)
return 1;
return 0;
}
return 0;
}
/* Expand the array index beginning at S and extending LEN characters. */
arrayind_t
array_expand_index (s, len)
char *s;
int len;
{
char *exp, *t;
int expok;
arrayind_t val;
exp = (char *)xmalloc (len);
strncpy (exp, s, len - 1);
exp[len - 1] = '\0';
t = expand_arith_string (exp, 0);
this_command_name = (char *)NULL;
val = evalexp (t, &expok);
free (t);
free (exp);
if (expok == 0)
{
last_command_exit_value = EXECUTION_FAILURE;
jump_to_top_level (DISCARD);
}
return val;
}
/* Return the name of the variable specified by S without any subscript.
If SUBP is non-null, return a pointer to the start of the subscript
in *SUBP. If LENP is non-null, the length of the subscript is returned
in *LENP. This returns newly-allocated memory. */
char *
array_variable_name (s, subp, lenp)
char *s, **subp;
int *lenp;
{
char *t, *ret;
int ind, ni;
t = xstrchr (s, '[');
if (t == 0)
{
if (subp)
*subp = t;
if (lenp)
*lenp = 0;
return ((char *)NULL);
}
ind = t - s;
ni = skipsubscript (s, ind);
if (ni <= ind + 1 || s[ni] != ']')
{
err_badarraysub (s);
if (subp)
*subp = t;
if (lenp)
*lenp = 0;
return ((char *)NULL);
}
*t = '\0';
ret = savestring (s);
*t++ = '['; /* ] */
if (subp)
*subp = t;
if (lenp)
*lenp = ni - ind;
return ret;
}
/* Return the variable specified by S without any subscript. If SUBP is
non-null, return a pointer to the start of the subscript in *SUBP.
If LENP is non-null, the length of the subscript is returned in *LENP. */
SHELL_VAR *
array_variable_part (s, subp, lenp)
char *s, **subp;
int *lenp;
{
char *t;
SHELL_VAR *var;
t = array_variable_name (s, subp, lenp);
if (t == 0)
return ((SHELL_VAR *)NULL);
var = find_variable (t);
free (t);
return (var == 0 || invisible_p (var)) ? (SHELL_VAR *)0 : var;
}
/* Return a string containing the elements in the array and subscript
described by S. If the subscript is * or @, obeys quoting rules akin
to the expansion of $* and $@ including double quoting. If RTYPE
is non-null it gets 1 if the array reference is name[@] or name[*]
and 0 otherwise. */
static char *
array_value_internal (s, quoted, allow_all, rtype)
char *s;
int quoted, allow_all, *rtype;
{
int len;
arrayind_t ind;
char *retval, *t, *temp;
WORD_LIST *l;
SHELL_VAR *var;
var = array_variable_part (s, &t, &len);
/* Expand the index, even if the variable doesn't exist, in case side
effects are needed, like ${w[i++]} where w is unset. */
#if 0
if (var == 0)
return (char *)NULL;
#endif
if (len == 0)
return ((char *)NULL); /* error message already printed */
/* [ */
if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']')
{
if (rtype)
*rtype = 1;
if (allow_all == 0)
{
err_badarraysub (s);
return ((char *)NULL);
}
else if (var == 0 || value_cell (var) == 0)
return ((char *)NULL);
else if (array_p (var) == 0)
l = add_string_to_list (value_cell (var), (WORD_LIST *)NULL);
else
{
l = array_to_word_list (array_cell (var));
if (l == (WORD_LIST *)NULL)
return ((char *) NULL);
}
if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
{
temp = string_list_dollar_star (l);
retval = quote_string (temp);
free (temp);
}
else /* ${name[@]} or unquoted ${name[*]} */
retval = string_list_dollar_at (l, quoted);
dispose_words (l);
}
else
{
if (rtype)
*rtype = 0;
ind = array_expand_index (t, len);
if (ind < 0)
{
if (var)
err_badarraysub (var->name);
else
{
t[-1] = '\0';
err_badarraysub (s);
t[-1] = '['; /* ] */
}
return ((char *)NULL);
}
if (var == 0)
return ((char *)NULL);
if (array_p (var) == 0)
return (ind == 0 ? value_cell (var) : (char *)NULL);
retval = array_reference (array_cell (var), ind);
}
return retval;
}
/* Return a string containing the elements described by the array and
subscript contained in S, obeying quoting for subscripts * and @. */
char *
array_value (s, quoted, rtype)
char *s;
int quoted, *rtype;
{
return (array_value_internal (s, quoted, 1, rtype));
}
/* Return the value of the array indexing expression S as a single string.
If ALLOW_ALL is 0, do not allow `@' and `*' subscripts. This is used
by other parts of the shell such as the arithmetic expression evaluator
in expr.c. */
char *
get_array_value (s, allow_all, rtype)
char *s;
int allow_all, *rtype;
{
return (array_value_internal (s, 0, allow_all, rtype));
}
char *
array_keys (s, quoted)
char *s;
int quoted;
{
int len;
char *retval, *t, *temp;
WORD_LIST *l;
SHELL_VAR *var;
var = array_variable_part (s, &t, &len);
/* [ */
if (var == 0 || ALL_ELEMENT_SUB (t[0]) == 0 || t[1] != ']')
return (char *)NULL;
if (array_p (var) == 0)
l = add_string_to_list ("0", (WORD_LIST *)NULL);
else
{
l = array_keys_to_word_list (array_cell (var));
if (l == (WORD_LIST *)NULL)
return ((char *) NULL);
}
if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
{
temp = string_list_dollar_star (l);
retval = quote_string (temp);
free (temp);
}
else /* ${!name[@]} or unquoted ${!name[*]} */
retval = string_list_dollar_at (l, quoted);
dispose_words (l);
return retval;
}
#endif /* ARRAY_VARS */
+9 -13
View File
@@ -1,5 +1,5 @@
@%:@! /bin/sh
@%:@ From configure.in for Bash 3.2, version 3.190.
@%:@ From configure.in for Bash 3.2, version 3.193.
@%:@ Guess values for system-dependent variables and create Makefiles.
@%:@ Generated by GNU Autoconf 2.59 for bash 3.2-maint.
@%:@
@@ -1693,7 +1693,7 @@ if test "$opt_curses" = yes; then
fi
if test -z "${DEBUGGER_START_FILE}"; then
DEBUGGER_START_FILE=${ac_default_prefix}/share/bashdb/bashdb-main.inc
DEBUGGER_START_FILE='${datadir}/bashdb/bashdb-main.inc'
fi
opt_minimal_config=no
@@ -23402,7 +23402,7 @@ cat >>conftest.$ac_ext <<_ACEOF
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifndef SYS_SIGLIST_DECLARED
#if !HAVE_DECL_SYS_SIGLIST
extern char *sys_siglist[];
#endif
main()
@@ -27177,24 +27177,21 @@ if test "${bash_cv_dev_fd+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
bash_cv_dev_fd=""
if test -d /dev/fd && test -r /dev/fd/0 < /dev/null; then
if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then
# check for systems like FreeBSD 5 that only provide /dev/fd/[012]
exec 3</dev/null
if test -r /dev/fd/3; then
if (exec test -r /dev/fd/3 3</dev/null) ; then
bash_cv_dev_fd=standard
else
bash_cv_dev_fd=absent
fi
exec 3<&-
fi
if test -z "$bash_cv_dev_fd" ; then
if test -d /proc/self/fd && test -r /proc/self/fd/0 < /dev/null; then
if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
bash_cv_dev_fd=whacky
else
bash_cv_dev_fd=absent
fi
fi
set +x
fi
@@ -27225,9 +27222,9 @@ echo $ECHO_N "checking whether /dev/stdin stdout stderr are available... $ECHO_C
if test "${bash_cv_dev_stdin+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -d /dev/fd && test -r /dev/stdin < /dev/null; then
if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present
elif test -d /proc/self/fd && test -r /dev/stdin < /dev/null; then
elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present
else
bash_cv_dev_stdin=absent
@@ -27429,7 +27426,7 @@ esac
#AC_SUBST(ALLOCA_SOURCE)
#AC_SUBST(ALLOCA_OBJECT)
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/perl/Makefile pathnames.h"
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/perl/Makefile"
ac_config_commands="$ac_config_commands default"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -27986,7 +27983,6 @@ do
"po/Makefile.in" ) CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;;
"examples/loadables/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile" ;;
"examples/loadables/perl/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/loadables/perl/Makefile" ;;
"pathnames.h" ) CONFIG_FILES="$CONFIG_FILES pathnames.h" ;;
"default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
"default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+119 -10
View File
@@ -17,17 +17,126 @@
{
'm4_pattern_forbid' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_C_VOLATILE' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_C_VOLATILE' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_STAT' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_HEADER_TIME' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_FUNC_STRNLEN' => 1,
'm4_sinclude' => 1,
'AC_PROG_CXX' => 1,
'AC_PATH_X' => 1,
'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
'AC_PROG_AWK' => 1,
'_m4_warn' => 1,
'AC_HEADER_STDC' => 1,
'AC_HEADER_MAJOR' => 1,
'AC_FUNC_ERROR_AT_LINE' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
'AC_LIBSOURCE' => 1,
'AC_FUNC_MBRTOWC' => 1,
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_TYPE_UID_T' => 1,
'AC_PROG_MAKE_SET' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'm4_pattern_allow' => 1,
'sinclude' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_PROG_CC' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_PROG_YACC' => 1,
'AC_INIT' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'AC_FUNC_CHOWN' => 1,
'AC_SUBST' => 1,
'AC_FUNC_ALLOCA' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_PROG_RANLIB' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_FUNC_SETPGRP' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AC_FUNC_MMAP' => 1,
'AC_FUNC_REALLOC' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_CHECK_TYPES' => 1,
'AC_CONFIG_LINKS' => 1,
'AC_CHECK_MEMBERS' => 1,
'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_HEADER_STAT' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_C_INLINE' => 1,
'AC_PROG_CPP' => 1,
'AC_C_CONST' => 1,
'AC_PROG_LEX' => 1,
'AC_TYPE_PID_T' => 1,
'AC_CONFIG_FILES' => 1,
'include' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_PROG_INSTALL' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AH_OUTPUT' => 1,
'AC_FUNC_FSEEKO' => 1,
'AM_PROG_CC_C_O' => 1,
'AM_CONDITIONAL' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_PROG_LN_S' => 1,
'AC_FUNC_MEMCMP' => 1,
'm4_include' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_CHECK_FUNCS' => 1
}
], 'Autom4te::Request' ),
bless( [
'1',
1,
[
'/usr/share/autoconf'
],
[
'/usr/share/autoconf/autoconf/autoconf.m4f',
'aclocal.m4',
'configure.in'
],
{
'm4_pattern_forbid' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_C_VOLATILE' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_STAT' => 1,
'AC_HEADER_TIME' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_STRUCT_TM' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_FUNC_STRTOD' => 1,
@@ -65,8 +174,8 @@
'AC_FUNC_CHOWN' => 1,
'AC_SUBST' => 1,
'AC_FUNC_ALLOCA' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_PROG_RANLIB' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_FUNC_SETPGRP' => 1,
@@ -74,35 +183,35 @@
'AC_FUNC_MMAP' => 1,
'AC_FUNC_REALLOC' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_CHECK_TYPES' => 1,
'AC_CONFIG_LINKS' => 1,
'AC_CHECK_TYPES' => 1,
'AC_CHECK_MEMBERS' => 1,
'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_HEADER_STAT' => 1,
'AC_PROG_CPP' => 1,
'AC_C_INLINE' => 1,
'AC_PROG_CPP' => 1,
'AC_TYPE_PID_T' => 1,
'AC_PROG_LEX' => 1,
'AC_C_CONST' => 1,
'AC_PROG_LEX' => 1,
'AC_CONFIG_FILES' => 1,
'include' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_PROG_INSTALL' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AH_OUTPUT' => 1,
'AC_FUNC_FSEEKO' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AM_CONDITIONAL' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_FUNC_MEMCMP' => 1,
+61 -62
View File
@@ -64,7 +64,7 @@ m4trace:configure.in:52: -1- AC_SUBST([host_vendor], [`echo $ac_cv_host | sed 's
m4trace:configure.in:52: -1- AC_SUBST([host_os], [`echo $ac_cv_host | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\3/'`])
m4trace:configure.in:102: -2- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete.
You should run autoupdate.], [autoconf/general.m4:219: AC_HELP_STRING is expanded from...
aclocal.m4:1972: AM_PATH_LISPDIR is expanded from...
aclocal.m4:1969: AM_PATH_LISPDIR is expanded from...
configure.in:102: the top level])
m4trace:configure.in:102: -1- AC_SUBST([EMACS])
m4trace:configure.in:102: -1- AC_SUBST([lispdir])
@@ -316,7 +316,7 @@ m4trace:configure.in:483: -1- AC_CHECK_LIB([ncurses], [tgetent], [bash_cv_termca
m4trace:configure.in:483: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
aclocal.m4:1865: RL_LIB_READLINE_VERSION is expanded from...
aclocal.m4:1862: RL_LIB_READLINE_VERSION is expanded from...
configure.in:483: the top level])
m4trace:configure.in:483: -1- AC_DEFINE_TRACE_LITERAL([RL_READLINE_VERSION])
m4trace:configure.in:483: -1- AH_OUTPUT([RL_READLINE_VERSION], [/* encoded version of the installed readline library */
@@ -398,16 +398,16 @@ m4trace:configure.in:627: -1- AC_SUBST([XGETTEXT])
m4trace:configure.in:627: -1- AC_SUBST([MSGMERGE])
m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_OUTPUT_COMMANDS' is obsolete.
You should run autoupdate.], [autoconf/status.m4:318: AC_OUTPUT_COMMANDS is expanded from...
aclocal.m4:3828: AM_PO_SUBDIRS is expanded from...
aclocal.m4:3825: AM_PO_SUBDIRS is expanded from...
configure.in:627: AM_PO_SUBDIRS is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -3- _m4_warn([obsolete], [The macro `_AC_OUTPUT_COMMANDS_CNT' is obsolete.
You should run autoupdate.], [autoconf/status.m4:321: _AC_OUTPUT_COMMANDS_CNT is expanded from...
autoconf/status.m4:318: AC_OUTPUT_COMMANDS is expanded from...
aclocal.m4:3828: AM_PO_SUBDIRS is expanded from...
aclocal.m4:3825: AM_PO_SUBDIRS is expanded from...
configure.in:627: AM_PO_SUBDIRS is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_TYPE_OFF_T
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([off_t])
@@ -460,11 +460,11 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is ob
You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2621: gt_INTDIV0 is expanded from...
aclocal.m4:2618: gt_INTDIV0 is expanded from...
configure.in:627: gt_INTDIV0 is required by...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([INTDIV0_RAISES_SIGFPE])
m4trace:configure.in:627: -1- AH_OUTPUT([INTDIV0_RAISES_SIGFPE], [/* Define if integer division by zero raises signal SIGFPE. */
@@ -473,13 +473,13 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2676: jm_AC_HEADER_INTTYPES_H is expanded from...
aclocal.m4:2673: jm_AC_HEADER_INTTYPES_H is expanded from...
configure.in:627: jm_AC_HEADER_INTTYPES_H is required by...
aclocal.m4:3979: jm_AC_TYPE_UINTMAX_T is expanded from...
aclocal.m4:3976: jm_AC_TYPE_UINTMAX_T is expanded from...
configure.in:627: jm_AC_TYPE_UINTMAX_T is required by...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTTYPES_H_WITH_UINTMAX])
m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_INTTYPES_H_WITH_UINTMAX], [/* Define if <inttypes.h> exists, doesn\'t clash with <sys/types.h>, and
@@ -489,13 +489,13 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:3947: jm_AC_HEADER_STDINT_H is expanded from...
aclocal.m4:3944: jm_AC_HEADER_STDINT_H is expanded from...
configure.in:627: jm_AC_HEADER_STDINT_H is required by...
aclocal.m4:3979: jm_AC_TYPE_UINTMAX_T is expanded from...
aclocal.m4:3976: jm_AC_TYPE_UINTMAX_T is expanded from...
configure.in:627: jm_AC_TYPE_UINTMAX_T is required by...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_STDINT_H_WITH_UINTMAX])
m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_STDINT_H_WITH_UINTMAX], [/* Define if <stdint.h> exists, doesn\'t clash with <sys/types.h>, and declares
@@ -505,13 +505,13 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:4002: jm_AC_TYPE_UNSIGNED_LONG_LONG is expanded from...
aclocal.m4:3999: jm_AC_TYPE_UNSIGNED_LONG_LONG is expanded from...
configure.in:627: jm_AC_TYPE_UNSIGNED_LONG_LONG is required by...
aclocal.m4:3979: jm_AC_TYPE_UINTMAX_T is expanded from...
aclocal.m4:3976: jm_AC_TYPE_UINTMAX_T is expanded from...
configure.in:627: jm_AC_TYPE_UINTMAX_T is required by...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_UNSIGNED_LONG_LONG])
m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_UNSIGNED_LONG_LONG], [/* Define if you have the unsigned long long type. */
@@ -527,11 +527,11 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2648: gt_HEADER_INTTYPES_H is expanded from...
aclocal.m4:2645: gt_HEADER_INTTYPES_H is expanded from...
configure.in:627: gt_HEADER_INTTYPES_H is required by...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTTYPES_H])
m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_INTTYPES_H], [/* Define if <inttypes.h> exists and doesn\'t clash with <sys/types.h>. */
@@ -540,11 +540,11 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2708: gt_INTTYPES_PRI is expanded from...
aclocal.m4:2705: gt_INTTYPES_PRI is expanded from...
configure.in:627: gt_INTTYPES_PRI is required by...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([PRI_MACROS_BROKEN])
m4trace:configure.in:627: -1- AH_OUTPUT([PRI_MACROS_BROKEN], [/* Define if <inttypes.h> exists and defines unusable PRI* macros. */
@@ -625,21 +625,21 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2521: AM_ICONV_LINK is expanded from...
aclocal.m4:2549: AM_ICONV is expanded from...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2518: AM_ICONV_LINK is expanded from...
aclocal.m4:2546: AM_ICONV is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2521: AM_ICONV_LINK is expanded from...
aclocal.m4:2549: AM_ICONV is expanded from...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2518: AM_ICONV_LINK is expanded from...
aclocal.m4:2546: AM_ICONV is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_ICONV])
m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_ICONV], [/* Define if you have the iconv() function. */
@@ -649,10 +649,10 @@ m4trace:configure.in:627: -1- AC_SUBST([LTLIBICONV])
m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
aclocal.m4:2549: AM_ICONV is expanded from...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2546: AM_ICONV is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([ICONV_CONST])
m4trace:configure.in:627: -1- AH_OUTPUT([ICONV_CONST], [/* Define as const if the declaration of iconv() needs const. */
@@ -661,10 +661,10 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:1999: AM_LANGINFO_CODESET is expanded from...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:1996: AM_LANGINFO_CODESET is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LANGINFO_CODESET])
m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_LANGINFO_CODESET], [/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
@@ -673,10 +673,10 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2766: AM_LC_MESSAGES is expanded from...
aclocal.m4:2410: AM_INTL_SUBDIR is expanded from...
aclocal.m4:2763: AM_LC_MESSAGES is expanded from...
aclocal.m4:2407: AM_INTL_SUBDIR is expanded from...
configure.in:627: AM_INTL_SUBDIR is required by...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LC_MESSAGES])
m4trace:configure.in:627: -1- AH_OUTPUT([HAVE_LC_MESSAGES], [/* Define if your <locale.h> file defines LC_MESSAGES. */
@@ -687,19 +687,19 @@ m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:2340: AM_GNU_GETTEXT is expanded from...
aclocal.m4:2337: AM_GNU_GETTEXT is expanded from...
configure.in:627: the top level])
m4trace:configure.in:627: -1- AC_DEFINE_TRACE_LITERAL([ENABLE_NLS])
m4trace:configure.in:627: -1- AH_OUTPUT([ENABLE_NLS], [/* Define to 1 if translation of program messages to the user\'s native
@@ -1244,14 +1244,14 @@ m4trace:configure.in:777: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o
You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:1746: BASH_CHECK_MULTIBYTE is expanded from...
aclocal.m4:1743: BASH_CHECK_MULTIBYTE is expanded from...
configure.in:777: the top level])
m4trace:configure.in:777: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LANGINFO_CODESET])
m4trace:configure.in:777: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:1746: BASH_CHECK_MULTIBYTE is expanded from...
aclocal.m4:1743: BASH_CHECK_MULTIBYTE is expanded from...
configure.in:777: the top level])
m4trace:configure.in:777: -1- AC_DEFINE_TRACE_LITERAL([HAVE_WCHAR_T])
m4trace:configure.in:777: -1- AH_OUTPUT([HAVE_WCHAR_T], [/* systems should define this type here */
@@ -1260,7 +1260,7 @@ m4trace:configure.in:777: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:1746: BASH_CHECK_MULTIBYTE is expanded from...
aclocal.m4:1743: BASH_CHECK_MULTIBYTE is expanded from...
configure.in:777: the top level])
m4trace:configure.in:777: -1- AC_DEFINE_TRACE_LITERAL([HAVE_WCTYPE_T])
m4trace:configure.in:777: -1- AH_OUTPUT([HAVE_WCTYPE_T], [/* systems should define this type here */
@@ -1269,7 +1269,7 @@ m4trace:configure.in:777: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from...
aclocal.m4:1746: BASH_CHECK_MULTIBYTE is expanded from...
aclocal.m4:1743: BASH_CHECK_MULTIBYTE is expanded from...
configure.in:777: the top level])
m4trace:configure.in:777: -1- AC_DEFINE_TRACE_LITERAL([HAVE_WINT_T])
m4trace:configure.in:777: -1- AH_OUTPUT([HAVE_WINT_T], [/* systems should define this type here */
@@ -1515,7 +1515,7 @@ m4trace:configure.in:853: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LSTAT])
m4trace:configure.in:857: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
aclocal.m4:1909: BASH_FUNC_CTYPE_NONASCII is expanded from...
aclocal.m4:1906: BASH_FUNC_CTYPE_NONASCII is expanded from...
configure.in:857: the top level])
m4trace:configure.in:857: -1- AC_DEFINE_TRACE_LITERAL([CTYPE_NON_ASCII])
m4trace:configure.in:858: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
@@ -1769,7 +1769,7 @@ m4trace:configure.in:927: -1- AC_DEFINE_TRACE_LITERAL([FIONREAD_IN_SYS_IOCTL])
m4trace:configure.in:929: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
aclocal.m4:1942: BASH_CHECK_WCONTINUED is expanded from...
aclocal.m4:1939: BASH_CHECK_WCONTINUED is expanded from...
configure.in:929: the top level])
m4trace:configure.in:929: -1- AC_DEFINE_TRACE_LITERAL([WCONTINUED_BROKEN])
m4trace:configure.in:932: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
@@ -1782,21 +1782,21 @@ m4trace:configure.in:933: -1- AC_DEFINE_TRACE_LITERAL([HAVE_GETPW_DECLS])
m4trace:configure.in:934: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
aclocal.m4:1670: BASH_CHECK_RTSIGS is expanded from...
aclocal.m4:1667: BASH_CHECK_RTSIGS is expanded from...
configure.in:934: the top level])
m4trace:configure.in:934: -1- AC_DEFINE_TRACE_LITERAL([UNUSABLE_RT_SIGNALS])
m4trace:configure.in:935: -1- AC_SUBST([SIGLIST_O])
m4trace:configure.in:939: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
aclocal.m4:1619: BASH_CHECK_KERNEL_RLIMIT is expanded from...
aclocal.m4:1616: BASH_CHECK_KERNEL_RLIMIT is expanded from...
configure.in:939: the top level])
m4trace:configure.in:939: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete.
You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:2173: AC_COMPILE_IFELSE is expanded from...
autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
aclocal.m4:1619: BASH_CHECK_KERNEL_RLIMIT is expanded from...
aclocal.m4:1616: BASH_CHECK_KERNEL_RLIMIT is expanded from...
configure.in:939: the top level])
m4trace:configure.in:939: -1- AC_DEFINE_TRACE_LITERAL([RLIMIT_NEEDS_KERNEL])
m4trace:configure.in:947: -1- AC_CHECK_LIB([termcap], [tgetent], [bash_cv_termcap_lib=libtermcap], [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
@@ -1848,13 +1848,12 @@ m4trace:configure.in:1094: -1- AC_SUBST([LOCAL_LIBS])
m4trace:configure.in:1095: -1- AC_SUBST([LOCAL_CFLAGS])
m4trace:configure.in:1096: -1- AC_SUBST([LOCAL_LDFLAGS])
m4trace:configure.in:1097: -1- AC_SUBST([LOCAL_DEFS])
m4trace:configure.in:1111: -1- AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
m4trace:configure.in:1110: -1- AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
lib/intl/Makefile \
lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
examples/loadables/Makefile examples/loadables/perl/Makefile \
pathnames.h])
m4trace:configure.in:1111: -1- _m4_warn([obsolete], [AC_OUTPUT should be used without arguments.
examples/loadables/Makefile examples/loadables/perl/Makefile])
m4trace:configure.in:1110: -1- _m4_warn([obsolete], [AC_OUTPUT should be used without arguments.
You should run autoupdate.], [])
m4trace:configure.in:1111: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
m4trace:configure.in:1111: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
m4trace:configure.in:1110: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
m4trace:configure.in:1110: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
+3200
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -55,7 +55,7 @@
*/
/* The character which is used to separate arguments. */
int brace_arg_separator = ',';
static const int brace_arg_separator = ',';
#if defined (__P)
static int brace_gobbler __P((char *, size_t, int *, int));
+630
View File
@@ -0,0 +1,630 @@
/* braces.c -- code for doing word expansion in curly braces. */
/* Copyright (C) 1987-2003 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Stuff in curly braces gets expanded before all other shell expansions. */
#include "config.h"
#if defined (BRACE_EXPANSION)
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include "bashansi.h"
#if defined (SHELL)
# include "shell.h"
#endif /* SHELL */
#include "general.h"
#include "shmbutil.h"
#include "chartypes.h"
#define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
#define BRACE_SEQ_SPECIFIER ".."
/* Basic idea:
Segregate the text into 3 sections: preamble (stuff before an open brace),
postamble (stuff after the matching close brace) and amble (stuff after
preamble, and before postamble). Expand amble, and then tack on the
expansions to preamble. Expand postamble, and tack on the expansions to
the result so far.
*/
/* The character which is used to separate arguments. */
int brace_arg_separator = ',';
#if defined (__P)
static int brace_gobbler __P((char *, size_t, int *, int));
static char **expand_amble __P((char *, size_t, int));
static char **expand_seqterm __P((char *, size_t));
static char **mkseq __P((int, int, int, int));
static char **array_concat __P((char **, char **));
#else
static int brace_gobbler ();
static char **expand_amble ();
static char **expand_seqterm ();
static char **mkseq();
static char **array_concat ();
#endif
#if 0
static void
dump_result (a)
char **a;
{
int i;
for (i = 0; a[i]; i++)
printf ("dump_result: a[%d] = -%s-\n", i, a[i]);
}
#endif
/* Return an array of strings; the brace expansion of TEXT. */
char **
brace_expand (text)
char *text;
{
register int start;
size_t tlen;
char *preamble, *postamble, *amble;
size_t alen;
char **tack, **result;
int i, j, c, c1;
DECLARE_MBSTATE;
/* Find the text of the preamble. */
tlen = strlen (text);
i = 0;
#if defined (CSH_BRACE_COMPAT)
c = brace_gobbler (text, tlen, &i, '{'); /* } */
#else
/* Make sure that when we exit this loop, c == 0 or text[i] begins a
valid brace expansion sequence. */
do
{
c = brace_gobbler (text, tlen, &i, '{'); /* } */
c1 = c;
/* Verify that c begins a valid brace expansion word. If it doesn't, we
go on. Loop stops when there are no more open braces in the word. */
if (c)
{
start = j = i + 1; /* { */
c = brace_gobbler (text, tlen, &j, '}');
if (c == 0) /* it's not */
{
i++;
c = c1;
continue;
}
else /* it is */
{
c = c1;
break;
}
}
else
break;
}
while (c);
#endif /* !CSH_BRACE_COMPAT */
preamble = (char *)xmalloc (i + 1);
strncpy (preamble, text, i);
preamble[i] = '\0';
result = (char **)xmalloc (2 * sizeof (char *));
result[0] = preamble;
result[1] = (char *)NULL;
/* Special case. If we never found an exciting character, then
the preamble is all of the text, so just return that. */
if (c != '{')
return (result);
/* Find the amble. This is the stuff inside this set of braces. */
start = ++i;
c = brace_gobbler (text, tlen, &i, '}');
/* What if there isn't a matching close brace? */
if (c == 0)
{
#if defined (NOTDEF)
/* Well, if we found an unquoted BRACE_ARG_SEPARATOR between START
and I, then this should be an error. Otherwise, it isn't. */
j = start;
while (j < i)
{
if (text[j] == '\\')
{
j++;
ADVANCE_CHAR (text, tlen, j);
continue;
}
if (text[j] == brace_arg_separator)
{ /* { */
strvec_dispose (result);
report_error ("no closing `%c' in %s", '}', text);
throw_to_top_level ();
}
ADVANCE_CHAR (text, tlen, j);
}
#endif
free (preamble); /* Same as result[0]; see initialization. */
result[0] = savestring (text);
return (result);
}
#if defined (SHELL)
amble = substring (text, start, i);
alen = i - start;
#else
amble = (char *)xmalloc (1 + (i - start));
strncpy (amble, &text[start], (i - start));
alen = i - start;
amble[alen] = '\0';
#endif
#if defined (SHELL)
INITIALIZE_MBSTATE;
/* If the amble does not contain an unquoted BRACE_ARG_SEPARATOR, then
just return without doing any expansion. */
j = 0;
while (amble[j])
{
if (amble[j] == '\\')
{
j++;
ADVANCE_CHAR (amble, alen, j);
continue;
}
if (amble[j] == brace_arg_separator)
break;
ADVANCE_CHAR (amble, alen, j);
}
if (amble[j] == 0)
{
tack = expand_seqterm (amble, alen);
if (tack)
goto add_tack;
else
{
free (amble);
free (preamble);
result[0] = savestring (text);
return (result);
}
}
#endif /* SHELL */
tack = expand_amble (amble, alen, 0);
add_tack:
result = array_concat (result, tack);
free (amble);
strvec_dispose (tack);
postamble = text + i + 1;
tack = brace_expand (postamble);
result = array_concat (result, tack);
strvec_dispose (tack);
return (result);
}
/* Expand the text found inside of braces. We simply try to split the
text at BRACE_ARG_SEPARATORs into separate strings. We then brace
expand each slot which needs it, until there are no more slots which
need it. */
static char **
expand_amble (text, tlen, flags)
char *text;
size_t tlen;
int flags;
{
char **result, **partial;
char *tem;
int start, i, c;
DECLARE_MBSTATE;
result = (char **)NULL;
start = i = 0;
c = 1;
while (c)
{
c = brace_gobbler (text, tlen, &i, brace_arg_separator);
#if defined (SHELL)
tem = substring (text, start, i);
#else
tem = (char *)xmalloc (1 + (i - start));
strncpy (tem, &text[start], (i - start));
tem[i- start] = '\0';
#endif
partial = brace_expand (tem);
if (!result)
result = partial;
else
{
register int lr, lp, j;
lr = strvec_len (result);
lp = strvec_len (partial);
result = strvec_resize (result, lp + lr + 1);
for (j = 0; j < lp; j++)
result[lr + j] = partial[j];
result[lr + j] = (char *)NULL;
free (partial);
}
free (tem);
ADVANCE_CHAR (text, tlen, i);
start = i;
}
return (result);
}
#define ST_BAD 0
#define ST_INT 1
#define ST_CHAR 2
static char **
mkseq (start, end, incr, type)
int start, end, incr, type;
{
int n, i;
char **result, *t;
n = abs (end - start) + 1;
result = strvec_create (n + 1);
if (incr == 0)
incr = 1;
if (start > end && incr > 0)
incr = -incr;
else if (start < end && incr < 0)
incr = -incr;
/* Make sure we go through the loop at least once, so {3..3} prints `3' */
i = 0;
n = start;
do
{
#if defined (SHELL)
QUIT; /* XXX - memory leak here */
#endif
if (type == ST_INT)
result[i++] = itos (n);
else
{
t = (char *)xmalloc (2);
t[0] = n;
t[1] = '\0';
result[i++] = t;
}
if (n == end)
break;
n += incr;
}
while (1);
result[i] = (char *)0;
return (result);
}
static char **
expand_seqterm (text, tlen)
char *text;
size_t tlen;
{
char *t, *lhs, *rhs;
int i, lhs_t, rhs_t, lhs_v, rhs_v;
intmax_t tl, tr;
char **result;
t = strstr (text, BRACE_SEQ_SPECIFIER);
if (t == 0)
return ((char **)NULL);
i = t - text; /* index of start of BRACE_SEQ_SPECIFIER */
lhs = substring (text, 0, i);
rhs = substring (text, i + sizeof(BRACE_SEQ_SPECIFIER) - 1, tlen);
if (lhs[0] == 0 || rhs[0] == 0)
{
free (lhs);
free (rhs);
return ((char **)NULL);
}
/* Now figure out whether LHS and RHS are integers or letters. Both
sides have to match. */
lhs_t = (legal_number (lhs, &tl)) ? ST_INT :
((ISALPHA (lhs[0]) && lhs[1] == 0) ? ST_CHAR : ST_BAD);
rhs_t = (legal_number (rhs, &tr)) ? ST_INT :
((ISALPHA (rhs[0]) && rhs[1] == 0) ? ST_CHAR : ST_BAD);
if (lhs_t != rhs_t || lhs_t == ST_BAD || rhs_t == ST_BAD)
{
free (lhs);
free (rhs);
return ((char **)NULL);
}
/* OK, we have something. It's either a sequence of integers, ascending
or descending, or a sequence or letters, ditto. Generate the sequence,
put it into a string vector, and return it. */
if (lhs_t == ST_CHAR)
{
lhs_v = (unsigned char)lhs[0];
rhs_v = (unsigned char)rhs[0];
}
else
{
lhs_v = tl; /* integer truncation */
rhs_v = tr;
}
result = mkseq (lhs_v, rhs_v, 1, lhs_t);
free (lhs);
free (rhs);
return (result);
}
/* Start at INDEX, and skip characters in TEXT. Set INDEX to the
index of the character matching SATISFY. This understands about
quoting. Return the character that caused us to stop searching;
this is either the same as SATISFY, or 0. */
/* If SATISFY is `}', we are looking for a brace expression, so we
should enforce the rules that govern valid brace expansions:
1) to count as an arg separator, a comma or `..' has to be outside
an inner set of braces.
*/
static int
brace_gobbler (text, tlen, indx, satisfy)
char *text;
size_t tlen;
int *indx;
int satisfy;
{
register int i, c, quoted, level, commas, pass_next;
#if defined (SHELL)
int si;
char *t;
#endif
DECLARE_MBSTATE;
level = quoted = pass_next = 0;
#if defined (CSH_BRACE_COMPAT)
commas = 1;
#else
commas = (satisfy == '}') ? 0 : 1;
#endif
i = *indx;
while (c = text[i])
{
if (pass_next)
{
pass_next = 0;
ADVANCE_CHAR (text, tlen, i);
continue;
}
/* A backslash escapes the next character. This allows backslash to
escape the quote character in a double-quoted string. */
if (c == '\\' && (quoted == 0 || quoted == '"' || quoted == '`'))
{
pass_next = 1;
i++;
continue;
}
#if defined (SHELL)
/* If compiling for the shell, treat ${...} like \{...} */
if (c == '$' && text[i+1] == '{' && quoted != '\'') /* } */
{
pass_next = 1;
i++;
if (quoted == 0)
level++;
continue;
}
#endif
if (quoted)
{
if (c == quoted)
quoted = 0;
ADVANCE_CHAR (text, tlen, i);
continue;
}
if (c == '"' || c == '\'' || c == '`')
{
quoted = c;
i++;
continue;
}
#if defined (SHELL)
/* Pass new-style command substitutions through unchanged. */
if (c == '$' && text[i+1] == '(') /* ) */
{
si = i + 2;
t = extract_command_subst (text, &si);
i = si;
free (t);
i++;
continue;
}
#endif
if (c == satisfy && level == 0 && quoted == 0 && commas > 0)
{
/* We ignore an open brace surrounded by whitespace, and also
an open brace followed immediately by a close brace preceded
by whitespace. */
if (c == '{' &&
((!i || brace_whitespace (text[i - 1])) &&
(brace_whitespace (text[i + 1]) || text[i + 1] == '}')))
{
i++;
continue;
}
break;
}
if (c == '{')
level++;
else if (c == '}' && level)
level--;
#if !defined (CSH_BRACE_COMPAT)
else if (satisfy == '}' && c == brace_arg_separator && level == 0)
commas++;
else if (satisfy == '}' && STREQN (text+i, BRACE_SEQ_SPECIFIER, 2) &&
text[i+2] != satisfy && level == 0)
commas++;
#endif
ADVANCE_CHAR (text, tlen, i);
}
*indx = i;
return (c);
}
/* Return a new array of strings which is the result of appending each
string in ARR2 to each string in ARR1. The resultant array is
len (arr1) * len (arr2) long. For convenience, ARR1 (and its contents)
are free ()'ed. ARR1 can be NULL, in that case, a new version of ARR2
is returned. */
static char **
array_concat (arr1, arr2)
char **arr1, **arr2;
{
register int i, j, len, len1, len2;
register char **result;
if (arr1 == 0)
return (strvec_copy (arr2));
if (arr2 == 0)
return (strvec_copy (arr1));
len1 = strvec_len (arr1);
len2 = strvec_len (arr2);
result = (char **)xmalloc ((1 + (len1 * len2)) * sizeof (char *));
len = 0;
for (i = 0; i < len1; i++)
{
int strlen_1 = strlen (arr1[i]);
for (j = 0; j < len2; j++)
{
result[len] = (char *)xmalloc (1 + strlen_1 + strlen (arr2[j]));
strcpy (result[len], arr1[i]);
strcpy (result[len] + strlen_1, arr2[j]);
len++;
}
free (arr1[i]);
}
free (arr1);
result[len] = (char *)NULL;
return (result);
}
#if defined (TEST)
#include <stdio.h>
fatal_error (format, arg1, arg2)
char *format, *arg1, *arg2;
{
report_error (format, arg1, arg2);
exit (1);
}
report_error (format, arg1, arg2)
char *format, *arg1, *arg2;
{
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
}
main ()
{
char example[256];
for (;;)
{
char **result;
int i;
fprintf (stderr, "brace_expand> ");
if ((!fgets (example, 256, stdin)) ||
(strncmp (example, "quit", 4) == 0))
break;
if (strlen (example))
example[strlen (example) - 1] = '\0';
result = brace_expand (example);
for (i = 0; result[i]; i++)
printf ("%s\n", result[i]);
free_array (result);
}
}
/*
* Local variables:
* compile-command: "gcc -g -Bstatic -DTEST -o brace_expand braces.c general.o"
* end:
*/
#endif /* TEST */
#endif /* BRACE_EXPANSION */
+1 -1
View File
@@ -56,7 +56,7 @@ extern int errno;
extern int posixly_correct;
extern int array_needs_making;
extern char *bash_getcwd_errstr;
extern const char * const bash_getcwd_errstr;
static int bindpwd __P((int));
static void setpwd __P((char *));
+5 -5
View File
@@ -73,11 +73,11 @@ int cdable_vars;
$BUILTIN cd
$FUNCTION cd_builtin
$SHORT_DOC cd [-L|-P] [dir]
Change the current directory to DIR. The variable $HOME is the
default DIR. The variable CDPATH defines the search path for
the directory containing DIR. Alternative directory names in CDPATH
are separated by a colon (:). A null directory name is the same as
the current directory, i.e. `.'. If DIR begins with a slash (/),
Change the current directory to DIR. The default for DIR is the value
of the HOME shell variable. The variable CDPATH defines the search
path for the directory containing DIR. Alternative directory names in
CDPATH are separated by a colon (:). A null directory name is the same
as the current directory, i.e., `.'. If DIR begins with a slash (/),
then CDPATH is not used. If the directory is not found, and the
shell option `cdable_vars' is set, then try the word as a variable
name. If that variable has a value, then cd to the value of that
+2 -2
View File
@@ -69,7 +69,7 @@ extern int last_command_exit_value;
extern int running_trap;
extern int posixly_correct;
extern char *this_command_name, *shell_name;
extern char *bash_getcwd_errstr;
extern const char * const bash_getcwd_errstr;
/* Used by some builtins and the mainline code. */
sh_builtin_func_t *last_shell_builtin = (sh_builtin_func_t *)NULL;
@@ -639,7 +639,7 @@ display_signal_list (list, forcecols)
{
printf ("%2d) %s", i, name);
if (++column < 4)
if (++column < 5)
printf ("\t");
else
{
+2 -2
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.
@@ -639,7 +639,7 @@ display_signal_list (list, forcecols)
{
printf ("%2d) %s", i, name);
if (++column < 4)
if (++column < 5)
printf ("\t");
else
{
+4 -4
View File
@@ -73,8 +73,8 @@ static int print_cmd_completions __P((WORD_LIST *));
static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
static struct _compacts {
char *actname;
static const struct _compacts {
const char * const actname;
int actflag;
int actopt;
} compacts[] = {
@@ -106,8 +106,8 @@ static struct _compacts {
};
/* This should be a STRING_INT_ALIST */
static struct _compopt {
char *optname;
const static struct _compopt {
const char * const optname;
int optflag;
} compopts[] = {
{ "bashdefault", COPT_BASHDEFAULT },
+1 -1
View File
@@ -533,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
+24 -12
View File
@@ -45,6 +45,7 @@ $END
#include "common.h"
#include "builtext.h" /* for jobs_builtin */
extern int check_jobs_at_exit;
extern int last_command_exit_value;
extern int running_trap, trap_saved_exit_value;
extern int subshell_environment;
@@ -94,7 +95,7 @@ exit_or_logout (list)
int exit_value;
#if defined (JOB_CONTROL)
int exit_immediate_okay;
int exit_immediate_okay, stopmsg;
exit_immediate_okay = (interactive == 0 ||
last_shell_builtin == exit_builtin ||
@@ -102,21 +103,32 @@ exit_or_logout (list)
last_shell_builtin == jobs_builtin);
/* Check for stopped jobs if the user wants to. */
if (!exit_immediate_okay)
if (exit_immediate_okay == 0)
{
register int i;
for (i = 0; i < js.j_jobslots; i++)
for (i = stopmsg = 0; i < js.j_jobslots; i++)
if (jobs[i] && STOPPED (i))
{
fprintf (stderr, _("There are stopped jobs.\n"));
stopmsg = JSTOPPED;
else if (check_jobs_at_exit && stopmsg == 0 && RUNNING (i))
stopmsg = JRUNNING;
/* 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);
}
if (stopmsg == JSTOPPED)
fprintf (stderr, _("There are stopped jobs.\n"));
else if (stopmsg == JRUNNING)
fprintf (stderr, _("There are running jobs.\n"));
if (stopmsg && check_jobs_at_exit)
list_all_jobs (JLIST_STANDARD);
if (stopmsg)
{
/* This is NOT superfluous because EOF can get here without
going through the command parser. Set both last and this
so that either `exit', `logout', or ^D will work to exit
immediately if nothing intervenes. */
this_shell_builtin = last_shell_builtin = exit_builtin;
return (EXECUTION_FAILURE);
}
}
#endif /* JOB_CONTROL */
+3 -3
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);
}
@@ -102,7 +102,7 @@ exit_or_logout (list)
last_shell_builtin == jobs_builtin);
/* Check for stopped jobs if the user wants to. */
if (!exit_immediate_okay)
if (exit_immediate_okay == 0)
{
register int i;
for (i = 0; i < js.j_jobslots; i++)
+36 -14
View File
@@ -1,7 +1,7 @@
This file is help.def, from which is created help.c.
It implements the builtin "help" in Bash.
Copyright (C) 1987-2003 Free Software Foundation, Inc.
Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -176,7 +176,8 @@ static void
show_builtin_command_help ()
{
int i, j;
char blurb[36];
int height, width;
char *t, blurb[128];
printf (
_("These shell commands are defined internally. Type `help' to see this list.\n\
@@ -187,21 +188,42 @@ Use `man -k' or `info' to find out more about commands not in this list.\n\
A star (*) next to a name means that the command is disabled.\n\
\n"));
for (i = 0; i < num_shell_builtins; i++)
t = get_string_value ("COLUMNS");
width = (t && *t) ? atoi (t) : 80;
if (width <= 0)
width = 80;
width /= 2;
if (width > sizeof (blurb))
width = sizeof (blurb);
height = (num_shell_builtins + 1) / 2; /* number of rows */
for (i = 0; i < height; i++)
{
QUIT;
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
strncpy (blurb + 1, shell_builtins[i].short_doc, 34);
blurb[35] = '\0';
printf ("%s", blurb);
if (i % 2)
printf ("\n");
else
for (j = strlen (blurb); j < 35; j++)
putc (' ', stdout);
/* first column */
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
strncpy (blurb + 1, shell_builtins[i].short_doc, width - 2);
blurb[width - 2] = '>'; /* indicate truncation */
blurb[width - 1] = '\0';
printf ("%s", blurb);
if ((i << 1) == num_shell_builtins)
{
printf ("\n");
break;
}
/* two spaces */
for (j = strlen (blurb); j < width; j++)
putc (' ', stdout);
/* second column */
blurb[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
strncpy (blurb + 1, shell_builtins[i+height].short_doc, width - 3);
blurb[width - 3] = '>'; /* indicate truncation */
blurb[width - 2] = '\0';
printf ("%s\n", blurb);
}
if (i % 2)
printf ("\n");
}
#endif /* HELP_BUILTIN */
+207
View File
@@ -0,0 +1,207 @@
This file is help.def, from which is created help.c.
It implements the builtin "help" in Bash.
Copyright (C) 1987-2003 Free Software Foundation, Inc.
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 help.c
$BUILTIN help
$FUNCTION help_builtin
$DEPENDS_ON HELP_BUILTIN
$SHORT_DOC help [-s] [pattern ...]
Display helpful information about builtin commands. If PATTERN is
specified, gives detailed help on all commands matching PATTERN,
otherwise a list of the builtins is printed. The -s option
restricts the output for each builtin command matching PATTERN to
a short usage synopsis.
$END
#include <config.h>
#if defined (HELP_BUILTIN)
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include <errno.h>
#include <filecntl.h>
#include "../bashintl.h"
#include "../shell.h"
#include "../builtins.h"
#include "../pathexp.h"
#include "common.h"
#include "bashgetopt.h"
#include <glob/strmatch.h>
#include <glob/glob.h>
#ifndef errno
extern int errno;
#endif
static void show_builtin_command_help __P((void));
static void show_longdoc __P((int));
/* Print out a list of the known functions in the shell, and what they do.
If LIST is supplied, print out the list which matches for each pattern
specified. */
int
help_builtin (list)
WORD_LIST *list;
{
register int i;
char *pattern, *name;
int plen, match_found, sflag;
sflag = 0;
reset_internal_getopt ();
while ((i = internal_getopt (list, "s")) != -1)
{
switch (i)
{
case 's':
sflag = 1;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
if (list == 0)
{
show_shell_version (0);
show_builtin_command_help ();
return (EXECUTION_SUCCESS);
}
/* We should consider making `help bash' do something. */
if (glob_pattern_p (list->word->word))
{
if (list->next)
printf (_("Shell commands matching keywords `"));
else
printf (_("Shell commands matching keyword `"));
print_word_list (list, ", ");
printf ("'\n\n");
}
for (match_found = 0, pattern = ""; list; list = list->next)
{
pattern = list->word->word;
plen = strlen (pattern);
for (i = 0; name = shell_builtins[i].name; i++)
{
QUIT;
if ((strncmp (pattern, name, plen) == 0) ||
(strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH))
{
printf ("%s: %s\n", name, shell_builtins[i].short_doc);
if (sflag == 0)
show_longdoc (i);
match_found++;
}
}
}
if (match_found == 0)
{
builtin_error (_("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern);
return (EXECUTION_FAILURE);
}
fflush (stdout);
return (EXECUTION_SUCCESS);
}
/* By convention, enforced by mkbuiltins.c, if separate help files are being
used, the long_doc array contains one string -- the full pathname of the
help file for this builtin. */
static void
show_longdoc (i)
int i;
{
register int j;
char * const *doc;
int fd;
doc = shell_builtins[i].long_doc;
if (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL)
{
fd = open (doc[0], O_RDONLY);
if (fd == -1)
{
builtin_error (_("%s: cannot open: %s"), doc[0], strerror (errno));
return;
}
zcatfd (fd, 1, doc[0]);
close (fd);
}
else
for (j = 0; doc[j]; j++)
printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
}
static void
show_builtin_command_help ()
{
int i, j;
char blurb[36];
printf (
_("These shell commands are defined internally. Type `help' to see this list.\n\
Type `help name' to find out more about the function `name'.\n\
Use `info bash' to find out more about the shell in general.\n\
Use `man -k' or `info' to find out more about commands not in this list.\n\
\n\
A star (*) next to a name means that the command is disabled.\n\
\n"));
for (i = 0; i < num_shell_builtins; i++)
{
QUIT;
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
strncpy (blurb + 1, shell_builtins[i].short_doc, 37);
blurb[38] = '\0';
printf ("%s", blurb);
if (i % 2)
printf ("\n");
else
for (j = strlen (blurb); j < 40; j++)
putc (' ', stdout);
}
if (i % 2)
printf ("\n");
}
#endif /* HELP_BUILTIN */
+217
View File
@@ -0,0 +1,217 @@
This file is help.def, from which is created help.c.
It implements the builtin "help" in Bash.
Copyright (C) 1987-2003 Free Software Foundation, Inc.
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 help.c
$BUILTIN help
$FUNCTION help_builtin
$DEPENDS_ON HELP_BUILTIN
$SHORT_DOC help [-s] [pattern ...]
Display helpful information about builtin commands. If PATTERN is
specified, gives detailed help on all commands matching PATTERN,
otherwise a list of the builtins is printed. The -s option
restricts the output for each builtin command matching PATTERN to
a short usage synopsis.
$END
#include <config.h>
#if defined (HELP_BUILTIN)
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include <errno.h>
#include <filecntl.h>
#include "../bashintl.h"
#include "../shell.h"
#include "../builtins.h"
#include "../pathexp.h"
#include "common.h"
#include "bashgetopt.h"
#include <glob/strmatch.h>
#include <glob/glob.h>
#ifndef errno
extern int errno;
#endif
static void show_builtin_command_help __P((void));
static void show_longdoc __P((int));
/* Print out a list of the known functions in the shell, and what they do.
If LIST is supplied, print out the list which matches for each pattern
specified. */
int
help_builtin (list)
WORD_LIST *list;
{
register int i;
char *pattern, *name;
int plen, match_found, sflag;
sflag = 0;
reset_internal_getopt ();
while ((i = internal_getopt (list, "s")) != -1)
{
switch (i)
{
case 's':
sflag = 1;
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend;
if (list == 0)
{
show_shell_version (0);
show_builtin_command_help ();
return (EXECUTION_SUCCESS);
}
/* We should consider making `help bash' do something. */
if (glob_pattern_p (list->word->word))
{
if (list->next)
printf (_("Shell commands matching keywords `"));
else
printf (_("Shell commands matching keyword `"));
print_word_list (list, ", ");
printf ("'\n\n");
}
for (match_found = 0, pattern = ""; list; list = list->next)
{
pattern = list->word->word;
plen = strlen (pattern);
for (i = 0; name = shell_builtins[i].name; i++)
{
QUIT;
if ((strncmp (pattern, name, plen) == 0) ||
(strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH))
{
printf ("%s: %s\n", name, shell_builtins[i].short_doc);
if (sflag == 0)
show_longdoc (i);
match_found++;
}
}
}
if (match_found == 0)
{
builtin_error (_("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern);
return (EXECUTION_FAILURE);
}
fflush (stdout);
return (EXECUTION_SUCCESS);
}
/* By convention, enforced by mkbuiltins.c, if separate help files are being
used, the long_doc array contains one string -- the full pathname of the
help file for this builtin. */
static void
show_longdoc (i)
int i;
{
register int j;
char * const *doc;
int fd;
doc = shell_builtins[i].long_doc;
if (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL)
{
fd = open (doc[0], O_RDONLY);
if (fd == -1)
{
builtin_error (_("%s: cannot open: %s"), doc[0], strerror (errno));
return;
}
zcatfd (fd, 1, doc[0]);
close (fd);
}
else
for (j = 0; doc[j]; j++)
printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
}
static void
show_builtin_command_help ()
{
int i, j;
int width;
char *t, blurb[128];
printf (
_("These shell commands are defined internally. Type `help' to see this list.\n\
Type `help name' to find out more about the function `name'.\n\
Use `info bash' to find out more about the shell in general.\n\
Use `man -k' or `info' to find out more about commands not in this list.\n\
\n\
A star (*) next to a name means that the command is disabled.\n\
\n"));
t = get_string_value ("COLUMNS");
width = (t && *t) ? atoi (t) : 80;
if (width <= 0)
width = 80;
width /= 2;
if (width > sizeof (blurb))
width = sizeof (blurb);
for (i = 0; i < num_shell_builtins; i++)
{
QUIT;
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
strncpy (blurb + 1, shell_builtins[i].short_doc, width - 2);
blurb[width - 1] = '\0';
printf ("%s", blurb);
if (i % 2)
printf ("\n");
else
for (j = strlen (blurb); j < width; j++)
putc (' ', stdout);
}
if (i % 2)
printf ("\n");
}
#endif /* HELP_BUILTIN */
+1 -1
View File
@@ -145,7 +145,7 @@ $END
$BUILTIN variables
$DOCNAME variable_help
$SHORT_DOC variables - Some variable names and meanings
$SHORT_DOC variables - Names and meanings of some shell variables
BASH_VERSION Version information for this Bash.
CDPATH A colon-separated list of directories to search
for directries given as arguments to `cd'.
+3 -3
View File
@@ -164,13 +164,13 @@ static int get_edit_mode __P((char *));
static int bash_set_history __P((int, char *));
#endif
static char *on = "on";
static char *off = "off";
static const char * const on = "on";
static const char * const off = "off";
/* A struct used to match long options for set -o to the corresponding
option letter or internal variable. The functions can be called to
dynamically generate values. */
struct {
const struct {
char *name;
int letter;
int *variable;
+5 -2
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.
@@ -161,8 +164,8 @@ static int get_edit_mode __P((char *));
static int bash_set_history __P((int, char *));
#endif
static char *on = "on";
static char *off = "off";
static const char * const on = "on";
static const char * const off = "off";
/* A struct used to match long options for set -o to the corresponding
option letter or internal variable. The functions can be called to
+6 -2
View File
@@ -68,6 +68,8 @@ extern int glob_ignore_case, match_ignore_case;
extern int hup_on_exit;
extern int xpg_echo;
extern int gnu_error_format;
extern int check_jobs_at_exit;
extern int autocd;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
@@ -114,9 +116,11 @@ static struct {
int *value;
shopt_set_func_t *set_func;
} shopt_vars[] = {
{ "autocd", &autocd, (shopt_set_func_t *)NULL },
{ "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
{ "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
{ "checkhash", &check_hashed_filenames, (shopt_set_func_t *)NULL },
{ "checkjobs", &check_jobs_at_exit, (shopt_set_func_t *)NULL },
{ "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
{ "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
@@ -170,8 +174,8 @@ static struct {
{ (char *)0, (int *)0, (shopt_set_func_t *)NULL }
};
static char *on = "on";
static char *off = "off";
static const char * const on = "on";
static const char * const off = "off";
static int find_shopt __P((char *));
static int toggle_shopts __P((int, WORD_LIST *, int));
+5 -1
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.
@@ -68,6 +68,8 @@ extern int glob_ignore_case, match_ignore_case;
extern int hup_on_exit;
extern int xpg_echo;
extern int gnu_error_format;
extern int check_jobs_at_exit;
extern int autocd;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
@@ -114,9 +116,11 @@ static struct {
int *value;
shopt_set_func_t *set_func;
} shopt_vars[] = {
{ "autocd", &autocd, (shopt_set_func_t *)NULL },
{ "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
{ "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
{ "checkhash", &check_hashed_filenames, (shopt_set_func_t *)NULL },
{ "checkjobs", &check_jobs_at_exit, (shopt_set_func_t *)NULL },
{ "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
{ "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
+2 -2
View File
@@ -193,8 +193,8 @@ typedef struct {
int option; /* The ulimit option for this limit. */
int parameter; /* Parameter to pass to get_limit (). */
int block_factor; /* Blocking factor for specific limit. */
char *description; /* Descriptive string to output. */
char *units; /* scale */
const char * const description; /* Descriptive string to output. */
const char * const units; /* scale */
} RESOURCE_LIMITS;
static RESOURCE_LIMITS limits[] = {
+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);
}
}
Vendored
+4 -5
View File
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in for Bash 3.2, version 3.190.
# From configure.in for Bash 3.2, version 3.193.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for bash 3.2-maint.
#
@@ -1693,7 +1693,7 @@ if test "$opt_curses" = yes; then
fi
if test -z "${DEBUGGER_START_FILE}"; then
DEBUGGER_START_FILE=${ac_default_prefix}/share/bashdb/bashdb-main.inc
DEBUGGER_START_FILE='${datadir}/bashdb/bashdb-main.inc'
fi
opt_minimal_config=no
@@ -23402,7 +23402,7 @@ cat >>conftest.$ac_ext <<_ACEOF
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifndef SYS_SIGLIST_DECLARED
#if !HAVE_DECL_SYS_SIGLIST
extern char *sys_siglist[];
#endif
main()
@@ -27426,7 +27426,7 @@ esac
#AC_SUBST(ALLOCA_SOURCE)
#AC_SUBST(ALLOCA_OBJECT)
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/perl/Makefile pathnames.h"
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/perl/Makefile"
ac_config_commands="$ac_config_commands default"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -27983,7 +27983,6 @@ do
"po/Makefile.in" ) CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;;
"examples/loadables/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile" ;;
"examples/loadables/perl/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/loadables/perl/Makefile" ;;
"pathnames.h" ) CONFIG_FILES="$CONFIG_FILES pathnames.h" ;;
"default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
"default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+4 -5
View File
@@ -22,7 +22,7 @@ dnl Process this file with autoconf to produce a configure script.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AC_REVISION([for Bash 3.2, version 3.192])dnl
AC_REVISION([for Bash 3.2, version 3.193])dnl
define(bashvers, 3.2)
define(relstatus, maint)
@@ -149,7 +149,7 @@ if test "$opt_curses" = yes; then
fi
if test -z "${DEBUGGER_START_FILE}"; then
DEBUGGER_START_FILE=${ac_default_prefix}/share/bashdb/bashdb-main.inc
DEBUGGER_START_FILE='${datadir}/bashdb/bashdb-main.inc'
fi
dnl optional shell features in config.h.in
@@ -782,7 +782,7 @@ AC_CHECK_LIB(dl, dlopen)
AC_CHECK_FUNCS(dlopen dlclose dlsym)
fi
dnl this defines SYS_SIGLIST_DECLARED
dnl this defines HAVE_DECL_SYS_SIGLIST
AC_DECL_SYS_SIGLIST
dnl network functions -- check for inet_aton again
@@ -1103,8 +1103,7 @@ AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
lib/intl/Makefile \
lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
examples/loadables/Makefile examples/loadables/perl/Makefile \
pathnames.h],
examples/loadables/Makefile examples/loadables/perl/Makefile],
[
# Makefile uses this timestamp file to record whether config.h is up to date.
echo timestamp > stamp-h
+1111
View File
File diff suppressed because it is too large Load Diff
+1110
View File
File diff suppressed because it is too large Load Diff
+63 -8
View File
@@ -6,12 +6,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Mon Nov 27 12:02:01 EST 2006
.\" Last Change: Tue Dec 26 19:01:54 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 27" "GNU Bash-3.2"
.TH BASH 1 "2006 December 26" "GNU Bash-3.2"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -1245,6 +1245,11 @@ The following variables are set by the shell:
Expands to the full file name used to invoke this instance of
.BR bash .
.TP
.B BASHPID
Expands to the process id of the current bash process.
This differs from \fB$$\fP under certain circumstances, such as subshells
that do not require bash to be re-initialized.
.TP
.B BASH_ARGC
An array variable whose values are the number of parameters in each
frame of the current bash execution call stack.
@@ -1346,6 +1351,10 @@ This variable is available only in shell functions invoked by the
programmable completion facilities (see \fBProgrammable Completion\fP
below).
.TP
.B COMP_KEY
The key (or final key of a key sequence) used to invoke the current
completion function.
.TP
.B COMP_LINE
The current command line.
This variable is available only in shell functions and external
@@ -1363,6 +1372,20 @@ commands invoked by the
programmable completion facilities (see \fBProgrammable Completion\fP
below).
.TP
.B COMP_TYPE
Set to an integer value corresponding to the type of completion attempted
that caused a completion function to be called:
\fITAB\fP, for normal completion,
\fI?\fP, for listing completions after successive tabs,
\fI!\fP, for listing alternatives on partial word completion,
\fI@\fP, to list completions if the word is not unmodified,
or
\fI%\fP, for menu completion.
This variable is available only in shell functions and external
commands invoked by the
programmable completion facilities (see \fBProgrammable Completion\fP
below).
.TP
.B COMP_WORDBREAKS
The set of characters that the Readline library treats as word
separators when performing word completion.
@@ -2674,10 +2697,18 @@ is unset, or its
value is exactly
.BR <space><tab><newline> ,
the default, then
sequences of
.BR <space> ,
.BR <tab> ,
and
.B <newline>
at the beginning and end of the results of the previous
expansions are ignored, and
any sequence of
.SM
.B IFS
characters serves to delimit words. If
characters not at the beginning or end serves to delimit words.
If
.SM
.B IFS
has a value other than the default, then sequences of
@@ -4178,11 +4209,15 @@ is executed for each child that exits.
.PP
If an attempt to exit
.B bash
is made while jobs are stopped, the shell prints a warning message. The
is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has
been enabled using the \fBshopt\fP builtin, running), the shell prints a
warning message, and, if the \fBcheckjobs\fP option is enabled, lists the
jobs and their statuses.
The
.B jobs
command may then be used to inspect their status.
command may then be used to inspect their status.
If a second attempt to exit is made without an intervening command,
the shell does not print another warning, and the stopped
the shell does not print another warning, and any stopped
jobs are terminated.
.SH PROMPTING
When executing interactively,
@@ -5459,10 +5494,14 @@ After these matches have been generated, any shell function or command
specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
When the command or function is invoked, the
.SM
.B COMP_LINE
.BR COMP_LINE ,
.SM
.BR COMP_POINT ,
.SM
.BR COMP_KEY ,
and
.SM
.B COMP_POINT
.B COMP_TYPE
variables are assigned values as described above under
\fBShell Variables\fP.
If a shell function is being invoked, the
@@ -7554,6 +7593,10 @@ Any command associated with the \fBRETURN\fP trap is executed
before execution resumes after the function or script.
.TP
\fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
.PD 0
.TP
\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\fP] [\fIarg\fP ...]
.PD
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.
@@ -7955,6 +7998,11 @@ The list of \fBshopt\fP options is:
.if n .sp 1v
.PD 0
.TP 8
.B autocd
If set, a command name that is the name of a directory is executed as if
it were the argument to the \fBcd\fP command.
This option is only used by interactive shells.
.TP 8
.B cdable_vars
If set, an argument to the
.B cd
@@ -7977,6 +8025,13 @@ If set, \fBbash\fP checks that a command found in the hash
table exists before trying to execute it. If a hashed command no
longer exists, a normal path search is performed.
.TP 8
.B checkjobs
If set, bash lists the status of any stopped and running jobs before
exiting an interactive shell. If any jobs are running, this causes
the exit to be deferred until a second exit is attempted without an
intervening command (see \fBJOB CONTROL\fP above). The shell always
postpones exiting if any jobs are stopped.
.TP 8
.B checkwinsize
If set, \fBbash\fP checks the window size after each command
and, if necessary, updates the values of
+58 -10
View File
@@ -6,12 +6,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Mon Nov 27 12:02:01 EST 2006
.\" Last Change: Tue Dec 26 19:01:54 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 27" "GNU Bash-3.2"
.TH BASH 1 "2006 December 26" "GNU Bash-3.2"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -1245,6 +1245,11 @@ The following variables are set by the shell:
Expands to the full file name used to invoke this instance of
.BR bash .
.TP
.B BASHPID
Expands to the process id of the current bash process.
This differs from \fB$$\fP under certain circumstances, such as subshells
that do not require bash to be re-initialized.
.TP
.B BASH_ARGC
An array variable whose values are the number of parameters in each
frame of the current bash execution call stack.
@@ -1363,6 +1368,20 @@ commands invoked by the
programmable completion facilities (see \fBProgrammable Completion\fP
below).
.TP
.B COMP_TYPE
Set to an integer value corresponding to the type of completion attempted
that caused a completion function to be called:
\fITAB\fP, for normal completion,
\fI?\fP, for listing completions after successive tabs,
\fI!\fP, for listing alternatives on partial word completion,
\fI@\fP, to list completions if the word is not unmodified,
or
\fI%\fP, for menu completion.
This variable is available only in shell functions and external
commands invoked by the
programmable completion facilities (see \fBProgrammable Completion\fP
below).
.TP
.B COMP_WORDBREAKS
The set of characters that the Readline library treats as word
separators when performing word completion.
@@ -2674,10 +2693,18 @@ is unset, or its
value is exactly
.BR <space><tab><newline> ,
the default, then
sequences of
.BR <space> ,
.BR <tab> ,
and
.B <newline>
at the beginning and end of the results of the previous
expansions are ignored, and
any sequence of
.SM
.B IFS
characters serves to delimit words. If
characters not at the beginning or end serves to delimit words.
If
.SM
.B IFS
has a value other than the default, then sequences of
@@ -4178,11 +4205,15 @@ is executed for each child that exits.
.PP
If an attempt to exit
.B bash
is made while jobs are stopped, the shell prints a warning message. The
is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has
been enabled using the \fBshopt\fP builtin, running), the shell prints a
warning message, and, if the \fBcheckjobs\fP option is enabled, lists the
jobs and their statuses.
The
.B jobs
command may then be used to inspect their status.
command may then be used to inspect their status.
If a second attempt to exit is made without an intervening command,
the shell does not print another warning, and the stopped
the shell does not print another warning, and any stopped
jobs are terminated.
.SH PROMPTING
When executing interactively,
@@ -5459,10 +5490,11 @@ After these matches have been generated, any shell function or command
specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
When the command or function is invoked, the
.SM
.B COMP_LINE
and
.BR COMP_LINE ,
.SM
.B COMP_POINT
.BR COMP_POINT ,
and
.B COMP_TYPE
variables are assigned values as described above under
\fBShell Variables\fP.
If a shell function is being invoked, the
@@ -7417,7 +7449,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
@@ -7554,6 +7586,10 @@ Any command associated with the \fBRETURN\fP trap is executed
before execution resumes after the function or script.
.TP
\fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
.PD 0
.TP
\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\fP] [\fIarg\fP ...]
.PD
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.
@@ -7955,6 +7991,11 @@ The list of \fBshopt\fP options is:
.if n .sp 1v
.PD 0
.TP 8
.B autocd
If set, a command name that is the name of a directory is executed as if
it were the argument to the \fBcd\fP command.
This option is only used by interactive shells.
.TP 8
.B cdable_vars
If set, an argument to the
.B cd
@@ -7977,6 +8018,13 @@ If set, \fBbash\fP checks that a command found in the hash
table exists before trying to execute it. If a hashed command no
longer exists, a normal path search is performed.
.TP 8
.B checkjobs
If set, bash lists the status of any stopped and running jobs before
exiting an interactive shell. If any jobs are running, this causes
the exit to be deferred until a second exit is attempted without an
intervening command (see \fBJOB CONTROL\fP above). The shell always
postpones exiting if any jobs are stopped.
.TP 8
.B checkwinsize
If set, \fBbash\fP checks the window size after each command
and, if necessary, updates the values of
+349 -289
View File
@@ -562,7 +562,7 @@ fashion:
In a non-interactive shell, or an interactive shell in which the
@code{interactive_comments} option to the @code{shopt}
builtin is enabled (@pxref{Bash Builtins}),
builtin is enabled (@pxref{The Shopt Builtin}),
a word beginning with @samp{#}
causes that word and all remaining characters on that line to
be ignored. An interactive shell without the @code{interactive_comments}
@@ -848,7 +848,7 @@ The syntax of the @code{case} command is:
@code{case} will selectively execute the @var{command-list} corresponding to
the first @var{pattern} that matches @var{word}.
If the shell option @code{nocasematch}
(see the description of @code{shopt} in @ref{Bash Builtins})
(see the description of @code{shopt} in @ref{The Shopt Builtin})
is enabled, the match is performed without regard to the case
of alphabetic characters.
The @samp{|} is used to separate multiple patterns, and the @samp{)}
@@ -960,7 +960,7 @@ When the @samp{==} and @samp{!=} operators are used, the string to the
right of the operator is considered a pattern and matched according
to the rules described below in @ref{Pattern Matching}.
If the shell option @code{nocasematch}
(see the description of @code{shopt} in @ref{Bash Builtins})
(see the description of @code{shopt} in @ref{The Shopt Builtin})
is enabled, the match is performed without regard to the case
of alphabetic characters.
The return value is 0 if the string matches (@samp{==}) or does not
@@ -977,7 +977,7 @@ the pattern, and 1 otherwise.
If the regular expression is syntactically incorrect, the conditional
expression's return value is 2.
If the shell option @code{nocasematch}
(see the description of @code{shopt} in @ref{Bash Builtins})
(see the description of @code{shopt} in @ref{The Shopt Builtin})
is enabled, the match is performed without regard to the case
of alphabetic characters.
Substrings matched by parenthesized subexpressions within the regular
@@ -1785,13 +1785,15 @@ The shell scans the results of parameter expansion, command substitution,
and arithmetic expansion that did not occur within double quotes for
word splitting.
The shell treats each character of @env{$IFS}
as a delimiter, and splits the results of the other
expansions into words on these characters. If
@env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
the default, then any sequence of @env{IFS}
characters serves to delimit words. If @env{IFS}
has a value other than the default, then sequences of
The shell treats each character of @env{$IFS} as a delimiter, and splits
the results of the other expansions into words on these characters.
If @env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
the default, then sequences of
@code{ <space>}, @code{<tab>}, and @code{<newline>}
at the beginning and end of the results of the previous
expansions are ignored, and any sequence of @env{IFS}
characters not at the beginning or end serves to delimit words.
If @env{IFS} has a value other than the default, then sequences of
the whitespace characters @code{space} and @code{tab}
are ignored at the beginning and end of the
word, as long as the whitespace character is in the
@@ -1844,7 +1846,7 @@ When matching a file name, the slash character must always be
matched explicitly.
In other cases, the @samp{.} character is not treated specially.
See the description of @code{shopt} in @ref{Bash Builtins},
See the description of @code{shopt} in @ref{The Shopt Builtin},
for a description of the @code{nocaseglob}, @code{nullglob},
@code{failglob}, and @code{dotglob} options.
@@ -2355,7 +2357,7 @@ options enabled at invocation (either by default or with command-line
arguments) or by @code{set}
@item
options enabled by @code{shopt}
options enabled by @code{shopt} (@pxref{The Shopt Builtin})
@item
shell aliases defined with @code{alias} (@pxref{Aliases})
@@ -2512,7 +2514,7 @@ builtin (@pxref{Job Control Builtins}) or marked
to not receive @code{SIGHUP} using @code{disown -h}.
If the @code{huponexit} shell option has been set with @code{shopt}
(@pxref{Bash Builtins}), Bash sends a @code{SIGHUP} to all jobs when
(@pxref{The Shopt Builtin}), Bash sends a @code{SIGHUP} to all jobs when
an interactive login shell exits.
If Bash is waiting for a command to complete and receives a signal
@@ -2592,8 +2594,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:: Change the values of shell attributes and
positional parameters.
* Modifying Shell Behavior:: Builtins to modify shell attributes and
optional behavior.
* Special Builtins:: Builtin commands classified specially by
POSIX.
@end menu
@@ -2896,8 +2898,9 @@ shift [@var{n}]
@end example
Shift the positional parameters to the left by @var{n}.
The positional parameters from @var{n}+1 @dots{} @code{$#} are
renamed to @code{$1} @dots{} @code{$#}-@var{n}+1.
Parameters represented by the numbers @code{$#} to @var{n}+1 are unset.
renamed to @code{$1} @dots{} @code{$#}-@var{n}.
Parameters represented by the numbers @code{$#} to @code{$#}-@var{n}+1
are unset.
@var{n} must be a non-negative number less than or equal to @code{$#}.
If @var{n} is zero or greater than @code{$#}, the positional parameters
are not changed.
@@ -3018,7 +3021,7 @@ before every simple command, @code{for} command, @code{case} command,
@code{select} command, every arithmetic @code{for} command, and before
the first command executes in a shell function.
Refer to the description of the @code{extglob} option to the
@code{shopt} builtin (@pxref{Bash Builtins}) for details of its
@code{shopt} builtin (@pxref{The Shopt Builtin}) for details of its
effect on the @code{DEBUG} trap.
If a @var{sigspec} is @code{ERR}, the command @var{arg}
is executed whenever a simple command has a non-zero exit status,
@@ -3254,7 +3257,7 @@ When @option{-p} is used, additional options are ignored.
The @option{-F} option inhibits the display of function definitions;
only the function name and attributes are printed.
If the @code{extdebug} shell option is enabled using @code{shopt}
(@pxref{Bash Builtins}), the source file name and line number where
(@pxref{The Shopt Builtin}), the source file name and line number where
the function is defined are displayed as well.
@option{-F} implies @option{-f}.
The following options can be used to restrict output to variables with
@@ -3528,262 +3531,6 @@ Read input from file descriptor @var{fd}.
@end table
@item shopt
@btindex shopt
@example
shopt [-pqsu] [-o] [@var{optname} @dots{}]
@end example
Toggle the values of variables controlling optional shell behavior.
With no options, or with the @option{-p} option, a list of all settable
options is displayed, with an indication of whether or not each is set.
The @option{-p} option causes output to be displayed in a form that
may be reused as input.
Other options have the following meanings:
@table @code
@item -s
Enable (set) each @var{optname}.
@item -u
Disable (unset) each @var{optname}.
@item -q
Suppresses normal output; the return status
indicates whether the @var{optname} is set or unset.
If multiple @var{optname} arguments are given with @option{-q},
the return status is zero if all @var{optnames} are enabled;
non-zero otherwise.
@item -o
Restricts the values of
@var{optname} to be those defined for the @option{-o} option to the
@code{set} builtin (@pxref{The Set Builtin}).
@end table
If either @option{-s} or @option{-u}
is used with no @var{optname} arguments, the display is limited to
those options which are set or unset, respectively.
Unless otherwise noted, the @code{shopt} options are disabled (off)
by default.
The return status when listing options is zero if all @var{optnames}
are enabled, non-zero otherwise. When setting or unsetting options,
the return status is zero unless an @var{optname} is not a valid shell
option.
The list of @code{shopt} options is:
@table @code
@item cdable_vars
If this is set, an argument to the @code{cd}
builtin command that
is not a directory is assumed to be the name of a variable whose
value is the directory to change to.
@item cdspell
If set, minor errors in the spelling of a directory component in a
@code{cd} command will be corrected.
The errors checked for are transposed characters,
a missing character, and a character too many.
If a correction is found, the corrected path is printed,
and the command proceeds.
This option is only used by interactive shells.
@item checkhash
If this is set, Bash checks that a command found in the hash
table exists before trying to execute it. If a hashed command no
longer exists, a normal path search is performed.
@item checkwinsize
If set, Bash checks the window size after each command
and, if necessary, updates the values of
@env{LINES} and @env{COLUMNS}.
@item cmdhist
If set, Bash
attempts to save all lines of a multiple-line
command in the same history entry. This allows
easy re-editing of multi-line commands.
@item dotglob
If set, Bash includes filenames beginning with a `.' in
the results of filename expansion.
@item execfail
If this is set, a non-interactive shell will not exit if
it cannot execute the file specified as an argument to the @code{exec}
builtin command. An interactive shell does not exit if @code{exec}
fails.
@item expand_aliases
If set, aliases are expanded as described below under Aliases,
@ref{Aliases}.
This option is enabled by default for interactive shells.
@item extdebug
If set, behavior intended for use by debuggers is enabled:
@enumerate
@item
The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins})
displays the source file name and line number corresponding to each function
name supplied as an argument.
@item
If the command run by the @code{DEBUG} trap returns a non-zero value, the
next command is skipped and not executed.
@item
If the command run by the @code{DEBUG} trap returns a value of 2, and the
shell is executing in a subroutine (a shell function or a shell script
executed by the @code{.} or @code{source} builtins), a call to
@code{return} is simulated.
@item
@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
descriptions (@pxref{Bash Variables}).
@item
Function tracing is enabled: command substitution, shell functions, and
subshells invoked with @code{( @var{command} )} inherit the
@code{DEBUG} and @code{RETURN} traps.
@item
Error tracing is enabled: command substitution, shell functions, and
subshells invoked with @code{( @var{command} )} inherit the
@code{ERROR} trap.
@end enumerate
@item extglob
If set, the extended pattern matching features described above
(@pxref{Pattern Matching}) are enabled.
@item extquote
If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is
performed within @code{$@{@var{parameter}@}} expansions
enclosed in double quotes. This option is enabled by default.
@item failglob
If set, patterns which fail to match filenames during pathname expansion
result in an expansion error.
@item force_fignore
If set, the suffixes specified by the @env{FIGNORE} shell variable
cause words to be ignored when performing word completion even if
the ignored words are the only possible completions.
@xref{Bash Variables}, for a description of @env{FIGNORE}.
This option is enabled by default.
@item gnu_errfmt
If set, shell error messages are written in the standard @sc{gnu} error
message format.
@item histappend
If set, the history list is appended to the file named by the value
of the @env{HISTFILE}
variable when the shell exits, rather than overwriting the file.
@item histreedit
If set, and Readline
is being used, a user is given the opportunity to re-edit a
failed history substitution.
@item histverify
If set, and Readline
is being used, the results of history substitution are not immediately
passed to the shell parser. Instead, the resulting line is loaded into
the Readline editing buffer, allowing further modification.
@item hostcomplete
If set, and Readline is being used, Bash will attempt to perform
hostname completion when a word containing a @samp{@@} is being
completed (@pxref{Commands For Completion}). This option is enabled
by default.
@item huponexit
If set, Bash will send @code{SIGHUP} to all jobs when an interactive
login shell exits (@pxref{Signals}).
@item interactive_comments
Allow a word beginning with @samp{#}
to cause that word and all remaining characters on that
line to be ignored in an interactive shell.
This option is enabled by default.
@item lithist
If enabled, and the @code{cmdhist}
option is enabled, multi-line commands are saved to the history with
embedded newlines rather than using semicolon separators where possible.
@item login_shell
The shell sets this option if it is started as a login shell
(@pxref{Invoking Bash}).
The value may not be changed.
@item mailwarn
If set, and a file that Bash is checking for mail has been
accessed since the last time it was checked, the message
@code{"The mail in @var{mailfile} has been read"} is displayed.
@item no_empty_cmd_completion
If set, and Readline is being used, Bash will not attempt to search
the @env{PATH} for possible completions when completion is attempted
on an empty line.
@item nocaseglob
If set, Bash matches filenames in a case-insensitive fashion when
performing filename expansion.
@item nocasematch
If set, Bash matches patterns in a case-insensitive fashion when
performing matching while executing @code{case} or @code{[[}
conditional commands.
@item nullglob
If set, Bash allows filename patterns which match no
files to expand to a null string, rather than themselves.
@item progcomp
If set, the programmable completion facilities
(@pxref{Programmable Completion}) are enabled.
This option is enabled by default.
@item promptvars
If set, prompt strings undergo
parameter expansion, command substitution, arithmetic
expansion, and quote removal after being expanded
as described below (@pxref{Printing a Prompt}).
This option is enabled by default.
@item restricted_shell
The shell sets this option if it is started in restricted mode
(@pxref{The Restricted Shell}).
The value may not be changed.
This is not reset when the startup files are executed, allowing
the startup files to discover whether or not a shell is restricted.
@item shift_verbose
If this is set, the @code{shift}
builtin prints an error message when the shift count exceeds the
number of positional parameters.
@item sourcepath
If set, the @code{source} builtin uses the value of @env{PATH}
to find the directory containing the file supplied as an argument.
This option is enabled by default.
@item xpg_echo
If set, the @code{echo} builtin expands backslash-escape sequences
by default.
@end table
@noindent
The return status when listing options is zero if all @var{optnames}
are enabled, non-zero otherwise.
When setting or unsetting options, the return status is zero unless an
@var{optname} is not a valid shell option.
@item source
@btindex source
@example
@@ -3933,16 +3680,28 @@ Aliases are described in @ref{Aliases}.
@end table
@node The Set Builtin
@section The Set Builtin
@node Modifying Shell Behavior
@section Modifying Shell Behavior
@menu
* The Set Builtin:: Change the values of shell attributes and
positional parameters.
* The Shopt Builtin:: Modify shell optional behavior.
@end menu
This builtin is so complicated that it deserves its own section.
@node The Set Builtin
@subsection The Set Builtin
This builtin is so complicated that it deserves its own section. @code{set}
allows you to change the values of shell options and set the positional
parameters, or to display the names and values of shell variables.
@table @code
@item set
@btindex set
@example
set [--abefhkmnptuvxBCEHPT] [-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
@@ -4191,6 +3950,283 @@ The special parameter @code{#} is set to N.
The return status is always zero unless an invalid option is supplied.
@end table
@node The Shopt Builtin
@subsection The Shopt Builtin
This builtin allows you to change additional shell optional behavior.
@table @code
@item shopt
@btindex shopt
@example
shopt [-pqsu] [-o] [@var{optname} @dots{}]
@end example
Toggle the values of variables controlling optional shell behavior.
With no options, or with the @option{-p} option, a list of all settable
options is displayed, with an indication of whether or not each is set.
The @option{-p} option causes output to be displayed in a form that
may be reused as input.
Other options have the following meanings:
@table @code
@item -s
Enable (set) each @var{optname}.
@item -u
Disable (unset) each @var{optname}.
@item -q
Suppresses normal output; the return status
indicates whether the @var{optname} is set or unset.
If multiple @var{optname} arguments are given with @option{-q},
the return status is zero if all @var{optnames} are enabled;
non-zero otherwise.
@item -o
Restricts the values of
@var{optname} to be those defined for the @option{-o} option to the
@code{set} builtin (@pxref{The Set Builtin}).
@end table
If either @option{-s} or @option{-u}
is used with no @var{optname} arguments, the display is limited to
those options which are set or unset, respectively.
Unless otherwise noted, the @code{shopt} options are disabled (off)
by default.
The return status when listing options is zero if all @var{optnames}
are enabled, non-zero otherwise. When setting or unsetting options,
the return status is zero unless an @var{optname} is not a valid shell
option.
The list of @code{shopt} options is:
@table @code
@item autocd
If set, a command name that is the name of a directory is executed as if
it were the argument to the @code{cd} command.
This option is only used by interactive shells.
@item cdable_vars
If this is set, an argument to the @code{cd} builtin command that
is not a directory is assumed to be the name of a variable whose
value is the directory to change to.
@item cdspell
If set, minor errors in the spelling of a directory component in a
@code{cd} command will be corrected.
The errors checked for are transposed characters,
a missing character, and a character too many.
If a correction is found, the corrected path is printed,
and the command proceeds.
This option is only used by interactive shells.
@item checkhash
If this is set, Bash checks that a command found in the hash
table exists before trying to execute it. If a hashed command no
longer exists, a normal path search is performed.
@item checkjobs
If set, Bash lists the status of any stopped and running jobs before
exiting an interactive shell. If any jobs are running, this causes
the exit to be deferred until a second exit is attempted without an
intervening command (@pxref{Job Control}).
The shell always postpones exiting if any jobs are stopped.
@item checkwinsize
If set, Bash checks the window size after each command
and, if necessary, updates the values of
@env{LINES} and @env{COLUMNS}.
@item cmdhist
If set, Bash
attempts to save all lines of a multiple-line
command in the same history entry. This allows
easy re-editing of multi-line commands.
@item dotglob
If set, Bash includes filenames beginning with a `.' in
the results of filename expansion.
@item execfail
If this is set, a non-interactive shell will not exit if
it cannot execute the file specified as an argument to the @code{exec}
builtin command. An interactive shell does not exit if @code{exec}
fails.
@item expand_aliases
If set, aliases are expanded as described below under Aliases,
@ref{Aliases}.
This option is enabled by default for interactive shells.
@item extdebug
If set, behavior intended for use by debuggers is enabled:
@enumerate
@item
The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins})
displays the source file name and line number corresponding to each function
name supplied as an argument.
@item
If the command run by the @code{DEBUG} trap returns a non-zero value, the
next command is skipped and not executed.
@item
If the command run by the @code{DEBUG} trap returns a value of 2, and the
shell is executing in a subroutine (a shell function or a shell script
executed by the @code{.} or @code{source} builtins), a call to
@code{return} is simulated.
@item
@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
descriptions (@pxref{Bash Variables}).
@item
Function tracing is enabled: command substitution, shell functions, and
subshells invoked with @code{( @var{command} )} inherit the
@code{DEBUG} and @code{RETURN} traps.
@item
Error tracing is enabled: command substitution, shell functions, and
subshells invoked with @code{( @var{command} )} inherit the
@code{ERROR} trap.
@end enumerate
@item extglob
If set, the extended pattern matching features described above
(@pxref{Pattern Matching}) are enabled.
@item extquote
If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is
performed within @code{$@{@var{parameter}@}} expansions
enclosed in double quotes. This option is enabled by default.
@item failglob
If set, patterns which fail to match filenames during pathname expansion
result in an expansion error.
@item force_fignore
If set, the suffixes specified by the @env{FIGNORE} shell variable
cause words to be ignored when performing word completion even if
the ignored words are the only possible completions.
@xref{Bash Variables}, for a description of @env{FIGNORE}.
This option is enabled by default.
@item gnu_errfmt
If set, shell error messages are written in the standard @sc{gnu} error
message format.
@item histappend
If set, the history list is appended to the file named by the value
of the @env{HISTFILE}
variable when the shell exits, rather than overwriting the file.
@item histreedit
If set, and Readline
is being used, a user is given the opportunity to re-edit a
failed history substitution.
@item histverify
If set, and Readline
is being used, the results of history substitution are not immediately
passed to the shell parser. Instead, the resulting line is loaded into
the Readline editing buffer, allowing further modification.
@item hostcomplete
If set, and Readline is being used, Bash will attempt to perform
hostname completion when a word containing a @samp{@@} is being
completed (@pxref{Commands For Completion}). This option is enabled
by default.
@item huponexit
If set, Bash will send @code{SIGHUP} to all jobs when an interactive
login shell exits (@pxref{Signals}).
@item interactive_comments
Allow a word beginning with @samp{#}
to cause that word and all remaining characters on that
line to be ignored in an interactive shell.
This option is enabled by default.
@item lithist
If enabled, and the @code{cmdhist}
option is enabled, multi-line commands are saved to the history with
embedded newlines rather than using semicolon separators where possible.
@item login_shell
The shell sets this option if it is started as a login shell
(@pxref{Invoking Bash}).
The value may not be changed.
@item mailwarn
If set, and a file that Bash is checking for mail has been
accessed since the last time it was checked, the message
@code{"The mail in @var{mailfile} has been read"} is displayed.
@item no_empty_cmd_completion
If set, and Readline is being used, Bash will not attempt to search
the @env{PATH} for possible completions when completion is attempted
on an empty line.
@item nocaseglob
If set, Bash matches filenames in a case-insensitive fashion when
performing filename expansion.
@item nocasematch
If set, Bash matches patterns in a case-insensitive fashion when
performing matching while executing @code{case} or @code{[[}
conditional commands.
@item nullglob
If set, Bash allows filename patterns which match no
files to expand to a null string, rather than themselves.
@item progcomp
If set, the programmable completion facilities
(@pxref{Programmable Completion}) are enabled.
This option is enabled by default.
@item promptvars
If set, prompt strings undergo
parameter expansion, command substitution, arithmetic
expansion, and quote removal after being expanded
as described below (@pxref{Printing a Prompt}).
This option is enabled by default.
@item restricted_shell
The shell sets this option if it is started in restricted mode
(@pxref{The Restricted Shell}).
The value may not be changed.
This is not reset when the startup files are executed, allowing
the startup files to discover whether or not a shell is restricted.
@item shift_verbose
If this is set, the @code{shift}
builtin prints an error message when the shift count exceeds the
number of positional parameters.
@item sourcepath
If set, the @code{source} builtin uses the value of @env{PATH}
to find the directory containing the file supplied as an argument.
This option is enabled by default.
@item xpg_echo
If set, the @code{echo} builtin expands backslash-escape sequences
by default.
@end table
@noindent
The return status when listing options is zero if all @var{optnames}
are enabled, non-zero otherwise.
When setting or unsetting options, the return status is zero unless an
@var{optname} is not a valid shell option.
@end table
@node Special Builtins
@section Special Builtins
@cindex special builtin
@@ -4310,6 +4346,11 @@ variables for controlling the job control facilities
@item BASH
The full pathname used to execute the current instance of Bash.
@item BASHPID
Expands to the process id of the current Bash process.
This differs from @code{$$} under certain circumstances, such as subshells
that do not require Bash to be re-initialized.
@item BASH_ARGC
An array variable whose values are the number of parameters in each
frame of the current bash execution call stack. The number of
@@ -4318,7 +4359,7 @@ with @code{.} or @code{source}) is at the top of the stack. When a
subroutine is executed, the number of parameters passed is pushed onto
@code{BASH_ARGC}.
The shell sets @code{BASH_ARGC} only when in extended debugging mode
(see @ref{Bash Builtins}
(see @ref{The Shopt Builtin}
for a description of the @code{extdebug} option to the @code{shopt}
builtin).
@@ -4329,7 +4370,7 @@ is at the top of the stack; the first parameter of the initial call is
at the bottom. When a subroutine is executed, the parameters supplied
are pushed onto @code{BASH_ARGV}.
The shell sets @code{BASH_ARGV} only when in extended debugging mode
(see @ref{Bash Builtins}
(see @ref{The Shopt Builtin}
for a description of the @code{extdebug} option to the @code{shopt}
builtin).
@@ -4428,6 +4469,23 @@ This variable is available only in shell functions and external
commands invoked by the
programmable completion facilities (@pxref{Programmable Completion}).
@item COMP_TYPE
Set to an integer value corresponding to the type of completion attempted
that caused a completion function to be called:
@var{TAB}, for normal completion,
@samp{?}, for listing completions after successive tabs,
@samp{!}, for listing alternatives on partial word completion,
@samp{@@}, to list completions if the word is not unmodified,
or
@samp{%}, for menu completion.
This variable is available only in shell functions and external
commands invoked by the
programmable completion facilities (@pxref{Programmable Completion}).
@item COMP_KEY
The key (or final key of a key sequence) used to invoke the current
completion function.
@item COMP_WORDBREAKS
The set of characters that the Readline library treats as word
separators when performing word completion.
@@ -4858,7 +4916,7 @@ line before the single-character options to be recognized.
@table @code
@item --debugger
Arrange for the debugger profile to be executed before the shell
starts. Turns on extended debugging mode (see @ref{Bash Builtins}
starts. Turns on extended debugging mode (see @ref{The Shopt Builtin}
for a description of the @code{extdebug} option to the @code{shopt}
builtin) and shell function tracing
(see @ref{The Set Builtin} for a description of the @code{-o functrace}
@@ -4961,7 +5019,7 @@ This implies the @option{-n} option; no commands will be executed.
@item [-+]O [@var{shopt_option}]
@var{shopt_option} is one of the shell options accepted by the
@code{shopt} builtin (@pxref{Shell Builtin Commands}).
@code{shopt} builtin (@pxref{The Shopt Builtin}).
If @var{shopt_option} is present, @option{-O} sets the value of that option;
@option{+O} unsets it.
If @var{shopt_option} is not supplied, the names and values of the shell
@@ -5260,7 +5318,7 @@ Parser syntax errors will not cause the shell to exit.
@item
Simple spelling correction for directory arguments to the @code{cd}
builtin is enabled by default (see the description of the @code{cdspell}
option to the @code{shopt} builtin in @ref{Bash Builtins}).
option to the @code{shopt} builtin in @ref{The Shopt Builtin}).
@item
The shell will check the value of the @env{TMOUT} variable and exit
@@ -5544,7 +5602,7 @@ If arguments are needed, a shell function should be used
Aliases are not expanded when the shell is not interactive,
unless the @code{expand_aliases} shell option is set using
@code{shopt} (@pxref{Bash Builtins}).
@code{shopt} (@pxref{The Shopt Builtin}).
The rules concerning the definition and use of aliases are
somewhat confusing. Bash
@@ -6246,11 +6304,13 @@ Bash reports such changes immediately (@pxref{The Set Builtin}).
Any trap on @code{SIGCHLD} is executed for each child process
that exits.
If an attempt to exit Bash is made while jobs are stopped, the
shell prints a message warning that there are stopped jobs.
If an attempt to exit Bash is made while jobs are stopped, (or running, if
the @code{checkjobs} option is enabled -- see @ref{The Shopt Builtin}), the
shell prints a warning message, and if the @code{checkjobs} option is
enabled, lists the jobs and their statuses.
The @code{jobs} command may then be used to inspect their status.
If a second attempt to exit is made without an intervening command,
Bash does not print another warning, and the stopped jobs are terminated.
Bash does not print another warning, and any stopped jobs are terminated.
@node Job Control Builtins
@section Job Control Builtins
@@ -7233,7 +7293,7 @@ executed with the @code{.} or @code{source} builtins
@item
Bash includes the @code{shopt} builtin, for finer control of shell
optional capabilities (@pxref{Bash Builtins}), and allows these options
optional capabilities (@pxref{The Shopt Builtin}), and allows these options
to be set and unset at shell invocation (@pxref{Invoking Bash}).
@item
+591 -263
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+346 -290
View File
@@ -562,7 +562,7 @@ fashion:
In a non-interactive shell, or an interactive shell in which the
@code{interactive_comments} option to the @code{shopt}
builtin is enabled (@pxref{Bash Builtins}),
builtin is enabled (@pxref{The Shopt Builtin}),
a word beginning with @samp{#}
causes that word and all remaining characters on that line to
be ignored. An interactive shell without the @code{interactive_comments}
@@ -848,7 +848,7 @@ The syntax of the @code{case} command is:
@code{case} will selectively execute the @var{command-list} corresponding to
the first @var{pattern} that matches @var{word}.
If the shell option @code{nocasematch}
(see the description of @code{shopt} in @ref{Bash Builtins})
(see the description of @code{shopt} in @ref{The Shopt Builtin})
is enabled, the match is performed without regard to the case
of alphabetic characters.
The @samp{|} is used to separate multiple patterns, and the @samp{)}
@@ -960,7 +960,7 @@ When the @samp{==} and @samp{!=} operators are used, the string to the
right of the operator is considered a pattern and matched according
to the rules described below in @ref{Pattern Matching}.
If the shell option @code{nocasematch}
(see the description of @code{shopt} in @ref{Bash Builtins})
(see the description of @code{shopt} in @ref{The Shopt Builtin})
is enabled, the match is performed without regard to the case
of alphabetic characters.
The return value is 0 if the string matches (@samp{==}) or does not
@@ -977,7 +977,7 @@ the pattern, and 1 otherwise.
If the regular expression is syntactically incorrect, the conditional
expression's return value is 2.
If the shell option @code{nocasematch}
(see the description of @code{shopt} in @ref{Bash Builtins})
(see the description of @code{shopt} in @ref{The Shopt Builtin})
is enabled, the match is performed without regard to the case
of alphabetic characters.
Substrings matched by parenthesized subexpressions within the regular
@@ -1785,13 +1785,15 @@ The shell scans the results of parameter expansion, command substitution,
and arithmetic expansion that did not occur within double quotes for
word splitting.
The shell treats each character of @env{$IFS}
as a delimiter, and splits the results of the other
expansions into words on these characters. If
@env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
the default, then any sequence of @env{IFS}
characters serves to delimit words. If @env{IFS}
has a value other than the default, then sequences of
The shell treats each character of @env{$IFS} as a delimiter, and splits
the results of the other expansions into words on these characters.
If @env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
the default, then sequences of
@code{ <space>}, @code{<tab>}, and @code{<newline>}
at the beginning and end of the results of the previous
expansions are ignored, and any sequence of @env{IFS}
characters not at the beginning or end serves to delimit words.
If @env{IFS} has a value other than the default, then sequences of
the whitespace characters @code{space} and @code{tab}
are ignored at the beginning and end of the
word, as long as the whitespace character is in the
@@ -1844,7 +1846,7 @@ When matching a file name, the slash character must always be
matched explicitly.
In other cases, the @samp{.} character is not treated specially.
See the description of @code{shopt} in @ref{Bash Builtins},
See the description of @code{shopt} in @ref{The Shopt Builtin},
for a description of the @code{nocaseglob}, @code{nullglob},
@code{failglob}, and @code{dotglob} options.
@@ -2355,7 +2357,7 @@ options enabled at invocation (either by default or with command-line
arguments) or by @code{set}
@item
options enabled by @code{shopt}
options enabled by @code{shopt} (@pxref{The Shopt Builtin})
@item
shell aliases defined with @code{alias} (@pxref{Aliases})
@@ -2512,7 +2514,7 @@ builtin (@pxref{Job Control Builtins}) or marked
to not receive @code{SIGHUP} using @code{disown -h}.
If the @code{huponexit} shell option has been set with @code{shopt}
(@pxref{Bash Builtins}), Bash sends a @code{SIGHUP} to all jobs when
(@pxref{The Shopt Builtin}), Bash sends a @code{SIGHUP} to all jobs when
an interactive login shell exits.
If Bash is waiting for a command to complete and receives a signal
@@ -2592,8 +2594,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:: Change the values of shell attributes and
positional parameters.
* Modifying Shell Behavior:: Builtins to modify shell attributes and
optional behavior.
* Special Builtins:: Builtin commands classified specially by
POSIX.
@end menu
@@ -2896,8 +2898,9 @@ shift [@var{n}]
@end example
Shift the positional parameters to the left by @var{n}.
The positional parameters from @var{n}+1 @dots{} @code{$#} are
renamed to @code{$1} @dots{} @code{$#}-@var{n}+1.
Parameters represented by the numbers @code{$#} to @var{n}+1 are unset.
renamed to @code{$1} @dots{} @code{$#}-@var{n}.
Parameters represented by the numbers @code{$#} to @code{$#}-@var{n}+1
are unset.
@var{n} must be a non-negative number less than or equal to @code{$#}.
If @var{n} is zero or greater than @code{$#}, the positional parameters
are not changed.
@@ -3018,7 +3021,7 @@ before every simple command, @code{for} command, @code{case} command,
@code{select} command, every arithmetic @code{for} command, and before
the first command executes in a shell function.
Refer to the description of the @code{extglob} option to the
@code{shopt} builtin (@pxref{Bash Builtins}) for details of its
@code{shopt} builtin (@pxref{The Shopt Builtin}) for details of its
effect on the @code{DEBUG} trap.
If a @var{sigspec} is @code{ERR}, the command @var{arg}
is executed whenever a simple command has a non-zero exit status,
@@ -3254,7 +3257,7 @@ When @option{-p} is used, additional options are ignored.
The @option{-F} option inhibits the display of function definitions;
only the function name and attributes are printed.
If the @code{extdebug} shell option is enabled using @code{shopt}
(@pxref{Bash Builtins}), the source file name and line number where
(@pxref{The Shopt Builtin}), the source file name and line number where
the function is defined are displayed as well.
@option{-F} implies @option{-f}.
The following options can be used to restrict output to variables with
@@ -3356,7 +3359,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
@@ -3528,262 +3531,6 @@ Read input from file descriptor @var{fd}.
@end table
@item shopt
@btindex shopt
@example
shopt [-pqsu] [-o] [@var{optname} @dots{}]
@end example
Toggle the values of variables controlling optional shell behavior.
With no options, or with the @option{-p} option, a list of all settable
options is displayed, with an indication of whether or not each is set.
The @option{-p} option causes output to be displayed in a form that
may be reused as input.
Other options have the following meanings:
@table @code
@item -s
Enable (set) each @var{optname}.
@item -u
Disable (unset) each @var{optname}.
@item -q
Suppresses normal output; the return status
indicates whether the @var{optname} is set or unset.
If multiple @var{optname} arguments are given with @option{-q},
the return status is zero if all @var{optnames} are enabled;
non-zero otherwise.
@item -o
Restricts the values of
@var{optname} to be those defined for the @option{-o} option to the
@code{set} builtin (@pxref{The Set Builtin}).
@end table
If either @option{-s} or @option{-u}
is used with no @var{optname} arguments, the display is limited to
those options which are set or unset, respectively.
Unless otherwise noted, the @code{shopt} options are disabled (off)
by default.
The return status when listing options is zero if all @var{optnames}
are enabled, non-zero otherwise. When setting or unsetting options,
the return status is zero unless an @var{optname} is not a valid shell
option.
The list of @code{shopt} options is:
@table @code
@item cdable_vars
If this is set, an argument to the @code{cd}
builtin command that
is not a directory is assumed to be the name of a variable whose
value is the directory to change to.
@item cdspell
If set, minor errors in the spelling of a directory component in a
@code{cd} command will be corrected.
The errors checked for are transposed characters,
a missing character, and a character too many.
If a correction is found, the corrected path is printed,
and the command proceeds.
This option is only used by interactive shells.
@item checkhash
If this is set, Bash checks that a command found in the hash
table exists before trying to execute it. If a hashed command no
longer exists, a normal path search is performed.
@item checkwinsize
If set, Bash checks the window size after each command
and, if necessary, updates the values of
@env{LINES} and @env{COLUMNS}.
@item cmdhist
If set, Bash
attempts to save all lines of a multiple-line
command in the same history entry. This allows
easy re-editing of multi-line commands.
@item dotglob
If set, Bash includes filenames beginning with a `.' in
the results of filename expansion.
@item execfail
If this is set, a non-interactive shell will not exit if
it cannot execute the file specified as an argument to the @code{exec}
builtin command. An interactive shell does not exit if @code{exec}
fails.
@item expand_aliases
If set, aliases are expanded as described below under Aliases,
@ref{Aliases}.
This option is enabled by default for interactive shells.
@item extdebug
If set, behavior intended for use by debuggers is enabled:
@enumerate
@item
The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins})
displays the source file name and line number corresponding to each function
name supplied as an argument.
@item
If the command run by the @code{DEBUG} trap returns a non-zero value, the
next command is skipped and not executed.
@item
If the command run by the @code{DEBUG} trap returns a value of 2, and the
shell is executing in a subroutine (a shell function or a shell script
executed by the @code{.} or @code{source} builtins), a call to
@code{return} is simulated.
@item
@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
descriptions (@pxref{Bash Variables}).
@item
Function tracing is enabled: command substitution, shell functions, and
subshells invoked with @code{( @var{command} )} inherit the
@code{DEBUG} and @code{RETURN} traps.
@item
Error tracing is enabled: command substitution, shell functions, and
subshells invoked with @code{( @var{command} )} inherit the
@code{ERROR} trap.
@end enumerate
@item extglob
If set, the extended pattern matching features described above
(@pxref{Pattern Matching}) are enabled.
@item extquote
If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is
performed within @code{$@{@var{parameter}@}} expansions
enclosed in double quotes. This option is enabled by default.
@item failglob
If set, patterns which fail to match filenames during pathname expansion
result in an expansion error.
@item force_fignore
If set, the suffixes specified by the @env{FIGNORE} shell variable
cause words to be ignored when performing word completion even if
the ignored words are the only possible completions.
@xref{Bash Variables}, for a description of @env{FIGNORE}.
This option is enabled by default.
@item gnu_errfmt
If set, shell error messages are written in the standard @sc{gnu} error
message format.
@item histappend
If set, the history list is appended to the file named by the value
of the @env{HISTFILE}
variable when the shell exits, rather than overwriting the file.
@item histreedit
If set, and Readline
is being used, a user is given the opportunity to re-edit a
failed history substitution.
@item histverify
If set, and Readline
is being used, the results of history substitution are not immediately
passed to the shell parser. Instead, the resulting line is loaded into
the Readline editing buffer, allowing further modification.
@item hostcomplete
If set, and Readline is being used, Bash will attempt to perform
hostname completion when a word containing a @samp{@@} is being
completed (@pxref{Commands For Completion}). This option is enabled
by default.
@item huponexit
If set, Bash will send @code{SIGHUP} to all jobs when an interactive
login shell exits (@pxref{Signals}).
@item interactive_comments
Allow a word beginning with @samp{#}
to cause that word and all remaining characters on that
line to be ignored in an interactive shell.
This option is enabled by default.
@item lithist
If enabled, and the @code{cmdhist}
option is enabled, multi-line commands are saved to the history with
embedded newlines rather than using semicolon separators where possible.
@item login_shell
The shell sets this option if it is started as a login shell
(@pxref{Invoking Bash}).
The value may not be changed.
@item mailwarn
If set, and a file that Bash is checking for mail has been
accessed since the last time it was checked, the message
@code{"The mail in @var{mailfile} has been read"} is displayed.
@item no_empty_cmd_completion
If set, and Readline is being used, Bash will not attempt to search
the @env{PATH} for possible completions when completion is attempted
on an empty line.
@item nocaseglob
If set, Bash matches filenames in a case-insensitive fashion when
performing filename expansion.
@item nocasematch
If set, Bash matches patterns in a case-insensitive fashion when
performing matching while executing @code{case} or @code{[[}
conditional commands.
@item nullglob
If set, Bash allows filename patterns which match no
files to expand to a null string, rather than themselves.
@item progcomp
If set, the programmable completion facilities
(@pxref{Programmable Completion}) are enabled.
This option is enabled by default.
@item promptvars
If set, prompt strings undergo
parameter expansion, command substitution, arithmetic
expansion, and quote removal after being expanded
as described below (@pxref{Printing a Prompt}).
This option is enabled by default.
@item restricted_shell
The shell sets this option if it is started in restricted mode
(@pxref{The Restricted Shell}).
The value may not be changed.
This is not reset when the startup files are executed, allowing
the startup files to discover whether or not a shell is restricted.
@item shift_verbose
If this is set, the @code{shift}
builtin prints an error message when the shift count exceeds the
number of positional parameters.
@item sourcepath
If set, the @code{source} builtin uses the value of @env{PATH}
to find the directory containing the file supplied as an argument.
This option is enabled by default.
@item xpg_echo
If set, the @code{echo} builtin expands backslash-escape sequences
by default.
@end table
@noindent
The return status when listing options is zero if all @var{optnames}
are enabled, non-zero otherwise.
When setting or unsetting options, the return status is zero unless an
@var{optname} is not a valid shell option.
@item source
@btindex source
@example
@@ -3933,16 +3680,28 @@ Aliases are described in @ref{Aliases}.
@end table
@node The Set Builtin
@section The Set Builtin
@node Modifying Shell Behavior
@section Modifying Shell Behavior
@menu
* The Set Builtin:: Change the values of shell attributes and
positional parameters.
* The Shopt Builtin:: Modify shell optional behavior.
@end menu
This builtin is so complicated that it deserves its own section.
@node The Set Builtin
@subsection The Set Builtin
This builtin is so complicated that it deserves its own section. @code{set}
allows you to change the values of shell options and set the positional
parameters, or to display the names and values of shell variables.
@table @code
@item set
@btindex set
@example
set [--abefhkmnptuvxBCEHPT] [-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
@@ -4191,6 +3950,283 @@ The special parameter @code{#} is set to N.
The return status is always zero unless an invalid option is supplied.
@end table
@node The Shopt Builtin
@subsection The Shopt Builtin
This builtin allows you to change additional shell optional behavior.
@table @code
@item shopt
@btindex shopt
@example
shopt [-pqsu] [-o] [@var{optname} @dots{}]
@end example
Toggle the values of variables controlling optional shell behavior.
With no options, or with the @option{-p} option, a list of all settable
options is displayed, with an indication of whether or not each is set.
The @option{-p} option causes output to be displayed in a form that
may be reused as input.
Other options have the following meanings:
@table @code
@item -s
Enable (set) each @var{optname}.
@item -u
Disable (unset) each @var{optname}.
@item -q
Suppresses normal output; the return status
indicates whether the @var{optname} is set or unset.
If multiple @var{optname} arguments are given with @option{-q},
the return status is zero if all @var{optnames} are enabled;
non-zero otherwise.
@item -o
Restricts the values of
@var{optname} to be those defined for the @option{-o} option to the
@code{set} builtin (@pxref{The Set Builtin}).
@end table
If either @option{-s} or @option{-u}
is used with no @var{optname} arguments, the display is limited to
those options which are set or unset, respectively.
Unless otherwise noted, the @code{shopt} options are disabled (off)
by default.
The return status when listing options is zero if all @var{optnames}
are enabled, non-zero otherwise. When setting or unsetting options,
the return status is zero unless an @var{optname} is not a valid shell
option.
The list of @code{shopt} options is:
@table @code
@item autocd
If set, a command name that is the name of a directory is executed as if
it were the argument to the @code{cd} command.
This option is only used by interactive shells.
@item cdable_vars
If this is set, an argument to the @code{cd} builtin command that
is not a directory is assumed to be the name of a variable whose
value is the directory to change to.
@item cdspell
If set, minor errors in the spelling of a directory component in a
@code{cd} command will be corrected.
The errors checked for are transposed characters,
a missing character, and a character too many.
If a correction is found, the corrected path is printed,
and the command proceeds.
This option is only used by interactive shells.
@item checkhash
If this is set, Bash checks that a command found in the hash
table exists before trying to execute it. If a hashed command no
longer exists, a normal path search is performed.
@item checkjobs
If set, Bash lists the status of any stopped and running jobs before
exiting an interactive shell. If any jobs are running, this causes
the exit to be deferred until a second exit is attempted without an
intervening command (@pxref{Job Control}).
The shell always postpones exiting if any jobs are stopped.
@item checkwinsize
If set, Bash checks the window size after each command
and, if necessary, updates the values of
@env{LINES} and @env{COLUMNS}.
@item cmdhist
If set, Bash
attempts to save all lines of a multiple-line
command in the same history entry. This allows
easy re-editing of multi-line commands.
@item dotglob
If set, Bash includes filenames beginning with a `.' in
the results of filename expansion.
@item execfail
If this is set, a non-interactive shell will not exit if
it cannot execute the file specified as an argument to the @code{exec}
builtin command. An interactive shell does not exit if @code{exec}
fails.
@item expand_aliases
If set, aliases are expanded as described below under Aliases,
@ref{Aliases}.
This option is enabled by default for interactive shells.
@item extdebug
If set, behavior intended for use by debuggers is enabled:
@enumerate
@item
The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins})
displays the source file name and line number corresponding to each function
name supplied as an argument.
@item
If the command run by the @code{DEBUG} trap returns a non-zero value, the
next command is skipped and not executed.
@item
If the command run by the @code{DEBUG} trap returns a value of 2, and the
shell is executing in a subroutine (a shell function or a shell script
executed by the @code{.} or @code{source} builtins), a call to
@code{return} is simulated.
@item
@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their
descriptions (@pxref{Bash Variables}).
@item
Function tracing is enabled: command substitution, shell functions, and
subshells invoked with @code{( @var{command} )} inherit the
@code{DEBUG} and @code{RETURN} traps.
@item
Error tracing is enabled: command substitution, shell functions, and
subshells invoked with @code{( @var{command} )} inherit the
@code{ERROR} trap.
@end enumerate
@item extglob
If set, the extended pattern matching features described above
(@pxref{Pattern Matching}) are enabled.
@item extquote
If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is
performed within @code{$@{@var{parameter}@}} expansions
enclosed in double quotes. This option is enabled by default.
@item failglob
If set, patterns which fail to match filenames during pathname expansion
result in an expansion error.
@item force_fignore
If set, the suffixes specified by the @env{FIGNORE} shell variable
cause words to be ignored when performing word completion even if
the ignored words are the only possible completions.
@xref{Bash Variables}, for a description of @env{FIGNORE}.
This option is enabled by default.
@item gnu_errfmt
If set, shell error messages are written in the standard @sc{gnu} error
message format.
@item histappend
If set, the history list is appended to the file named by the value
of the @env{HISTFILE}
variable when the shell exits, rather than overwriting the file.
@item histreedit
If set, and Readline
is being used, a user is given the opportunity to re-edit a
failed history substitution.
@item histverify
If set, and Readline
is being used, the results of history substitution are not immediately
passed to the shell parser. Instead, the resulting line is loaded into
the Readline editing buffer, allowing further modification.
@item hostcomplete
If set, and Readline is being used, Bash will attempt to perform
hostname completion when a word containing a @samp{@@} is being
completed (@pxref{Commands For Completion}). This option is enabled
by default.
@item huponexit
If set, Bash will send @code{SIGHUP} to all jobs when an interactive
login shell exits (@pxref{Signals}).
@item interactive_comments
Allow a word beginning with @samp{#}
to cause that word and all remaining characters on that
line to be ignored in an interactive shell.
This option is enabled by default.
@item lithist
If enabled, and the @code{cmdhist}
option is enabled, multi-line commands are saved to the history with
embedded newlines rather than using semicolon separators where possible.
@item login_shell
The shell sets this option if it is started as a login shell
(@pxref{Invoking Bash}).
The value may not be changed.
@item mailwarn
If set, and a file that Bash is checking for mail has been
accessed since the last time it was checked, the message
@code{"The mail in @var{mailfile} has been read"} is displayed.
@item no_empty_cmd_completion
If set, and Readline is being used, Bash will not attempt to search
the @env{PATH} for possible completions when completion is attempted
on an empty line.
@item nocaseglob
If set, Bash matches filenames in a case-insensitive fashion when
performing filename expansion.
@item nocasematch
If set, Bash matches patterns in a case-insensitive fashion when
performing matching while executing @code{case} or @code{[[}
conditional commands.
@item nullglob
If set, Bash allows filename patterns which match no
files to expand to a null string, rather than themselves.
@item progcomp
If set, the programmable completion facilities
(@pxref{Programmable Completion}) are enabled.
This option is enabled by default.
@item promptvars
If set, prompt strings undergo
parameter expansion, command substitution, arithmetic
expansion, and quote removal after being expanded
as described below (@pxref{Printing a Prompt}).
This option is enabled by default.
@item restricted_shell
The shell sets this option if it is started in restricted mode
(@pxref{The Restricted Shell}).
The value may not be changed.
This is not reset when the startup files are executed, allowing
the startup files to discover whether or not a shell is restricted.
@item shift_verbose
If this is set, the @code{shift}
builtin prints an error message when the shift count exceeds the
number of positional parameters.
@item sourcepath
If set, the @code{source} builtin uses the value of @env{PATH}
to find the directory containing the file supplied as an argument.
This option is enabled by default.
@item xpg_echo
If set, the @code{echo} builtin expands backslash-escape sequences
by default.
@end table
@noindent
The return status when listing options is zero if all @var{optnames}
are enabled, non-zero otherwise.
When setting or unsetting options, the return status is zero unless an
@var{optname} is not a valid shell option.
@end table
@node Special Builtins
@section Special Builtins
@cindex special builtin
@@ -4310,6 +4346,11 @@ variables for controlling the job control facilities
@item BASH
The full pathname used to execute the current instance of Bash.
@item BASHPID
Expands to the process id of the current Bash process.
This differs from @code{$$} under certain circumstances, such as subshells
that do not require Bash to be re-initialized.
@item BASH_ARGC
An array variable whose values are the number of parameters in each
frame of the current bash execution call stack. The number of
@@ -4318,7 +4359,7 @@ with @code{.} or @code{source}) is at the top of the stack. When a
subroutine is executed, the number of parameters passed is pushed onto
@code{BASH_ARGC}.
The shell sets @code{BASH_ARGC} only when in extended debugging mode
(see @ref{Bash Builtins}
(see @ref{The Shopt Builtin}
for a description of the @code{extdebug} option to the @code{shopt}
builtin).
@@ -4329,7 +4370,7 @@ is at the top of the stack; the first parameter of the initial call is
at the bottom. When a subroutine is executed, the parameters supplied
are pushed onto @code{BASH_ARGV}.
The shell sets @code{BASH_ARGV} only when in extended debugging mode
(see @ref{Bash Builtins}
(see @ref{The Shopt Builtin}
for a description of the @code{extdebug} option to the @code{shopt}
builtin).
@@ -4428,6 +4469,19 @@ This variable is available only in shell functions and external
commands invoked by the
programmable completion facilities (@pxref{Programmable Completion}).
@item COMP_TYPE
Set to an integer value corresponding to the type of completion attempted
that caused a completion function to be called:
@var{TAB}, for normal completion,
@samp{?}, for listing completions after successive tabs,
@samp{!}, for listing alternatives on partial word completion,
@samp{@@}, to list completions if the word is not unmodified,
or
@samp{%}, for menu completion.
This variable is available only in shell functions and external
commands invoked by the
programmable completion facilities (@pxref{Programmable Completion}).
@item COMP_WORDBREAKS
The set of characters that the Readline library treats as word
separators when performing word completion.
@@ -4858,7 +4912,7 @@ line before the single-character options to be recognized.
@table @code
@item --debugger
Arrange for the debugger profile to be executed before the shell
starts. Turns on extended debugging mode (see @ref{Bash Builtins}
starts. Turns on extended debugging mode (see @ref{The Shopt Builtin}
for a description of the @code{extdebug} option to the @code{shopt}
builtin) and shell function tracing
(see @ref{The Set Builtin} for a description of the @code{-o functrace}
@@ -4961,7 +5015,7 @@ This implies the @option{-n} option; no commands will be executed.
@item [-+]O [@var{shopt_option}]
@var{shopt_option} is one of the shell options accepted by the
@code{shopt} builtin (@pxref{Shell Builtin Commands}).
@code{shopt} builtin (@pxref{The Shopt Builtin}).
If @var{shopt_option} is present, @option{-O} sets the value of that option;
@option{+O} unsets it.
If @var{shopt_option} is not supplied, the names and values of the shell
@@ -5260,7 +5314,7 @@ Parser syntax errors will not cause the shell to exit.
@item
Simple spelling correction for directory arguments to the @code{cd}
builtin is enabled by default (see the description of the @code{cdspell}
option to the @code{shopt} builtin in @ref{Bash Builtins}).
option to the @code{shopt} builtin in @ref{The Shopt Builtin}).
@item
The shell will check the value of the @env{TMOUT} variable and exit
@@ -5544,7 +5598,7 @@ If arguments are needed, a shell function should be used
Aliases are not expanded when the shell is not interactive,
unless the @code{expand_aliases} shell option is set using
@code{shopt} (@pxref{Bash Builtins}).
@code{shopt} (@pxref{The Shopt Builtin}).
The rules concerning the definition and use of aliases are
somewhat confusing. Bash
@@ -6246,11 +6300,13 @@ Bash reports such changes immediately (@pxref{The Set Builtin}).
Any trap on @code{SIGCHLD} is executed for each child process
that exits.
If an attempt to exit Bash is made while jobs are stopped, the
shell prints a message warning that there are stopped jobs.
If an attempt to exit Bash is made while jobs are stopped, (or running, if
the @code{checkjobs} option is enabled -- see @ref{The Shopt Builtin}), the
shell prints a warning message, and if the @code{checkjobs} option is
enabled, lists the jobs and their statuses.
The @code{jobs} command may then be used to inspect their status.
If a second attempt to exit is made without an intervening command,
Bash does not print another warning, and the stopped jobs are terminated.
Bash does not print another warning, and any stopped jobs are terminated.
@node Job Control Builtins
@section Job Control Builtins
@@ -7233,7 +7289,7 @@ executed with the @code{.} or @code{source} builtins
@item
Bash includes the @code{shopt} builtin, for finer control of shell
optional capabilities (@pxref{Bash Builtins}), and allows these options
optional capabilities (@pxref{The Shopt Builtin}), and allows these options
to be set and unset at shell invocation (@pxref{Invoking Bash}).
@item
+3 -3
View File
@@ -2,9 +2,9 @@
Copyright (C) 1988-2006 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Mon Nov 27 12:02:15 EST 2006
@set LASTCHANGE Sat Dec 30 19:31:54 EST 2006
@set EDITION 3.2
@set VERSION 3.2
@set UPDATED 27 November 2006
@set UPDATED-MONTH November 2006
@set UPDATED 30 December 2006
@set UPDATED-MONTH December 2006
+3 -3
View File
@@ -2,9 +2,9 @@
Copyright (C) 1988-2006 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Wed Nov 8 11:21:28 EST 2006
@set LASTCHANGE Tue Dec 26 16:58:41 EST 2006
@set EDITION 3.2
@set VERSION 3.2
@set UPDATED 8 November 2006
@set UPDATED-MONTH November 2006
@set UPDATED 26 December 2006
@set UPDATED-MONTH December 2006
+3 -3
View File
@@ -59,7 +59,7 @@ extern int give_terminal_to __P((pid_t, int));
#endif /* JOB_CONTROL */
#if defined (ARRAY_VARS)
extern char *bash_badsub_errmsg;
extern const char * const bash_badsub_errmsg;
#endif
static void error_prolog __P((int));
@@ -70,7 +70,7 @@ static void error_prolog __P((int));
#define MAINTAINER "bash-maintainers@gnu.org"
#endif
char *the_current_maintainer = MAINTAINER;
const char * const the_current_maintainer = MAINTAINER;
int gnu_error_format = 0;
@@ -399,7 +399,7 @@ trace (format, va_alist)
/* **************************************************************** */
static char *cmd_error_table[] = {
static const char * const cmd_error_table[] = {
N_("unknown command error"), /* CMDERR_DEFAULT */
N_("bad command type"), /* CMDERR_BADTYPE */
N_("bad connector"), /* CMDERR_BADCONN */
+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);
+24 -4
View File
@@ -96,8 +96,9 @@ extern int errno;
#endif
extern int posixly_correct;
extern int breaking, continuing, loop_level;
extern int expand_aliases;
extern int autocd;
extern int breaking, continuing, loop_level;
extern int parse_and_execute_level, running_trap;
extern int command_string_index, line_number;
extern int dot_found_in_search;
@@ -907,7 +908,7 @@ extern int timeval_to_cpu __P((struct timeval *, struct timeval *, struct timeva
#define POSIX_TIMEFORMAT "real %2R\nuser %2U\nsys %2S"
#define BASH_TIMEFORMAT "\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS"
static int precs[] = { 0, 100, 10, 1 };
static const int precs[] = { 0, 100, 10, 1 };
/* Expand one `%'-prefixed escape sequence from a time format string. */
static int
@@ -2496,7 +2497,7 @@ execute_arith_command (arith_command)
#if defined (COND_COMMAND)
static char *nullstr = "";
static char * const nullstr = "";
static int
execute_cond_node (cond)
@@ -2743,6 +2744,17 @@ fix_assignment_words (words)
}
}
/* Return 1 if the file found by searching $PATH for PATHNAME, defaulting
to PATHNAME, is a directory. Used by the autocd code below. */
static int
is_dirname (pathname)
char *pathname;
{
char *temp;
temp = search_for_command (pathname);
return (temp ? file_isdir (temp) : file_isdir (pathname));
}
/* The meaty part of all the executions. We have to start hacking the
real execution of commands here. Fork a process, set things up,
execute the command. */
@@ -2792,7 +2804,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
#endif
first_word_quoted =
simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0;
simple_command->words ? (simple_command->words->word->flags & W_QUOTED) : 0;
last_command_subst_pid = NO_PID;
old_last_async_pid = last_asynchronous_pid;
@@ -2975,6 +2987,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
}
#endif /* JOB_CONTROL */
run_builtin:
/* Remember the name of this command globally. */
this_command_name = words->word->word;
@@ -3048,6 +3061,13 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
}
}
if (autocd && interactive && words->word && is_dirname (words->word->word))
{
words = make_word_list (make_word ("cd"), words);
xtrace_print_word_list (words, 0);
goto run_builtin;
}
if (command_line == 0)
command_line = savestring (the_printed_command_except_trap);
+24 -4
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.
@@ -96,8 +96,9 @@ extern int errno;
#endif
extern int posixly_correct;
extern int breaking, continuing, loop_level;
extern int expand_aliases;
extern int autocd;
extern int breaking, continuing, loop_level;
extern int parse_and_execute_level, running_trap;
extern int command_string_index, line_number;
extern int dot_found_in_search;
@@ -1396,7 +1397,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 ();
@@ -2743,6 +2744,17 @@ fix_assignment_words (words)
}
}
/* Return 1 if the file found by searching $PATH for PATHNAME, defaulting
to PATHNAME, is a directory. Used by the autocd code below. */
static int
is_dirname (pathname)
char *pathname;
{
char *temp;
temp = search_for_command (pathname);
return (temp ? file_isdir (temp) : file_isdir (pathname));
}
/* The meaty part of all the executions. We have to start hacking the
real execution of commands here. Fork a process, set things up,
execute the command. */
@@ -2792,7 +2804,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
#endif
first_word_quoted =
simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0;
simple_command->words ? (simple_command->words->word->flags & W_QUOTED) : 0;
last_command_subst_pid = NO_PID;
old_last_async_pid = last_asynchronous_pid;
@@ -2975,6 +2987,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
}
#endif /* JOB_CONTROL */
run_builtin:
/* Remember the name of this command globally. */
this_command_name = words->word->word;
@@ -3048,6 +3061,13 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
}
}
if (autocd && interactive && words->word && is_dirname (words->word->word))
{
words = make_word_list (make_word ("cd"), words);
xtrace_print_word_list (words, 0);
goto run_builtin;
}
if (command_line == 0)
command_line = savestring (the_printed_command_except_trap);
+3 -3
View File
@@ -153,7 +153,7 @@ static void readtok __P((void)); /* lexical analyzer */
static intmax_t expr_streval __P((char *, int));
static intmax_t strlong __P((char *));
static void evalerror __P((char *));
static void evalerror __P((const char *));
static void pushexp __P((void));
static void popexp __P((void));
@@ -205,7 +205,7 @@ extern char *this_command_name;
extern int unbound_vars_is_error;
#if defined (ARRAY_VARS)
extern char *bash_badsub_errmsg;
extern const char * const bash_badsub_errmsg;
#endif
#define SAVETOK(X) \
@@ -1187,7 +1187,7 @@ readtok ()
static void
evalerror (msg)
char *msg;
const char *msg;
{
char *name, *t;
+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);
}
+1 -1
View File
@@ -170,7 +170,7 @@ int pipefail_opt = 0;
/* */
/* **************************************************************** */
struct flags_alist shell_flags[] = {
const struct flags_alist shell_flags[] = {
/* Standard sh flags. */
{ 'a', &mark_modified_vars },
#if defined (JOB_CONTROL)
+355
View File
@@ -0,0 +1,355 @@
/* flags.c -- Everything about flags except the `set' command. That
is in builtins.c */
/* Copyright (C) 1987,1989 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. */
/* Flags hacking. */
#include "config.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "shell.h"
#include "flags.h"
#if defined (BANG_HISTORY)
# include "bashhist.h"
#endif
#if defined (JOB_CONTROL)
extern int set_job_control __P((int));
#endif
#if defined (RESTRICTED_SHELL)
extern char *shell_name;
#endif
extern int shell_initialized;
/* -c, -s invocation options -- not really flags, but they show up in $- */
extern int want_pending_command, read_from_stdin;
/* **************************************************************** */
/* */
/* The Standard Sh Flags. */
/* */
/* **************************************************************** */
/* Non-zero means automatically mark variables which are modified or created
as auto export variables. */
int mark_modified_vars = 0;
/* Non-zero causes asynchronous job notification. Otherwise, job state
notification only takes place just before a primary prompt is printed. */
int asynchronous_notification = 0;
/* Non-zero means exit immediately if a command exits with a non-zero
exit status. */
int exit_immediately_on_error = 0;
/* Non-zero means disable filename globbing. */
int disallow_filename_globbing = 0;
/* Non-zero means that all keyword arguments are placed into the environment
for a command, not just those that appear on the line before the command
name. */
int place_keywords_in_env = 0;
/* Non-zero means read commands, but don't execute them. This is useful
for debugging shell scripts that should do something hairy and possibly
destructive. */
int read_but_dont_execute = 0;
/* Non-zero means end of file is after one command. */
int just_one_command = 0;
/* Non-zero means don't overwrite existing files while doing redirections. */
int noclobber = 0;
/* Non-zero means trying to get the value of $i where $i is undefined
causes an error, instead of a null substitution. */
int unbound_vars_is_error = 0;
/* Non-zero means type out input lines after you read them. */
int echo_input_at_read = 0;
/* Non-zero means type out the command definition after reading, but
before executing. */
int echo_command_at_execute = 0;
/* Non-zero means turn on the job control features. */
int jobs_m_flag = 0;
/* Non-zero means this shell is interactive, even if running under a
pipe. */
int forced_interactive = 0;
/* By default, follow the symbolic links as if they were real directories
while hacking the `cd' command. This means that `cd ..' moves up in
the string of symbolic links that make up the current directory, instead
of the absolute directory. The shell variable `nolinks' also controls
this flag. */
int no_symbolic_links = 0;
/* **************************************************************** */
/* */
/* Non-Standard Flags Follow Here. */
/* */
/* **************************************************************** */
#if 0
/* Non-zero means do lexical scoping in the body of a FOR command. */
int lexical_scoping = 0;
#endif
/* Non-zero means no such thing as invisible variables. */
int no_invisible_vars = 0;
/* Non-zero means look up and remember command names in a hash table, */
int hashing_enabled = 1;
#if defined (BANG_HISTORY)
/* Non-zero means that we are doing history expansion. The default.
This means !22 gets the 22nd line of history. */
int history_expansion = 1;
#endif /* BANG_HISTORY */
/* Non-zero means that we allow comments to appear in interactive commands. */
int interactive_comments = 1;
#if defined (RESTRICTED_SHELL)
/* Non-zero means that this shell is `restricted'. A restricted shell
disallows: changing directories, command or path names containing `/',
unsetting or resetting the values of $PATH and $SHELL, and any type of
output redirection. */
int restricted = 0; /* currently restricted */
int restricted_shell = 0; /* shell was started in restricted mode. */
#endif /* RESTRICTED_SHELL */
/* Non-zero means that this shell is running in `privileged' mode. This
is required if the shell is to run setuid. If the `-p' option is
not supplied at startup, and the real and effective uids or gids
differ, disable_priv_mode is called to relinquish setuid status. */
int privileged_mode = 0;
#if defined (BRACE_EXPANSION)
/* Zero means to disable brace expansion: foo{a,b} -> fooa foob */
int brace_expansion = 1;
#endif
/* Non-zero means that shell functions inherit the DEBUG trap. */
int function_trace_mode = 0;
/* Non-zero means that shell functions inherit the ERR trap. */
int error_trace_mode = 0;
/* Non-zero means that the rightmost non-zero exit status in a pipeline
is the exit status of the entire pipeline. If each processes exits
with a 0 status, the status of the pipeline is 0. */
int pipefail_opt = 0;
/* **************************************************************** */
/* */
/* The Flags ALIST. */
/* */
/* **************************************************************** */
struct flags_alist shell_flags[] = {
/* Standard sh flags. */
{ 'a', &mark_modified_vars },
#if defined (JOB_CONTROL)
{ 'b', &asynchronous_notification },
#endif /* JOB_CONTROL */
{ 'e', &exit_immediately_on_error },
{ 'f', &disallow_filename_globbing },
{ 'h', &hashing_enabled },
{ 'i', &forced_interactive },
{ 'k', &place_keywords_in_env },
#if defined (JOB_CONTROL)
{ 'm', &jobs_m_flag },
#endif /* JOB_CONTROL */
{ 'n', &read_but_dont_execute },
{ 'p', &privileged_mode },
#if defined (RESTRICTED_SHELL)
{ 'r', &restricted },
#endif /* RESTRICTED_SHELL */
{ 't', &just_one_command },
{ 'u', &unbound_vars_is_error },
{ 'v', &echo_input_at_read },
{ 'x', &echo_command_at_execute },
/* New flags that control non-standard things. */
#if 0
{ 'l', &lexical_scoping },
#endif
#if defined (BRACE_EXPANSION)
{ 'B', &brace_expansion },
#endif
{ 'C', &noclobber },
{ 'E', &error_trace_mode },
#if defined (BANG_HISTORY)
{ 'H', &history_expansion },
#endif /* BANG_HISTORY */
{ 'I', &no_invisible_vars },
{ 'P', &no_symbolic_links },
{ 'T', &function_trace_mode },
{0, (int *)NULL}
};
#define NUM_SHELL_FLAGS (sizeof (shell_flags) / sizeof (struct flags_alist))
char optflags[NUM_SHELL_FLAGS+4] = { '+' };
int *
find_flag (name)
int name;
{
int i;
for (i = 0; shell_flags[i].name; i++)
{
if (shell_flags[i].name == name)
return (shell_flags[i].value);
}
return (FLAG_UNKNOWN);
}
/* Change the state of a flag, and return it's original value, or return
FLAG_ERROR if there is no flag FLAG. ON_OR_OFF must be either
FLAG_ON or FLAG_OFF. */
int
change_flag (flag, on_or_off)
int flag;
int on_or_off;
{
int *value, old_value;
#if defined (RESTRICTED_SHELL)
/* Don't allow "set +r" in a shell which is `restricted'. */
if (restricted && flag == 'r' && on_or_off == FLAG_OFF)
return (FLAG_ERROR);
#endif /* RESTRICTED_SHELL */
value = find_flag (flag);
if ((value == (int *)FLAG_UNKNOWN) || (on_or_off != FLAG_ON && on_or_off != FLAG_OFF))
return (FLAG_ERROR);
old_value = *value;
*value = (on_or_off == FLAG_ON) ? 1 : 0;
/* Special cases for a few flags. */
switch (flag)
{
#if defined (BANG_HISTORY)
case 'H':
if (on_or_off == FLAG_ON)
bash_initialize_history ();
break;
#endif
#if defined (JOB_CONTROL)
case 'm':
set_job_control (on_or_off == FLAG_ON);
break;
#endif /* JOB_CONTROL */
case 'n':
if (interactive_shell)
read_but_dont_execute = 0;
break;
case 'p':
if (on_or_off == FLAG_OFF)
disable_priv_mode ();
break;
#if defined (RESTRICTED_SHELL)
case 'r':
if (on_or_off == FLAG_ON && shell_initialized)
maybe_make_restricted (shell_name);
break;
#endif
}
return (old_value);
}
/* Return a string which is the names of all the currently
set shell flags. */
char *
which_set_flags ()
{
char *temp;
int i, string_index;
temp = (char *)xmalloc (1 + NUM_SHELL_FLAGS + read_from_stdin + want_pending_command);
for (i = string_index = 0; shell_flags[i].name; i++)
if (*(shell_flags[i].value))
temp[string_index++] = shell_flags[i].name;
if (want_pending_command)
temp[string_index++] = 'c';
if (read_from_stdin)
temp[string_index++] = 's';
temp[string_index] = '\0';
return (temp);
}
void
reset_shell_flags ()
{
mark_modified_vars = exit_immediately_on_error = disallow_filename_globbing = 0;
place_keywords_in_env = read_but_dont_execute = just_one_command = 0;
noclobber = unbound_vars_is_error = echo_input_at_read = 0;
echo_command_at_execute = jobs_m_flag = forced_interactive = 0;
no_symbolic_links = no_invisible_vars = privileged_mode = pipefail_opt = 0;
hashing_enabled = interactive_comments = 1;
#if defined (JOB_CONTROL)
asynchronous_notification = 0;
#endif
#if defined (BANG_HISTORY)
history_expansion = 1;
#endif
#if defined (BRACE_EXPANSION)
brace_expansion = 1;
#endif
#if defined (RESTRICTED_SHELL)
restricted = 0;
#endif
}
void
initialize_flags ()
{
register int i;
for (i = 0; shell_flags[i].name; i++)
optflags[i+1] = shell_flags[i].name;
optflags[++i] = 'o';
optflags[++i] = ';';
optflags[i+1] = '\0';
}
+1 -1
View File
@@ -37,7 +37,7 @@ struct flags_alist {
int *value;
};
extern struct flags_alist shell_flags[];
extern const struct flags_alist shell_flags[];
extern char optflags[];
extern int
+79
View File
@@ -0,0 +1,79 @@
/* flags.h -- a list of all the flags that the shell knows about. You add
a flag to this program by adding the name here, and in flags.c. */
/* Copyright (C) 1993 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 (_FLAGS_H_)
#define _FLAGS_H_
#include "stdc.h"
/* Welcome to the world of Un*x, where everything is slightly backwards. */
#define FLAG_ON '-'
#define FLAG_OFF '+'
#define FLAG_ERROR -1
#define FLAG_UNKNOWN (int *)0
/* The thing that we build the array of flags out of. */
struct flags_alist {
char name;
int *value;
};
extern struct flags_alist shell_flags[];
extern char optflags[];
extern int
mark_modified_vars, exit_immediately_on_error, disallow_filename_globbing,
place_keywords_in_env, read_but_dont_execute,
just_one_command, unbound_vars_is_error, echo_input_at_read,
echo_command_at_execute, no_invisible_vars, noclobber,
hashing_enabled, forced_interactive, privileged_mode,
asynchronous_notification, interactive_comments, no_symbolic_links,
function_trace_mode, error_trace_mode, pipefail_opt;
#if 0
extern int lexical_scoping;
#endif
#if defined (BRACE_EXPANSION)
extern int brace_expansion;
#endif
#if defined (BANG_HISTORY)
extern int history_expansion;
#endif /* BANG_HISTORY */
#if defined (RESTRICTED_SHELL)
extern int restricted;
extern int restricted_shell;
#endif /* RESTRICTED_SHELL */
extern int *find_flag __P((int));
extern int change_flag __P((int, int));
extern char *which_set_flags __P((void));
extern void reset_shell_flags __P((void));
extern void initialize_flags __P((void));
/* A macro for efficiency. */
#define change_flag_char(flag, on_or_off) change_flag (flag, on_or_off)
#endif /* _FLAGS_H_ */
+1 -1
View File
@@ -58,7 +58,7 @@ static int unquoted_tilde_word __P((const char *));
static void initialize_group_array __P((void));
/* A standard error message to use when getcwd() returns NULL. */
char *bash_getcwd_errstr = N_("getcwd: cannot access parent directories");
const char * const bash_getcwd_errstr = N_("getcwd: cannot access parent directories");
/* Do whatever is necessary to initialize `Posix mode'. */
void
+1 -1
View File
@@ -161,7 +161,7 @@ all_digits (string)
not null. */
int
legal_number (string, result)
char *string;
const char *string;
intmax_t *result;
{
intmax_t value;
+1 -1
View File
@@ -74,7 +74,7 @@ typedef struct process {
#define get_job_by_jid(ind) (jobs[(ind)])
/* A description of a pipeline's state. */
typedef enum { JRUNNING, JSTOPPED, JDEAD, JMIXED } JOB_STATE;
typedef enum { JRUNNING = 1, JSTOPPED = 2, JDEAD = 4, JMIXED = 8 } JOB_STATE;
#define JOBSTATE(job) (jobs[(job)]->state)
#define J_JOBSTATE(j) ((j)->state)
+5 -3
View File
@@ -20,9 +20,11 @@
#include "stdc.h"
#define GX_MARKDIRS 0x01 /* mark directory names with trailing `/' */
#define GX_NOCASE 0x02 /* ignore case */
#define GX_MATCHDOT 0x04 /* match `.' literally */
#define GX_MARKDIRS 0x001 /* mark directory names with trailing `/' */
#define GX_NOCASE 0x002 /* ignore case */
#define GX_MATCHDOT 0x004 /* match `.' literally */
#define GX_ALLDIRS 0x008 /* match all directories */
#define GX_MATCHDIRS 0x010 /* return only matching directory names */
extern int glob_pattern_p __P((const char *));
extern char **glob_vector __P((char *, char *, int));
+35
View File
@@ -0,0 +1,35 @@
/* File-name wildcard pattern matching for GNU.
Copyright (C) 1985, 1988, 1989 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _GLOB_H_
#define _GLOB_H_
#include "stdc.h"
#define GX_MARKDIRS 0x01 /* mark directory names with trailing `/' */
#define GX_NOCASE 0x02 /* ignore case */
#define GX_MATCHDOT 0x04 /* match `.' literally */
extern int glob_pattern_p __P((const char *));
extern char **glob_vector __P((char *, char *, int));
extern char **glob_filename __P((char *, int));
extern char *glob_error_return;
extern int noglob_dot_filenames;
extern int glob_ignore_case;
#endif /* _GLOB_H_ */
+1 -1
View File
@@ -231,7 +231,7 @@ static int maxbuck; /* highest bucket receiving allocation request. */
static char *memtop; /* top of heap */
static unsigned long binsizes[NBUCKETS] = {
static const unsigned long binsizes[NBUCKETS] = {
8UL, 16UL, 32UL, 64UL, 128UL, 256UL, 512UL, 1024UL, 2048UL, 4096UL,
8192UL, 16384UL, 32768UL, 65536UL, 131072UL, 262144UL, 524288UL,
1048576UL, 2097152UL, 4194304UL, 8388608UL, 16777216UL, 33554432UL,
+1 -1
View File
@@ -312,7 +312,7 @@ xbotch (mem, e, s, file, line)
int line;
{
fprintf (stderr, _("\r\nmalloc: %s:%d: assertion botched\r\n"),
file ? file : "unknown", line);
file ? file : _("unknown"), line);
#ifdef MALLOC_REGISTER
if (mem != NULL && malloc_register)
mregister_describe_mem (mem, stderr);
+15 -15
View File
@@ -80,7 +80,7 @@ static int glean_key_from_name PARAMS((char *));
static int find_boolean_var PARAMS((const char *));
static char *_rl_get_string_variable_value PARAMS((const char *));
static int substring_member_of_array PARAMS((char *, const char **));
static int substring_member_of_array PARAMS((const char *, const char * const *));
static int currently_reading_init_file;
@@ -936,11 +936,11 @@ _rl_init_file_error (msg)
typedef int _rl_parser_func_t PARAMS((char *));
/* Things that mean `Control'. */
const char *_rl_possible_control_prefixes[] = {
const char * const _rl_possible_control_prefixes[] = {
"Control-", "C-", "CTRL-", (const char *)NULL
};
const char *_rl_possible_meta_prefixes[] = {
const char * const _rl_possible_meta_prefixes[] = {
"Meta", "M-", (const char *)NULL
};
@@ -1099,8 +1099,8 @@ parser_include (args)
}
/* Associate textual names with actual functions. */
static struct {
const char *name;
static const struct {
const char * const name;
_rl_parser_func_t *function;
} parser_directives [] = {
{ "if", parser_if },
@@ -1406,8 +1406,8 @@ rl_parse_and_bind (string)
#define V_SPECIAL 0x1
static struct {
const char *name;
static const struct {
const char * const name;
int *value;
int flags;
} boolean_varlist [] = {
@@ -1494,8 +1494,8 @@ static int sv_editmode PARAMS((const char *));
static int sv_isrchterm PARAMS((const char *));
static int sv_keymap PARAMS((const char *));
static struct {
const char *name;
static const struct {
const char * const name;
int flags;
_rl_sv_func_t *set_func;
} string_varlist[] = {
@@ -1701,11 +1701,11 @@ sv_isrchterm (value)
For example, `Space' returns ' '. */
typedef struct {
const char *name;
const char * const name;
int value;
} assoc_list;
static assoc_list name_key_alist[] = {
static const assoc_list name_key_alist[] = {
{ "DEL", 0x7f },
{ "ESC", '\033' },
{ "Escape", '\033' },
@@ -1734,8 +1734,8 @@ glean_key_from_name (name)
}
/* Auxiliary functions to manage keymaps. */
static struct {
const char *name;
static const struct {
const char * const name;
Keymap map;
} keymap_names[] = {
{ "emacs", emacs_standard_keymap },
@@ -2298,8 +2298,8 @@ rl_dump_variables (count, key)
/* Return non-zero if any members of ARRAY are a substring in STRING. */
static int
substring_member_of_array (string, array)
char *string;
const char **array;
const char *string;
const char * const *array;
{
while (*array)
{
+2311
View File
File diff suppressed because it is too large Load Diff
+18 -5
View File
@@ -325,6 +325,12 @@ int rl_completion_mark_symlink_dirs;
/* If non-zero, inhibit completion (temporarily). */
int rl_inhibit_completion;
/* Set to the last key used to invoke one of the completion functions */
int rl_completion_invoking_key;
/* If non-zero, sort the completion matches. On by default. */
int rl_sort_completion_matches = 1;
/* Variables local to this file. */
/* Local variable states what happened during the last completion attempt. */
@@ -343,6 +349,8 @@ int
rl_complete (ignore, invoking_key)
int ignore, invoking_key;
{
rl_completion_invoking_key = invoking_key;
if (rl_inhibit_completion)
return (_rl_insert_char (ignore, invoking_key));
else if (rl_last_func == rl_complete && !completion_changed_buffer)
@@ -360,6 +368,7 @@ int
rl_possible_completions (ignore, invoking_key)
int ignore, invoking_key;
{
rl_completion_invoking_key = invoking_key;
return (rl_complete_internal ('?'));
}
@@ -367,6 +376,7 @@ int
rl_insert_completions (ignore, invoking_key)
int ignore, invoking_key;
{
rl_completion_invoking_key = invoking_key;
return (rl_complete_internal ('*'));
}
@@ -999,7 +1009,7 @@ remove_duplicate_matches (matches)
/* Sort the array without matches[0], since we need it to
stay in place no matter what. */
if (i)
if (i && rl_sort_completion_matches)
qsort (matches+1, i-1, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
/* Remember the lowest common denominator for it may be unique. */
@@ -1167,7 +1177,8 @@ compute_lcd_of_matches (match_list, matches, text)
}
/* sort the list to get consistent answers. */
qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
if (rl_sort_completion_matches)
qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
si = strlen (text);
if (si <= low)
@@ -1285,7 +1296,7 @@ rl_display_match_list (matches, len, max)
0 < len <= limit implies count = 1. */
/* Sort the items if they are not already sorted. */
if (rl_ignore_completion_duplicates == 0)
if (rl_ignore_completion_duplicates == 0 && rl_sort_completion_matches)
qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
rl_crlf ();
@@ -2116,8 +2127,8 @@ rl_filename_completion_function (text, state)
hit the end of the match list, we restore the original unmatched text,
ring the bell, and reset the counter to zero. */
int
rl_menu_complete (count, ignore)
int count, ignore;
rl_menu_complete (count, invoking_key)
int count, invoking_key;
{
rl_compentry_func_t *our_func;
int matching_filenames, found_quote;
@@ -2142,6 +2153,8 @@ rl_menu_complete (count, ignore)
match_list_index = match_list_size = 0;
matches = (char **)NULL;
rl_completion_invoking_key = invoking_key;
/* Only the completion entry function can change these. */
set_completion_defaults ('%');
+2 -2
View File
@@ -1,6 +1,6 @@
/* complete.c -- filename completion for readline. */
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
/* Copyright (C) 1987-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.
@@ -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);
+16
View File
@@ -1839,6 +1839,15 @@ if the application's completion function returns no matches.
It should be set only by an application's completion function.
@end deftypevar
@deftypevar int rl_sort_completion_matches
If an application sets this variable to 0, Readline will not sort the
list of completions (which implies that it cannot remove any duplicate
completions). The default value is 1, which means that Readline will
sort the completions and, depending on the value of
@code{rl_ignore_completion_duplicates}, will attempt to remove duplicate
matches.
@end deftypevar
@deftypevar int rl_completion_type
Set to a character describing the type of completion Readline is currently
attempting; see the description of @code{rl_complete_internal()}
@@ -1848,6 +1857,13 @@ completion function is called, allowing such functions to present
the same interface as @code{rl_complete()}.
@end deftypevar
@deftypevar int rl_completion_invoking_key
Set to the final character in the key sequence that invoked one of the
completion functions that call @code{rl_complete_internal()}. This is
set to the appropriate value before any application-specific completion
function is called.
@end deftypevar
@deftypevar int rl_inhibit_completion
If this variable is non-zero, completion is inhibited. The completion
character will be inserted as any other bound to @code{self-insert}.
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1559,9 +1559,9 @@ completed, and the matching words become the possible completions.
After these matches have been generated, any shell function or command
specified with the @option{-F} and @option{-C} options is invoked.
When the command or function is invoked, the @env{COMP_LINE} and
@env{COMP_POINT} variables are assigned values as described above
(@pxref{Bash Variables}).
When the command or function is invoked, the @env{COMP_LINE},
@env{COMP_POINT}, @env{COMP_KEY}, and @env{COMP_TYPE} variables are
assigned values as described above (@pxref{Bash Variables}).
If a shell function is being invoked, the @env{COMP_WORDS} and
@env{COMP_CWORD} variables are also set.
When the function or command is invoked, the first argument is the
+5 -5
View File
@@ -1559,9 +1559,9 @@ completed, and the matching words become the possible completions.
After these matches have been generated, any shell function or command
specified with the @option{-F} and @option{-C} options is invoked.
When the command or function is invoked, the @env{COMP_LINE} and
@env{COMP_POINT} variables are assigned values as described above
(@pxref{Bash Variables}).
When the command or function is invoked, the @env{COMP_LINE},
@env{COMP_POINT}, and @env{COMP_TYPE} variables are assigned values
as described above (@pxref{Bash Variables}).
If a shell function is being invoked, the @env{COMP_WORDS} and
@env{COMP_CWORD} variables are also set.
When the function or command is invoked, the first argument is the
@@ -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
+3 -3
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2006 Free Software Foundation, Inc.
@set EDITION 5.2
@set VERSION 5.2
@set UPDATED 26 April 2006
@set UPDATED-MONTH April 2006
@set UPDATED 30 December 2006
@set UPDATED-MONTH December 2006
@set LASTCHANGE Wed Apr 26 09:22:57 EDT 2006
@set LASTCHANGE Sat Dec 30 19:17:22 EST 2006
+10
View File
@@ -0,0 +1,10 @@
@ignore
Copyright (C) 1988-2006 Free Software Foundation, Inc.
@end ignore
@set EDITION 5.2
@set VERSION 5.2
@set UPDATED 26 April 2006
@set UPDATED-MONTH April 2006
@set LASTCHANGE Wed Apr 26 09:22:57 EDT 2006
+1 -1
View File
@@ -56,7 +56,7 @@ static int funmap_entry;
program specific function. */
int funmap_program_specific_entry_start;
static FUNMAP default_funmap[] = {
static const FUNMAP default_funmap[] = {
{ "abort", rl_abort },
{ "accept-line", rl_newline },
{ "arrow-key-prefix", rl_arrow_keys },
+255
View File
@@ -0,0 +1,255 @@
/* funmap.c -- attach names to functions. */
/* Copyright (C) 1987, 1989, 1992 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.
The GNU Readline Library 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.
The GNU Readline Library 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.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#if !defined (BUFSIZ)
#include <stdio.h>
#endif /* BUFSIZ */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include "rlconf.h"
#include "readline.h"
#include "xmalloc.h"
#ifdef __STDC__
typedef int QSFUNC (const void *, const void *);
#else
typedef int QSFUNC ();
#endif
extern int _rl_qsort_string_compare PARAMS((char **, char **));
FUNMAP **funmap;
static int funmap_size;
static int funmap_entry;
/* After initializing the function map, this is the index of the first
program specific function. */
int funmap_program_specific_entry_start;
static FUNMAP default_funmap[] = {
{ "abort", rl_abort },
{ "accept-line", rl_newline },
{ "arrow-key-prefix", rl_arrow_keys },
{ "backward-byte", rl_backward_byte },
{ "backward-char", rl_backward_char },
{ "backward-delete-char", rl_rubout },
{ "backward-kill-line", rl_backward_kill_line },
{ "backward-kill-word", rl_backward_kill_word },
{ "backward-word", rl_backward_word },
{ "beginning-of-history", rl_beginning_of_history },
{ "beginning-of-line", rl_beg_of_line },
{ "call-last-kbd-macro", rl_call_last_kbd_macro },
{ "capitalize-word", rl_capitalize_word },
{ "character-search", rl_char_search },
{ "character-search-backward", rl_backward_char_search },
{ "clear-screen", rl_clear_screen },
{ "complete", rl_complete },
{ "copy-backward-word", rl_copy_backward_word },
{ "copy-forward-word", rl_copy_forward_word },
{ "copy-region-as-kill", rl_copy_region_to_kill },
{ "delete-char", rl_delete },
{ "delete-char-or-list", rl_delete_or_show_completions },
{ "delete-horizontal-space", rl_delete_horizontal_space },
{ "digit-argument", rl_digit_argument },
{ "do-lowercase-version", rl_do_lowercase_version },
{ "downcase-word", rl_downcase_word },
{ "dump-functions", rl_dump_functions },
{ "dump-macros", rl_dump_macros },
{ "dump-variables", rl_dump_variables },
{ "emacs-editing-mode", rl_emacs_editing_mode },
{ "end-kbd-macro", rl_end_kbd_macro },
{ "end-of-history", rl_end_of_history },
{ "end-of-line", rl_end_of_line },
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
{ "forward-backward-delete-char", rl_rubout_or_delete },
{ "forward-byte", rl_forward_byte },
{ "forward-char", rl_forward_char },
{ "forward-search-history", rl_forward_search_history },
{ "forward-word", rl_forward_word },
{ "history-search-backward", rl_history_search_backward },
{ "history-search-forward", rl_history_search_forward },
{ "insert-comment", rl_insert_comment },
{ "insert-completions", rl_insert_completions },
{ "kill-whole-line", rl_kill_full_line },
{ "kill-line", rl_kill_line },
{ "kill-region", rl_kill_region },
{ "kill-word", rl_kill_word },
{ "menu-complete", rl_menu_complete },
{ "next-history", rl_get_next_history },
{ "non-incremental-forward-search-history", rl_noninc_forward_search },
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
{ "overwrite-mode", rl_overwrite_mode },
#ifdef __CYGWIN__
{ "paste-from-clipboard", rl_paste_from_clipboard },
#endif
{ "possible-completions", rl_possible_completions },
{ "previous-history", rl_get_previous_history },
{ "quoted-insert", rl_quoted_insert },
{ "re-read-init-file", rl_re_read_init_file },
{ "redraw-current-line", rl_refresh_line},
{ "reverse-search-history", rl_reverse_search_history },
{ "revert-line", rl_revert_line },
{ "self-insert", rl_insert },
{ "set-mark", rl_set_mark },
{ "start-kbd-macro", rl_start_kbd_macro },
{ "tab-insert", rl_tab_insert },
{ "tilde-expand", rl_tilde_expand },
{ "transpose-chars", rl_transpose_chars },
{ "transpose-words", rl_transpose_words },
{ "tty-status", rl_tty_status },
{ "undo", rl_undo_command },
{ "universal-argument", rl_universal_argument },
{ "unix-filename-rubout", rl_unix_filename_rubout },
{ "unix-line-discard", rl_unix_line_discard },
{ "unix-word-rubout", rl_unix_word_rubout },
{ "upcase-word", rl_upcase_word },
{ "yank", rl_yank },
{ "yank-last-arg", rl_yank_last_arg },
{ "yank-nth-arg", rl_yank_nth_arg },
{ "yank-pop", rl_yank_pop },
#if defined (VI_MODE)
{ "vi-append-eol", rl_vi_append_eol },
{ "vi-append-mode", rl_vi_append_mode },
{ "vi-arg-digit", rl_vi_arg_digit },
{ "vi-back-to-indent", rl_vi_back_to_indent },
{ "vi-bWord", rl_vi_bWord },
{ "vi-bword", rl_vi_bword },
{ "vi-change-case", rl_vi_change_case },
{ "vi-change-char", rl_vi_change_char },
{ "vi-change-to", rl_vi_change_to },
{ "vi-char-search", rl_vi_char_search },
{ "vi-column", rl_vi_column },
{ "vi-complete", rl_vi_complete },
{ "vi-delete", rl_vi_delete },
{ "vi-delete-to", rl_vi_delete_to },
{ "vi-eWord", rl_vi_eWord },
{ "vi-editing-mode", rl_vi_editing_mode },
{ "vi-end-word", rl_vi_end_word },
{ "vi-eof-maybe", rl_vi_eof_maybe },
{ "vi-eword", rl_vi_eword },
{ "vi-fWord", rl_vi_fWord },
{ "vi-fetch-history", rl_vi_fetch_history },
{ "vi-first-print", rl_vi_first_print },
{ "vi-fword", rl_vi_fword },
{ "vi-goto-mark", rl_vi_goto_mark },
{ "vi-insert-beg", rl_vi_insert_beg },
{ "vi-insertion-mode", rl_vi_insertion_mode },
{ "vi-match", rl_vi_match },
{ "vi-movement-mode", rl_vi_movement_mode },
{ "vi-next-word", rl_vi_next_word },
{ "vi-overstrike", rl_vi_overstrike },
{ "vi-overstrike-delete", rl_vi_overstrike_delete },
{ "vi-prev-word", rl_vi_prev_word },
{ "vi-put", rl_vi_put },
{ "vi-redo", rl_vi_redo },
{ "vi-replace", rl_vi_replace },
{ "vi-rubout", rl_vi_rubout },
{ "vi-search", rl_vi_search },
{ "vi-search-again", rl_vi_search_again },
{ "vi-set-mark", rl_vi_set_mark },
{ "vi-subst", rl_vi_subst },
{ "vi-tilde-expand", rl_vi_tilde_expand },
{ "vi-yank-arg", rl_vi_yank_arg },
{ "vi-yank-to", rl_vi_yank_to },
#endif /* VI_MODE */
{(char *)NULL, (rl_command_func_t *)NULL }
};
int
rl_add_funmap_entry (name, function)
const char *name;
rl_command_func_t *function;
{
if (funmap_entry + 2 >= funmap_size)
{
funmap_size += 64;
funmap = (FUNMAP **)xrealloc (funmap, funmap_size * sizeof (FUNMAP *));
}
funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
funmap[funmap_entry]->name = name;
funmap[funmap_entry]->function = function;
funmap[++funmap_entry] = (FUNMAP *)NULL;
return funmap_entry;
}
static int funmap_initialized;
/* Make the funmap contain all of the default entries. */
void
rl_initialize_funmap ()
{
register int i;
if (funmap_initialized)
return;
for (i = 0; default_funmap[i].name; i++)
rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function);
funmap_initialized = 1;
funmap_program_specific_entry_start = i;
}
/* Produce a NULL terminated array of known function names. The array
is sorted. The array itself is allocated, but not the strings inside.
You should free () the array when you done, but not the pointrs. */
const char **
rl_funmap_names ()
{
const char **result;
int result_size, result_index;
/* Make sure that the function map has been initialized. */
rl_initialize_funmap ();
for (result_index = result_size = 0, result = (const char **)NULL; funmap[result_index]; result_index++)
{
if (result_index + 2 > result_size)
{
result_size += 20;
result = (const char **)xrealloc (result, result_size * sizeof (char *));
}
result[result_index] = funmap[result_index]->name;
result[result_index + 1] = (char *)NULL;
}
qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
return (result);
}
+1 -1
View File
@@ -75,7 +75,7 @@ static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int));
static char *last_isearch_string;
static int last_isearch_string_len;
static char *default_isearch_terminators = "\033\012";
static char * const default_isearch_terminators = "\033\012";
_rl_search_cxt *
_rl_scxt_alloc (type, flags)
+670
View File
@@ -0,0 +1,670 @@
/* **************************************************************** */
/* */
/* I-Search and Searching */
/* */
/* **************************************************************** */
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
This file contains the Readline Library (the Library), a set of
routines for providing Emacs style line input to programs that ask
for it.
The Library 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.
The Library 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.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif
#include "rldefs.h"
#include "rlmbutil.h"
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "xmalloc.h"
/* Variables exported to other files in the readline library. */
char *_rl_isearch_terminators = (char *)NULL;
_rl_search_cxt *_rl_iscxt = 0;
/* Variables imported from other files in the readline library. */
extern HIST_ENTRY *_rl_saved_line_for_history;
static int rl_search_history PARAMS((int, int));
static _rl_search_cxt *_rl_isearch_init PARAMS((int));
static void _rl_isearch_fini PARAMS((_rl_search_cxt *));
static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int));
/* Last line found by the current incremental search, so we don't `find'
identical lines many times in a row. Now part of isearch context. */
/* static char *prev_line_found; */
/* Last search string and its length. */
static char *last_isearch_string;
static int last_isearch_string_len;
static char * const default_isearch_terminators = "\033\012";
_rl_search_cxt *
_rl_scxt_alloc (type, flags)
int type, flags;
{
_rl_search_cxt *cxt;
cxt = (_rl_search_cxt *)xmalloc (sizeof (_rl_search_cxt));
cxt->type = type;
cxt->sflags = flags;
cxt->search_string = 0;
cxt->search_string_size = cxt->search_string_index = 0;
cxt->lines = 0;
cxt->allocated_line = 0;
cxt->hlen = cxt->hindex = 0;
cxt->save_point = rl_point;
cxt->save_mark = rl_mark;
cxt->save_line = where_history ();
cxt->last_found_line = cxt->save_line;
cxt->prev_line_found = 0;
cxt->save_undo_list = 0;
cxt->history_pos = 0;
cxt->direction = 0;
cxt->lastc = 0;
cxt->sline = 0;
cxt->sline_len = cxt->sline_index = 0;
cxt->search_terminators = 0;
return cxt;
}
void
_rl_scxt_dispose (cxt, flags)
_rl_search_cxt *cxt;
int flags;
{
FREE (cxt->search_string);
FREE (cxt->allocated_line);
FREE (cxt->lines);
xfree (cxt);
}
/* Search backwards through the history looking for a string which is typed
interactively. Start with the current line. */
int
rl_reverse_search_history (sign, key)
int sign, key;
{
return (rl_search_history (-sign, key));
}
/* Search forwards through the history looking for a string which is typed
interactively. Start with the current line. */
int
rl_forward_search_history (sign, key)
int sign, key;
{
return (rl_search_history (sign, key));
}
/* Display the current state of the search in the echo-area.
SEARCH_STRING contains the string that is being searched for,
DIRECTION is zero for forward, or non-zero for reverse,
WHERE is the history list number of the current line. If it is
-1, then this line is the starting one. */
static void
rl_display_search (search_string, reverse_p, where)
char *search_string;
int reverse_p, where;
{
char *message;
int msglen, searchlen;
searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
message = (char *)xmalloc (searchlen + 33);
msglen = 0;
#if defined (NOTDEF)
if (where != -1)
{
sprintf (message, "[%d]", where + history_base);
msglen = strlen (message);
}
#endif /* NOTDEF */
message[msglen++] = '(';
if (reverse_p)
{
strcpy (message + msglen, "reverse-");
msglen += 8;
}
strcpy (message + msglen, "i-search)`");
msglen += 10;
if (search_string)
{
strcpy (message + msglen, search_string);
msglen += searchlen;
}
strcpy (message + msglen, "': ");
rl_message ("%s", message);
xfree (message);
(*rl_redisplay_function) ();
}
static _rl_search_cxt *
_rl_isearch_init (direction)
int direction;
{
_rl_search_cxt *cxt;
register int i;
HIST_ENTRY **hlist;
cxt = _rl_scxt_alloc (RL_SEARCH_ISEARCH, 0);
if (direction < 0)
cxt->sflags |= SF_REVERSE;
cxt->search_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
: default_isearch_terminators;
itrace("_rl_isearch_init: set search_terminators to %s", cxt->search_terminators);
/* Create an arrary of pointers to the lines that we want to search. */
hlist = history_list ();
rl_maybe_replace_line ();
i = 0;
if (hlist)
for (i = 0; hlist[i]; i++);
/* Allocate space for this many lines, +1 for the current input line,
and remember those lines. */
cxt->lines = (char **)xmalloc ((1 + (cxt->hlen = i)) * sizeof (char *));
for (i = 0; i < cxt->hlen; i++)
cxt->lines[i] = hlist[i]->line;
if (_rl_saved_line_for_history)
cxt->lines[i] = _rl_saved_line_for_history->line;
else
{
/* Keep track of this so we can free it. */
cxt->allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer));
strcpy (cxt->allocated_line, &rl_line_buffer[0]);
cxt->lines[i] = cxt->allocated_line;
}
cxt->hlen++;
/* The line where we start the search. */
cxt->history_pos = cxt->save_line;
rl_save_prompt ();
/* Initialize search parameters. */
cxt->search_string = (char *)xmalloc (cxt->search_string_size = 128);
cxt->search_string[cxt->search_string_index = 0] = '\0';
/* Normalize DIRECTION into 1 or -1. */
cxt->direction = (direction >= 0) ? 1 : -1;
cxt->sline = rl_line_buffer;
cxt->sline_len = strlen (cxt->sline);
cxt->sline_index = rl_point;
_rl_iscxt = cxt; /* save globally */
return cxt;
}
static void
_rl_isearch_fini (cxt)
_rl_search_cxt *cxt;
{
/* First put back the original state. */
strcpy (rl_line_buffer, cxt->lines[cxt->save_line]);
rl_restore_prompt ();
/* Save the search string for possible later use. */
FREE (last_isearch_string);
last_isearch_string = cxt->search_string;
last_isearch_string_len = cxt->search_string_index;
cxt->search_string = 0;
if (cxt->last_found_line < cxt->save_line)
rl_get_previous_history (cxt->save_line - cxt->last_found_line, 0);
else
rl_get_next_history (cxt->last_found_line - cxt->save_line, 0);
/* If the string was not found, put point at the end of the last matching
line. If last_found_line == orig_line, we didn't find any matching
history lines at all, so put point back in its original position. */
if (cxt->sline_index < 0)
{
if (cxt->last_found_line == cxt->save_line)
cxt->sline_index = cxt->save_point;
else
cxt->sline_index = strlen (rl_line_buffer);
rl_mark = cxt->save_mark;
}
rl_point = cxt->sline_index;
/* Don't worry about where to put the mark here; rl_get_previous_history
and rl_get_next_history take care of it. */
rl_clear_message ();
}
int
_rl_search_getchar (cxt)
_rl_search_cxt *cxt;
{
int c;
/* Read a key and decide how to proceed. */
RL_SETSTATE(RL_STATE_MOREINPUT);
c = cxt->lastc = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = cxt->lastc = _rl_read_mbstring (cxt->lastc, cxt->mb, MB_LEN_MAX);
#endif
return c;
}
/* Process just-read character C according to isearch context CXT. Return
-1 if the caller should just free the context and return, 0 if we should
break out of the loop, and 1 if we should continue to read characters. */
int
_rl_isearch_dispatch (cxt, c)
_rl_search_cxt *cxt;
int c;
{
int n, wstart, wlen, limit, cval;
rl_command_func_t *f;
f = (rl_command_func_t *)NULL;
/* Translate the keys we do something with to opcodes. */
if (c >= 0 && _rl_keymap[c].type == ISFUNC)
{
f = _rl_keymap[c].function;
if (f == rl_reverse_search_history)
cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2;
else if (f == rl_forward_search_history)
cxt->lastc = (cxt->sflags & SF_REVERSE) ? -2 : -1;
else if (f == rl_rubout)
cxt->lastc = -3;
else if (c == CTRL ('G'))
cxt->lastc = -4;
else if (c == CTRL ('W')) /* XXX */
cxt->lastc = -5;
else if (c == CTRL ('Y')) /* XXX */
cxt->lastc = -6;
}
itrace("_rl_isearch_dispatch: looking for %d in cxt->search_terminators", cxt->lastc);
/* The characters in isearch_terminators (set from the user-settable
variable isearch-terminators) are used to terminate the search but
not subsequently execute the character as a command. The default
value is "\033\012" (ESC and C-J). */
if (strchr (cxt->search_terminators, cxt->lastc))
{
itrace("_rl_isearch_dispatch: found %d in search_terminators", cxt->lastc);
/* ESC still terminates the search, but if there is pending
input or if input arrives within 0.1 seconds (on systems
with select(2)) it is used as a prefix character
with rl_execute_next. WATCH OUT FOR THIS! This is intended
to allow the arrow keys to be used like ^F and ^B are used
to terminate the search and execute the movement command.
XXX - since _rl_input_available depends on the application-
settable keyboard timeout value, this could alternatively
use _rl_input_queued(100000) */
if (cxt->lastc == ESC && _rl_input_available ())
rl_execute_next (ESC);
itrace("_rl_isearch_dispatch: exiting search based on char %d", cxt->lastc);
return (0);
}
#define ENDSRCH_CHAR(c) \
((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G')))
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
if (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc))
{
/* This sets rl_pending_input to c; it will be picked up the next
time rl_read_key is called. */
rl_execute_next (cxt->lastc);
return (0);
}
}
else
#endif
if (cxt->lastc >= 0 && ENDSRCH_CHAR (cxt->lastc))
{
/* This sets rl_pending_input to LASTC; it will be picked up the next
time rl_read_key is called. */
rl_execute_next (cxt->lastc);
return (0);
}
/* Now dispatch on the character. `Opcodes' affect the search string or
state. Other characters are added to the string. */
switch (cxt->lastc)
{
/* search again */
case -1:
if (cxt->search_string_index == 0)
{
if (last_isearch_string)
{
cxt->search_string_size = 64 + last_isearch_string_len;
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
strcpy (cxt->search_string, last_isearch_string);
cxt->search_string_index = last_isearch_string_len;
rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), -1);
break;
}
return (1);
}
else if (cxt->sflags & SF_REVERSE)
cxt->sline_index--;
else if (cxt->sline_index != cxt->sline_len)
cxt->sline_index++;
else
rl_ding ();
break;
/* switch directions */
case -2:
cxt->direction = -cxt->direction;
if (cxt->direction < 0)
cxt->sflags |= SF_REVERSE;
else
cxt->sflags &= ~SF_REVERSE;
break;
/* delete character from search string. */
case -3: /* C-H, DEL */
/* This is tricky. To do this right, we need to keep a
stack of search positions for the current search, with
sentinels marking the beginning and end. But this will
do until we have a real isearch-undo. */
if (cxt->search_string_index == 0)
rl_ding ();
else
cxt->search_string[--cxt->search_string_index] = '\0';
break;
case -4: /* C-G, abort */
rl_replace_line (cxt->lines[cxt->save_line], 0);
rl_point = cxt->save_point;
rl_mark = cxt->save_mark;
rl_restore_prompt();
rl_clear_message ();
return -1;
case -5: /* C-W */
/* skip over portion of line we already matched and yank word */
wstart = rl_point + cxt->search_string_index;
if (wstart >= rl_end)
{
rl_ding ();
break;
}
/* if not in a word, move to one. */
cval = _rl_char_value (rl_line_buffer, wstart);
if (_rl_walphabetic (cval) == 0)
{
rl_ding ();
break;
}
n = MB_NEXTCHAR (rl_line_buffer, wstart, 1, MB_FIND_NONZERO);;
while (n < rl_end)
{
cval = _rl_char_value (rl_line_buffer, n);
if (_rl_walphabetic (cval) == 0)
break;
n = MB_NEXTCHAR (rl_line_buffer, n, 1, MB_FIND_NONZERO);;
}
wlen = n - wstart + 1;
if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
{
cxt->search_string_size += wlen + 1;
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
}
for (; wstart < n; wstart++)
cxt->search_string[cxt->search_string_index++] = rl_line_buffer[wstart];
cxt->search_string[cxt->search_string_index] = '\0';
break;
case -6: /* C-Y */
/* skip over portion of line we already matched and yank rest */
wstart = rl_point + cxt->search_string_index;
if (wstart >= rl_end)
{
rl_ding ();
break;
}
n = rl_end - wstart + 1;
if (cxt->search_string_index + n + 1 >= cxt->search_string_size)
{
cxt->search_string_size += n + 1;
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
}
for (n = wstart; n < rl_end; n++)
cxt->search_string[cxt->search_string_index++] = rl_line_buffer[n];
cxt->search_string[cxt->search_string_index] = '\0';
break;
/* Add character to search string and continue search. */
default:
if (cxt->search_string_index + 2 >= cxt->search_string_size)
{
cxt->search_string_size += 128;
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int j, l;
for (j = 0, l = strlen (cxt->mb); j < l; )
cxt->search_string[cxt->search_string_index++] = cxt->mb[j++];
}
else
#endif
cxt->search_string[cxt->search_string_index++] = c;
cxt->search_string[cxt->search_string_index] = '\0';
break;
}
for (cxt->sflags &= ~(SF_FOUND|SF_FAILED);; )
{
limit = cxt->sline_len - cxt->search_string_index + 1;
/* Search the current line. */
while ((cxt->sflags & SF_REVERSE) ? (cxt->sline_index >= 0) : (cxt->sline_index < limit))
{
if (STREQN (cxt->search_string, cxt->sline + cxt->sline_index, cxt->search_string_index))
{
cxt->sflags |= SF_FOUND;
break;
}
else
cxt->sline_index += cxt->direction;
}
if (cxt->sflags & SF_FOUND)
break;
/* Move to the next line, but skip new copies of the line
we just found and lines shorter than the string we're
searching for. */
do
{
/* Move to the next line. */
cxt->history_pos += cxt->direction;
/* At limit for direction? */
if ((cxt->sflags & SF_REVERSE) ? (cxt->history_pos < 0) : (cxt->history_pos == cxt->hlen))
{
cxt->sflags |= SF_FAILED;
break;
}
/* We will need these later. */
cxt->sline = cxt->lines[cxt->history_pos];
cxt->sline_len = strlen (cxt->sline);
}
while ((cxt->prev_line_found && STREQ (cxt->prev_line_found, cxt->lines[cxt->history_pos])) ||
(cxt->search_string_index > cxt->sline_len));
if (cxt->sflags & SF_FAILED)
break;
/* Now set up the line for searching... */
cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0;
}
if (cxt->sflags & SF_FAILED)
{
/* We cannot find the search string. Ding the bell. */
rl_ding ();
cxt->history_pos = cxt->last_found_line;
return 1;
}
/* We have found the search string. Just display it. But don't
actually move there in the history list until the user accepts
the location. */
if (cxt->sflags & SF_FOUND)
{
cxt->prev_line_found = cxt->lines[cxt->history_pos];
rl_replace_line (cxt->lines[cxt->history_pos], 0);
rl_point = cxt->sline_index;
cxt->last_found_line = cxt->history_pos;
rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);
}
return 1;
}
static int
_rl_isearch_cleanup (cxt, r)
_rl_search_cxt *cxt;
int r;
{
if (r >= 0)
_rl_isearch_fini (cxt);
_rl_scxt_dispose (cxt, 0);
_rl_iscxt = 0;
RL_UNSETSTATE(RL_STATE_ISEARCH);
return (r != 0);
}
/* Search through the history looking for an interactively typed string.
This is analogous to i-search. We start the search in the current line.
DIRECTION is which direction to search; >= 0 means forward, < 0 means
backwards. */
static int
rl_search_history (direction, invoking_key)
int direction, invoking_key;
{
_rl_search_cxt *cxt; /* local for now, but saved globally */
int c, r;
RL_SETSTATE(RL_STATE_ISEARCH);
cxt = _rl_isearch_init (direction);
rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), -1);
/* If we are using the callback interface, all we do is set up here and
return. The key is that we leave RL_STATE_ISEARCH set. */
if (RL_ISSTATE (RL_STATE_CALLBACK))
return (0);
r = -1;
for (;;)
{
c = _rl_search_getchar (cxt);
/* We might want to handle EOF here (c == 0) */
r = _rl_isearch_dispatch (cxt, cxt->lastc);
if (r <= 0)
break;
}
/* The searching is over. The user may have found the string that she
was looking for, or else she may have exited a failing search. If
LINE_INDEX is -1, then that shows that the string searched for was
not found. We use this to determine where to place rl_point. */
return (_rl_isearch_cleanup (cxt, r));
}
#if defined (READLINE_CALLBACKS)
/* Called from the callback functions when we are ready to read a key. The
callback functions know to call this because RL_ISSTATE(RL_STATE_ISEARCH).
If _rl_isearch_dispatch finishes searching, this function is responsible
for turning off RL_STATE_ISEARCH, which it does using _rl_isearch_cleanup. */
int
_rl_isearch_callback (cxt)
_rl_search_cxt *cxt;
{
int c, r;
c = _rl_search_getchar (cxt);
/* We might want to handle EOF here */
r = _rl_isearch_dispatch (cxt, cxt->lastc);
return (r <= 0) ? _rl_isearch_cleanup (cxt, r) : 0;
}
#endif
+6
View File
@@ -718,6 +718,9 @@ extern int rl_attempted_completion_over;
functions. */
extern int rl_completion_type;
/* Set to the last key used to invoke one of the completion functions */
extern int rl_completion_invoking_key;
/* Up to this many items will be displayed in response to a
possible-completions call. After that, we ask the user if she
is sure she wants to see them all. The default value is 100. */
@@ -744,6 +747,9 @@ extern int rl_completion_found_quote;
application-specific completion function. */
extern int rl_completion_suppress_quote;
/* If non-zero, readline will sort the completion matches. On by default. */
extern int rl_sort_completion_matches;
/* If non-zero, a slash will be appended to completed filenames that are
symbolic links to directory names, subject to the value of the
mark-directories variable (which is user-settable). This exists so
+858
View File
@@ -0,0 +1,858 @@
/* Readline.h -- the names of functions callable from within readline. */
/* Copyright (C) 1987-2005 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.
The GNU Readline Library 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.
The GNU Readline Library 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.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_READLINE_H_)
#define _READLINE_H_
#ifdef __cplusplus
extern "C" {
#endif
#if defined (READLINE_LIBRARY)
# include "rlstdc.h"
# include "rltypedefs.h"
# include "keymaps.h"
# include "tilde.h"
#else
# include <readline/rlstdc.h>
# include <readline/rltypedefs.h>
# include <readline/keymaps.h>
# include <readline/tilde.h>
#endif
/* Hex-encoded Readline version number. */
#define RL_READLINE_VERSION 0x0502 /* Readline 5.2 */
#define RL_VERSION_MAJOR 5
#define RL_VERSION_MINOR 2
/* Readline data structures. */
/* Maintaining the state of undo. We remember individual deletes and inserts
on a chain of things to do. */
/* The actions that undo knows how to undo. Notice that UNDO_DELETE means
to insert some text, and UNDO_INSERT means to delete some text. I.e.,
the code tells undo what to undo, not how to undo it. */
enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
/* What an element of THE_UNDO_LIST looks like. */
typedef struct undo_list {
struct undo_list *next;
int start, end; /* Where the change took place. */
char *text; /* The text to insert, if undoing a delete. */
enum undo_code what; /* Delete, Insert, Begin, End. */
} UNDO_LIST;
/* The current undo list for RL_LINE_BUFFER. */
extern UNDO_LIST *rl_undo_list;
/* The data structure for mapping textual names to code addresses. */
typedef struct _funmap {
const char *name;
rl_command_func_t *function;
} FUNMAP;
extern FUNMAP **funmap;
/* **************************************************************** */
/* */
/* Functions available to bind to key sequences */
/* */
/* **************************************************************** */
/* Bindable commands for numeric arguments. */
extern int rl_digit_argument PARAMS((int, int));
extern int rl_universal_argument PARAMS((int, int));
/* Bindable commands for moving the cursor. */
extern int rl_forward_byte PARAMS((int, int));
extern int rl_forward_char PARAMS((int, int));
extern int rl_forward PARAMS((int, int));
extern int rl_backward_byte PARAMS((int, int));
extern int rl_backward_char PARAMS((int, int));
extern int rl_backward PARAMS((int, int));
extern int rl_beg_of_line PARAMS((int, int));
extern int rl_end_of_line PARAMS((int, int));
extern int rl_forward_word PARAMS((int, int));
extern int rl_backward_word PARAMS((int, int));
extern int rl_refresh_line PARAMS((int, int));
extern int rl_clear_screen PARAMS((int, int));
extern int rl_arrow_keys PARAMS((int, int));
/* Bindable commands for inserting and deleting text. */
extern int rl_insert PARAMS((int, int));
extern int rl_quoted_insert PARAMS((int, int));
extern int rl_tab_insert PARAMS((int, int));
extern int rl_newline PARAMS((int, int));
extern int rl_do_lowercase_version PARAMS((int, int));
extern int rl_rubout PARAMS((int, int));
extern int rl_delete PARAMS((int, int));
extern int rl_rubout_or_delete PARAMS((int, int));
extern int rl_delete_horizontal_space PARAMS((int, int));
extern int rl_delete_or_show_completions PARAMS((int, int));
extern int rl_insert_comment PARAMS((int, int));
/* Bindable commands for changing case. */
extern int rl_upcase_word PARAMS((int, int));
extern int rl_downcase_word PARAMS((int, int));
extern int rl_capitalize_word PARAMS((int, int));
/* Bindable commands for transposing characters and words. */
extern int rl_transpose_words PARAMS((int, int));
extern int rl_transpose_chars PARAMS((int, int));
/* Bindable commands for searching within a line. */
extern int rl_char_search PARAMS((int, int));
extern int rl_backward_char_search PARAMS((int, int));
/* Bindable commands for readline's interface to the command history. */
extern int rl_beginning_of_history PARAMS((int, int));
extern int rl_end_of_history PARAMS((int, int));
extern int rl_get_next_history PARAMS((int, int));
extern int rl_get_previous_history PARAMS((int, int));
/* Bindable commands for managing the mark and region. */
extern int rl_set_mark PARAMS((int, int));
extern int rl_exchange_point_and_mark PARAMS((int, int));
/* Bindable commands to set the editing mode (emacs or vi). */
extern int rl_vi_editing_mode PARAMS((int, int));
extern int rl_emacs_editing_mode PARAMS((int, int));
/* Bindable commands to change the insert mode (insert or overwrite) */
extern int rl_overwrite_mode PARAMS((int, int));
/* Bindable commands for managing key bindings. */
extern int rl_re_read_init_file PARAMS((int, int));
extern int rl_dump_functions PARAMS((int, int));
extern int rl_dump_macros PARAMS((int, int));
extern int rl_dump_variables PARAMS((int, int));
/* Bindable commands for word completion. */
extern int rl_complete PARAMS((int, int));
extern int rl_possible_completions PARAMS((int, int));
extern int rl_insert_completions PARAMS((int, int));
extern int rl_menu_complete PARAMS((int, int));
/* Bindable commands for killing and yanking text, and managing the kill ring. */
extern int rl_kill_word PARAMS((int, int));
extern int rl_backward_kill_word PARAMS((int, int));
extern int rl_kill_line PARAMS((int, int));
extern int rl_backward_kill_line PARAMS((int, int));
extern int rl_kill_full_line PARAMS((int, int));
extern int rl_unix_word_rubout PARAMS((int, int));
extern int rl_unix_filename_rubout PARAMS((int, int));
extern int rl_unix_line_discard PARAMS((int, int));
extern int rl_copy_region_to_kill PARAMS((int, int));
extern int rl_kill_region PARAMS((int, int));
extern int rl_copy_forward_word PARAMS((int, int));
extern int rl_copy_backward_word PARAMS((int, int));
extern int rl_yank PARAMS((int, int));
extern int rl_yank_pop PARAMS((int, int));
extern int rl_yank_nth_arg PARAMS((int, int));
extern int rl_yank_last_arg PARAMS((int, int));
/* Not available unless __CYGWIN__ is defined. */
#ifdef __CYGWIN__
extern int rl_paste_from_clipboard PARAMS((int, int));
#endif
/* Bindable commands for incremental searching. */
extern int rl_reverse_search_history PARAMS((int, int));
extern int rl_forward_search_history PARAMS((int, int));
/* Bindable keyboard macro commands. */
extern int rl_start_kbd_macro PARAMS((int, int));
extern int rl_end_kbd_macro PARAMS((int, int));
extern int rl_call_last_kbd_macro PARAMS((int, int));
/* Bindable undo commands. */
extern int rl_revert_line PARAMS((int, int));
extern int rl_undo_command PARAMS((int, int));
/* Bindable tilde expansion commands. */
extern int rl_tilde_expand PARAMS((int, int));
/* Bindable terminal control commands. */
extern int rl_restart_output PARAMS((int, int));
extern int rl_stop_output PARAMS((int, int));
/* Miscellaneous bindable commands. */
extern int rl_abort PARAMS((int, int));
extern int rl_tty_status PARAMS((int, int));
/* Bindable commands for incremental and non-incremental history searching. */
extern int rl_history_search_forward PARAMS((int, int));
extern int rl_history_search_backward PARAMS((int, int));
extern int rl_noninc_forward_search PARAMS((int, int));
extern int rl_noninc_reverse_search PARAMS((int, int));
extern int rl_noninc_forward_search_again PARAMS((int, int));
extern int rl_noninc_reverse_search_again PARAMS((int, int));
/* Bindable command used when inserting a matching close character. */
extern int rl_insert_close PARAMS((int, int));
/* Not available unless READLINE_CALLBACKS is defined. */
extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
extern void rl_callback_read_char PARAMS((void));
extern void rl_callback_handler_remove PARAMS((void));
/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
/* VI-mode bindable commands. */
extern int rl_vi_redo PARAMS((int, int));
extern int rl_vi_undo PARAMS((int, int));
extern int rl_vi_yank_arg PARAMS((int, int));
extern int rl_vi_fetch_history PARAMS((int, int));
extern int rl_vi_search_again PARAMS((int, int));
extern int rl_vi_search PARAMS((int, int));
extern int rl_vi_complete PARAMS((int, int));
extern int rl_vi_tilde_expand PARAMS((int, int));
extern int rl_vi_prev_word PARAMS((int, int));
extern int rl_vi_next_word PARAMS((int, int));
extern int rl_vi_end_word PARAMS((int, int));
extern int rl_vi_insert_beg PARAMS((int, int));
extern int rl_vi_append_mode PARAMS((int, int));
extern int rl_vi_append_eol PARAMS((int, int));
extern int rl_vi_eof_maybe PARAMS((int, int));
extern int rl_vi_insertion_mode PARAMS((int, int));
extern int rl_vi_movement_mode PARAMS((int, int));
extern int rl_vi_arg_digit PARAMS((int, int));
extern int rl_vi_change_case PARAMS((int, int));
extern int rl_vi_put PARAMS((int, int));
extern int rl_vi_column PARAMS((int, int));
extern int rl_vi_delete_to PARAMS((int, int));
extern int rl_vi_change_to PARAMS((int, int));
extern int rl_vi_yank_to PARAMS((int, int));
extern int rl_vi_rubout PARAMS((int, int));
extern int rl_vi_delete PARAMS((int, int));
extern int rl_vi_back_to_indent PARAMS((int, int));
extern int rl_vi_first_print PARAMS((int, int));
extern int rl_vi_char_search PARAMS((int, int));
extern int rl_vi_match PARAMS((int, int));
extern int rl_vi_change_char PARAMS((int, int));
extern int rl_vi_subst PARAMS((int, int));
extern int rl_vi_overstrike PARAMS((int, int));
extern int rl_vi_overstrike_delete PARAMS((int, int));
extern int rl_vi_replace PARAMS((int, int));
extern int rl_vi_set_mark PARAMS((int, int));
extern int rl_vi_goto_mark PARAMS((int, int));
/* VI-mode utility functions. */
extern int rl_vi_check PARAMS((void));
extern int rl_vi_domove PARAMS((int, int *));
extern int rl_vi_bracktype PARAMS((int));
extern void rl_vi_start_inserting PARAMS((int, int, int));
/* VI-mode pseudo-bindable commands, used as utility functions. */
extern int rl_vi_fWord PARAMS((int, int));
extern int rl_vi_bWord PARAMS((int, int));
extern int rl_vi_eWord PARAMS((int, int));
extern int rl_vi_fword PARAMS((int, int));
extern int rl_vi_bword PARAMS((int, int));
extern int rl_vi_eword PARAMS((int, int));
/* **************************************************************** */
/* */
/* Well Published Functions */
/* */
/* **************************************************************** */
/* Readline functions. */
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
extern char *readline PARAMS((const char *));
extern int rl_set_prompt PARAMS((const char *));
extern int rl_expand_prompt PARAMS((char *));
extern int rl_initialize PARAMS((void));
/* Undocumented; unused by readline */
extern int rl_discard_argument PARAMS((void));
/* Utility functions to bind keys to readline commands. */
extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
extern int rl_bind_key PARAMS((int, rl_command_func_t *));
extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
extern int rl_unbind_key PARAMS((int));
extern int rl_unbind_key_in_map PARAMS((int, Keymap));
extern int rl_bind_key_if_unbound PARAMS((int, rl_command_func_t *));
extern int rl_bind_key_if_unbound_in_map PARAMS((int, rl_command_func_t *, Keymap));
extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
extern int rl_bind_keyseq PARAMS((const char *, rl_command_func_t *));
extern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *));
extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
extern char *rl_variable_value PARAMS((const char *));
extern int rl_variable_bind PARAMS((const char *, const char *));
/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
/* Backwards compatibility, use rl_generic_bind instead. */
extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
/* Undocumented in the texinfo manual; not really useful to programs. */
extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
extern char *rl_untranslate_keyseq PARAMS((int));
extern rl_command_func_t *rl_named_function PARAMS((const char *));
extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
extern void rl_list_funmap_names PARAMS((void));
extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
extern void rl_function_dumper PARAMS((int));
extern void rl_macro_dumper PARAMS((int));
extern void rl_variable_dumper PARAMS((int));
extern int rl_read_init_file PARAMS((const char *));
extern int rl_parse_and_bind PARAMS((char *));
/* Functions for manipulating keymaps. */
extern Keymap rl_make_bare_keymap PARAMS((void));
extern Keymap rl_copy_keymap PARAMS((Keymap));
extern Keymap rl_make_keymap PARAMS((void));
extern void rl_discard_keymap PARAMS((Keymap));
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
extern char *rl_get_keymap_name PARAMS((Keymap));
extern void rl_set_keymap PARAMS((Keymap));
extern Keymap rl_get_keymap PARAMS((void));
/* Undocumented; used internally only. */
extern void rl_set_keymap_from_edit_mode PARAMS((void));
extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
/* Functions for manipulating the funmap, which maps command names to functions. */
extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
extern const char **rl_funmap_names PARAMS((void));
/* Undocumented, only used internally -- there is only one funmap, and this
function may be called only once. */
extern void rl_initialize_funmap PARAMS((void));
/* Utility functions for managing keyboard macros. */
extern void rl_push_macro_input PARAMS((char *));
/* Functions for undoing, from undo.c */
extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
extern void rl_free_undo_list PARAMS((void));
extern int rl_do_undo PARAMS((void));
extern int rl_begin_undo_group PARAMS((void));
extern int rl_end_undo_group PARAMS((void));
extern int rl_modifying PARAMS((int, int));
/* Functions for redisplay. */
extern void rl_redisplay PARAMS((void));
extern int rl_on_new_line PARAMS((void));
extern int rl_on_new_line_with_prompt PARAMS((void));
extern int rl_forced_update_display PARAMS((void));
extern int rl_clear_message PARAMS((void));
extern int rl_reset_line_state PARAMS((void));
extern int rl_crlf PARAMS((void));
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
#else
extern int rl_message ();
#endif
extern int rl_show_char PARAMS((int));
/* Undocumented in texinfo manual. */
extern int rl_character_len PARAMS((int, int));
/* Save and restore internal prompt redisplay information. */
extern void rl_save_prompt PARAMS((void));
extern void rl_restore_prompt PARAMS((void));
/* Modifying text. */
extern void rl_replace_line PARAMS((const char *, int));
extern int rl_insert_text PARAMS((const char *));
extern int rl_delete_text PARAMS((int, int));
extern int rl_kill_text PARAMS((int, int));
extern char *rl_copy_text PARAMS((int, int));
/* Terminal and tty mode management. */
extern void rl_prep_terminal PARAMS((int));
extern void rl_deprep_terminal PARAMS((void));
extern void rl_tty_set_default_bindings PARAMS((Keymap));
extern void rl_tty_unset_default_bindings PARAMS((Keymap));
extern int rl_reset_terminal PARAMS((const char *));
extern void rl_resize_terminal PARAMS((void));
extern void rl_set_screen_size PARAMS((int, int));
extern void rl_get_screen_size PARAMS((int *, int *));
extern void rl_reset_screen_size PARAMS((void));
extern char *rl_get_termcap PARAMS((const char *));
/* Functions for character input. */
extern int rl_stuff_char PARAMS((int));
extern int rl_execute_next PARAMS((int));
extern int rl_clear_pending_input PARAMS((void));
extern int rl_read_key PARAMS((void));
extern int rl_getc PARAMS((FILE *));
extern int rl_set_keyboard_input_timeout PARAMS((int));
/* `Public' utility functions . */
extern void rl_extend_line_buffer PARAMS((int));
extern int rl_ding PARAMS((void));
extern int rl_alphabetic PARAMS((int));
extern void rl_free PARAMS((void *));
/* Readline signal handling, from signals.c */
extern int rl_set_signals PARAMS((void));
extern int rl_clear_signals PARAMS((void));
extern void rl_cleanup_after_signal PARAMS((void));
extern void rl_reset_after_signal PARAMS((void));
extern void rl_free_line_state PARAMS((void));
extern int rl_set_paren_blink_timeout PARAMS((int));
/* Undocumented. */
extern int rl_maybe_save_line PARAMS((void));
extern int rl_maybe_unsave_line PARAMS((void));
extern int rl_maybe_replace_line PARAMS((void));
/* Completion functions. */
extern int rl_complete_internal PARAMS((int));
extern void rl_display_match_list PARAMS((char **, int, int));
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
extern char *rl_username_completion_function PARAMS((const char *, int));
extern char *rl_filename_completion_function PARAMS((const char *, int));
extern int rl_completion_mode PARAMS((rl_command_func_t *));
#if 0
/* Backwards compatibility (compat.c). These will go away sometime. */
extern void free_undo_list PARAMS((void));
extern int maybe_save_line PARAMS((void));
extern int maybe_unsave_line PARAMS((void));
extern int maybe_replace_line PARAMS((void));
extern int ding PARAMS((void));
extern int alphabetic PARAMS((int));
extern int crlf PARAMS((void));
extern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
extern char *username_completion_function PARAMS((const char *, int));
extern char *filename_completion_function PARAMS((const char *, int));
#endif
/* **************************************************************** */
/* */
/* Well Published Variables */
/* */
/* **************************************************************** */
/* The version of this incarnation of the readline library. */
extern const char *rl_library_version; /* e.g., "4.2" */
extern int rl_readline_version; /* e.g., 0x0402 */
/* True if this is real GNU readline. */
extern int rl_gnu_readline_p;
/* Flags word encapsulating the current readline state. */
extern int rl_readline_state;
/* Says which editing mode readline is currently using. 1 means emacs mode;
0 means vi mode. */
extern int rl_editing_mode;
/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means
overwrite mode. Reset to insert mode on each input line. */
extern int rl_insert_mode;
/* The name of the calling program. You should initialize this to
whatever was in argv[0]. It is used when parsing conditionals. */
extern const char *rl_readline_name;
/* The prompt readline uses. This is set from the argument to
readline (), and should not be assigned to directly. */
extern char *rl_prompt;
/* The prompt string that is actually displayed by rl_redisplay. Public so
applications can more easily supply their own redisplay functions. */
extern char *rl_display_prompt;
/* The line buffer that is in use. */
extern char *rl_line_buffer;
/* The location of point, and end. */
extern int rl_point;
extern int rl_end;
/* The mark, or saved cursor position. */
extern int rl_mark;
/* Flag to indicate that readline has finished with the current input
line and should return it. */
extern int rl_done;
/* If set to a character value, that will be the next keystroke read. */
extern int rl_pending_input;
/* Non-zero if we called this function from _rl_dispatch(). It's present
so functions can find out whether they were called from a key binding
or directly from an application. */
extern int rl_dispatching;
/* Non-zero if the user typed a numeric argument before executing the
current function. */
extern int rl_explicit_arg;
/* The current value of the numeric argument specified by the user. */
extern int rl_numeric_arg;
/* The address of the last command function Readline executed. */
extern rl_command_func_t *rl_last_func;
/* The name of the terminal to use. */
extern const char *rl_terminal_name;
/* The input and output streams. */
extern FILE *rl_instream;
extern FILE *rl_outstream;
/* If non-zero, Readline gives values of LINES and COLUMNS from the environment
greater precedence than values fetched from the kernel when computing the
screen dimensions. */
extern int rl_prefer_env_winsize;
/* If non-zero, then this is the address of a function to call just
before readline_internal () prints the first prompt. */
extern rl_hook_func_t *rl_startup_hook;
/* If non-zero, this is the address of a function to call just before
readline_internal_setup () returns and readline_internal starts
reading input characters. */
extern rl_hook_func_t *rl_pre_input_hook;
/* The address of a function to call periodically while Readline is
awaiting character input, or NULL, for no event handling. */
extern rl_hook_func_t *rl_event_hook;
/* The address of the function to call to fetch a character from the current
Readline input stream */
extern rl_getc_func_t *rl_getc_function;
extern rl_voidfunc_t *rl_redisplay_function;
extern rl_vintfunc_t *rl_prep_term_function;
extern rl_voidfunc_t *rl_deprep_term_function;
/* Dispatch variables. */
extern Keymap rl_executing_keymap;
extern Keymap rl_binding_keymap;
/* Display variables. */
/* If non-zero, readline will erase the entire line, including any prompt,
if the only thing typed on an otherwise-blank line is something bound to
rl_newline. */
extern int rl_erase_empty_line;
/* If non-zero, the application has already printed the prompt (rl_prompt)
before calling readline, so readline should not output it the first time
redisplay is done. */
extern int rl_already_prompted;
/* A non-zero value means to read only this many characters rather than
up to a character bound to accept-line. */
extern int rl_num_chars_to_read;
/* The text of a currently-executing keyboard macro. */
extern char *rl_executing_macro;
/* Variables to control readline signal handling. */
/* If non-zero, readline will install its own signal handlers for
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
extern int rl_catch_signals;
/* If non-zero, readline will install a signal handler for SIGWINCH
that also attempts to call any calling application's SIGWINCH signal
handler. Note that the terminal is not cleaned up before the
application's signal handler is called; use rl_cleanup_after_signal()
to do that. */
extern int rl_catch_sigwinch;
/* Completion variables. */
/* Pointer to the generator function for completion_matches ().
NULL means to use rl_filename_completion_function (), the default
filename completer. */
extern rl_compentry_func_t *rl_completion_entry_function;
/* If rl_ignore_some_completions_function is non-NULL it is the address
of a function to call after all of the possible matches have been
generated, but before the actual completion is done to the input line.
The function is called with one argument; a NULL terminated array
of (char *). If your function removes any of the elements, they
must be free()'ed. */
extern rl_compignore_func_t *rl_ignore_some_completions_function;
/* Pointer to alternative function to create matches.
Function is called with TEXT, START, and END.
START and END are indices in RL_LINE_BUFFER saying what the boundaries
of TEXT are.
If this function exists and returns NULL then call the value of
rl_completion_entry_function to try to match, otherwise use the
array of strings returned. */
extern rl_completion_func_t *rl_attempted_completion_function;
/* The basic list of characters that signal a break between words for the
completer routine. The initial contents of this variable is what
breaks words in the shell, i.e. "n\"\\'`@$>". */
extern const char *rl_basic_word_break_characters;
/* The list of characters that signal a break between words for
rl_complete_internal. The default list is the contents of
rl_basic_word_break_characters. */
extern /*const*/ char *rl_completer_word_break_characters;
/* Hook function to allow an application to set the completion word
break characters before readline breaks up the line. Allows
position-dependent word break characters. */
extern rl_cpvfunc_t *rl_completion_word_break_hook;
/* List of characters which can be used to quote a substring of the line.
Completion occurs on the entire substring, and within the substring
rl_completer_word_break_characters are treated as any other character,
unless they also appear within this list. */
extern const char *rl_completer_quote_characters;
/* List of quote characters which cause a word break. */
extern const char *rl_basic_quote_characters;
/* List of characters that need to be quoted in filenames by the completer. */
extern const char *rl_filename_quote_characters;
/* List of characters that are word break characters, but should be left
in TEXT when it is passed to the completion function. The shell uses
this to help determine what kind of completing to do. */
extern const char *rl_special_prefixes;
/* If non-zero, then this is the address of a function to call when
completing on a directory name. The function is called with
the address of a string (the current directory name) as an arg. It
changes what is displayed when the possible completions are printed
or inserted. */
extern rl_icppfunc_t *rl_directory_completion_hook;
/* If non-zero, this is the address of a function to call when completing
a directory name. This function takes the address of the directory name
to be modified as an argument. Unlike rl_directory_completion_hook, it
only modifies the directory name used in opendir(2), not what is displayed
when the possible completions are printed or inserted. It is called
before rl_directory_completion_hook. I'm not happy with how this works
yet, so it's undocumented. */
extern rl_icppfunc_t *rl_directory_rewrite_hook;
/* Backwards compatibility with previous versions of readline. */
#define rl_symbolic_link_hook rl_directory_completion_hook
/* If non-zero, then this is the address of a function to call when
completing a word would normally display the list of possible matches.
This function is called instead of actually doing the display.
It takes three arguments: (char **matches, int num_matches, int max_length)
where MATCHES is the array of strings that matched, NUM_MATCHES is the
number of strings in that array, and MAX_LENGTH is the length of the
longest string in that array. */
extern rl_compdisp_func_t *rl_completion_display_matches_hook;
/* Non-zero means that the results of the matches are to be treated
as filenames. This is ALWAYS zero on entry, and can only be changed
within a completion entry finder function. */
extern int rl_filename_completion_desired;
/* Non-zero means that the results of the matches are to be quoted using
double quotes (or an application-specific quoting mechanism) if the
filename contains any characters in rl_word_break_chars. This is
ALWAYS non-zero on entry, and can only be changed within a completion
entry finder function. */
extern int rl_filename_quoting_desired;
/* Set to a function to quote a filename in an application-specific fashion.
Called with the text to quote, the type of match found (single or multiple)
and a pointer to the quoting character to be used, which the function can
reset if desired. */
extern rl_quote_func_t *rl_filename_quoting_function;
/* Function to call to remove quoting characters from a filename. Called
before completion is attempted, so the embedded quotes do not interfere
with matching names in the file system. */
extern rl_dequote_func_t *rl_filename_dequoting_function;
/* Function to call to decide whether or not a word break character is
quoted. If a character is quoted, it does not break words for the
completer. */
extern rl_linebuf_func_t *rl_char_is_quoted_p;
/* Non-zero means to suppress normal filename completion after the
user-specified completion function has been called. */
extern int rl_attempted_completion_over;
/* Set to a character describing the type of completion being attempted by
rl_complete_internal; available for use by application completion
functions. */
extern int rl_completion_type;
/* Up to this many items will be displayed in response to a
possible-completions call. After that, we ask the user if she
is sure she wants to see them all. The default value is 100. */
extern int rl_completion_query_items;
/* Character appended to completed words when at the end of the line. The
default is a space. Nothing is added if this is '\0'. */
extern int rl_completion_append_character;
/* If set to non-zero by an application completion function,
rl_completion_append_character will not be appended. */
extern int rl_completion_suppress_append;
/* Set to any quote character readline thinks it finds before any application
completion function is called. */
extern int rl_completion_quote_character;
/* Set to a non-zero value if readline found quoting anywhere in the word to
be completed; set before any application completion function is called. */
extern int rl_completion_found_quote;
/* If non-zero, the completion functions don't append any closing quote.
This is set to 0 by rl_complete_internal and may be changed by an
application-specific completion function. */
extern int rl_completion_suppress_quote;
/* If non-zero, a slash will be appended to completed filenames that are
symbolic links to directory names, subject to the value of the
mark-directories variable (which is user-settable). This exists so
that application completion functions can override the user's preference
(set via the mark-symlinked-directories variable) if appropriate.
It's set to the value of _rl_complete_mark_symlink_dirs in
rl_complete_internal before any application-specific completion
function is called, so without that function doing anything, the user's
preferences are honored. */
extern int rl_completion_mark_symlink_dirs;
/* If non-zero, then disallow duplicates in the matches. */
extern int rl_ignore_completion_duplicates;
/* If this is non-zero, completion is (temporarily) inhibited, and the
completion character will be inserted as any other. */
extern int rl_inhibit_completion;
/* Input error; can be returned by (*rl_getc_function) if readline is reading
a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */
#define READERR (-2)
/* Definitions available for use by readline clients. */
#define RL_PROMPT_START_IGNORE '\001'
#define RL_PROMPT_END_IGNORE '\002'
/* Possible values for do_replace argument to rl_filename_quoting_function,
called by rl_complete_internal. */
#define NO_MATCH 0
#define SINGLE_MATCH 1
#define MULT_MATCH 2
/* Possible state values for rl_readline_state */
#define RL_STATE_NONE 0x000000 /* no state; before first call */
#define RL_STATE_INITIALIZING 0x000001 /* initializing */
#define RL_STATE_INITIALIZED 0x000002 /* initialization done */
#define RL_STATE_TERMPREPPED 0x000004 /* terminal is prepped */
#define RL_STATE_READCMD 0x000008 /* reading a command key */
#define RL_STATE_METANEXT 0x000010 /* reading input after ESC */
#define RL_STATE_DISPATCHING 0x000020 /* dispatching to a command */
#define RL_STATE_MOREINPUT 0x000040 /* reading more input in a command function */
#define RL_STATE_ISEARCH 0x000080 /* doing incremental search */
#define RL_STATE_NSEARCH 0x000100 /* doing non-inc search */
#define RL_STATE_SEARCH 0x000200 /* doing a history search */
#define RL_STATE_NUMERICARG 0x000400 /* reading numeric argument */
#define RL_STATE_MACROINPUT 0x000800 /* getting input from a macro */
#define RL_STATE_MACRODEF 0x001000 /* defining keyboard macro */
#define RL_STATE_OVERWRITE 0x002000 /* overwrite mode */
#define RL_STATE_COMPLETING 0x004000 /* doing completion */
#define RL_STATE_SIGHANDLER 0x008000 /* in readline sighandler */
#define RL_STATE_UNDOING 0x010000 /* doing an undo */
#define RL_STATE_INPUTPENDING 0x020000 /* rl_execute_next called */
#define RL_STATE_TTYCSAVED 0x040000 /* tty special chars saved */
#define RL_STATE_CALLBACK 0x080000 /* using the callback interface */
#define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */
#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */
#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */
#define RL_STATE_DONE 0x800000 /* done; accepted line */
#define RL_SETSTATE(x) (rl_readline_state |= (x))
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
#define RL_ISSTATE(x) (rl_readline_state & (x))
struct readline_state {
/* line state */
int point;
int end;
int mark;
char *buffer;
int buflen;
UNDO_LIST *ul;
char *prompt;
/* global state */
int rlstate;
int done;
Keymap kmap;
/* input state */
rl_command_func_t *lastfunc;
int insmode;
int edmode;
int kseqlen;
FILE *inf;
FILE *outf;
int pendingin;
char *macro;
/* signal state */
int catchsigs;
int catchsigwinch;
/* search state */
/* completion state */
/* options state */
/* reserved for future expansion, so the struct size doesn't change */
char reserved[64];
};
extern int rl_save_state PARAMS((struct readline_state *));
extern int rl_restore_state PARAMS((struct readline_state *));
#ifdef __cplusplus
}
#endif
#endif /* _READLINE_H_ */
+2 -2
View File
@@ -347,8 +347,8 @@ extern void _rl_vi_done_inserting PARAMS((void));
*************************************************************************/
/* bind.c */
extern const char *_rl_possible_control_prefixes[];
extern const char *_rl_possible_meta_prefixes[];
extern const char * const _rl_possible_control_prefixes[];
extern const char * const _rl_possible_meta_prefixes[];
/* callback.c */
extern _rl_callback_func_t *_rl_callback_func;
+10 -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 **));
@@ -384,6 +392,7 @@ extern int _rl_meta_flag;
extern int _rl_convert_meta_chars_to_ascii;
extern int _rl_output_meta_chars;
extern int _rl_bind_stty_chars;
extern int _rl_revert_all_at_newline;
extern char *_rl_comment_begin;
extern unsigned char _rl_parsing_conditionalized_out;
extern Keymap _rl_keymap;
+2 -2
View File
@@ -361,13 +361,13 @@ rl_resize_terminal ()
}
struct _tc_string {
const char *tc_var;
const char * const tc_var;
char **tc_value;
};
/* This should be kept sorted, just in case we decide to change the
search algorithm to something smarter. */
static struct _tc_string tc_strings[] =
static const struct _tc_string tc_strings[] =
{
{ "@7", &_rl_term_at7 },
{ "DC", &_rl_term_DC },
+731
View File
@@ -0,0 +1,731 @@
/* terminal.c -- controlling the terminal with termcap. */
/* Copyright (C) 1996-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.
The GNU Readline Library 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.
The GNU Readline Library 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.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#include "posixstat.h"
#include <fcntl.h>
#if defined (HAVE_SYS_FILE_H)
# include <sys/file.h>
#endif /* HAVE_SYS_FILE_H */
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_LOCALE_H)
# include <locale.h>
#endif
#include <stdio.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
#include "rltty.h"
#include "tcap.h"
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
#if defined (__MINGW32__)
# include <windows.h>
# include <wincon.h>
static void _win_get_screensize PARAMS((int *, int *));
#endif
#if defined (__EMX__)
static void _emx_get_screensize PARAMS((int *, int *));
#endif
#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
/* If the calling application sets this to a non-zero value, readline will
use the $LINES and $COLUMNS environment variables to set its idea of the
window size before interrogating the kernel. */
int rl_prefer_env_winsize = 0;
/* **************************************************************** */
/* */
/* Terminal and Termcap */
/* */
/* **************************************************************** */
static char *term_buffer = (char *)NULL;
static char *term_string_buffer = (char *)NULL;
static int tcap_initialized;
#if !defined (__linux__)
# if defined (__EMX__) || defined (NEED_EXTERN_PC)
extern
# endif /* __EMX__ || NEED_EXTERN_PC */
char PC, *BC, *UP;
#endif /* __linux__ */
/* Some strings to control terminal actions. These are output by tputs (). */
char *_rl_term_clreol;
char *_rl_term_clrpag;
char *_rl_term_cr;
char *_rl_term_backspace;
char *_rl_term_goto;
char *_rl_term_pc;
/* Non-zero if we determine that the terminal can do character insertion. */
int _rl_terminal_can_insert = 0;
/* How to insert characters. */
char *_rl_term_im;
char *_rl_term_ei;
char *_rl_term_ic;
char *_rl_term_ip;
char *_rl_term_IC;
/* How to delete characters. */
char *_rl_term_dc;
char *_rl_term_DC;
char *_rl_term_forward_char;
/* How to go up a line. */
char *_rl_term_up;
/* A visible bell; char if the terminal can be made to flash the screen. */
static char *_rl_visible_bell;
/* Non-zero means the terminal can auto-wrap lines. */
int _rl_term_autowrap = -1;
/* Non-zero means that this terminal has a meta key. */
static int term_has_meta;
/* The sequences to write to turn on and off the meta key, if this
terminal has one. */
static char *_rl_term_mm;
static char *_rl_term_mo;
/* The key sequences output by the arrow keys, if this terminal has any. */
static char *_rl_term_ku;
static char *_rl_term_kd;
static char *_rl_term_kr;
static char *_rl_term_kl;
/* How to initialize and reset the arrow keys, if this terminal has any. */
static char *_rl_term_ks;
static char *_rl_term_ke;
/* The key sequences sent by the Home and End keys, if any. */
static char *_rl_term_kh;
static char *_rl_term_kH;
static char *_rl_term_at7; /* @7 */
/* Delete key */
static char *_rl_term_kD;
/* Insert key */
static char *_rl_term_kI;
/* Cursor control */
static char *_rl_term_vs; /* very visible */
static char *_rl_term_ve; /* normal */
static void bind_termcap_arrow_keys PARAMS((Keymap));
/* Variables that hold the screen dimensions, used by the display code. */
int _rl_screenwidth, _rl_screenheight, _rl_screenchars;
/* Non-zero means the user wants to enable the keypad. */
int _rl_enable_keypad;
/* Non-zero means the user wants to enable a meta key. */
int _rl_enable_meta = 1;
#if defined (__EMX__)
static void
_emx_get_screensize (swp, shp)
int *swp, *shp;
{
int sz[2];
_scrsize (sz);
if (swp)
*swp = sz[0];
if (shp)
*shp = sz[1];
}
#endif
#if defined (__MINGW32__)
static void
_win_get_screensize (swp, shp)
int *swp, *shp;
{
HANDLE hConOut;
CONSOLE_SCREEN_BUFFER_INFO scr;
hConOut = GetStdHandle (STD_OUTPUT_HANDLE);
if (hConOut != INVALID_HANDLE_VALUE)
{
if (GetConsoleScreenBufferInfo (hConOut, &scr))
{
*swp = scr.dwSize.X;
*shp = scr.srWindow.Bottom - scr.srWindow.Top + 1;
}
}
}
#endif
/* Get readline's idea of the screen size. TTY is a file descriptor open
to the terminal. If IGNORE_ENV is true, we do not pay attention to the
values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being
non-null serve to check whether or not we have initialized termcap. */
void
_rl_get_screen_size (tty, ignore_env)
int tty, ignore_env;
{
char *ss;
#if defined (TIOCGWINSZ)
struct winsize window_size;
#endif /* TIOCGWINSZ */
int wr, wc;
wr = wc = -1;
#if defined (TIOCGWINSZ)
if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
{
wc = (int) window_size.ws_col;
wr = (int) window_size.ws_row;
}
#endif /* TIOCGWINSZ */
#if defined (__EMX__)
_emx_get_screensize (&wc, &wr);
#elif defined (__MINGW32__)
_win_get_screensize (&wc, &wr);
#endif
if (ignore_env || rl_prefer_env_winsize == 0)
{
_rl_screenwidth = wc;
_rl_screenheight = wr;
}
else
_rl_screenwidth = _rl_screenheight = -1;
/* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
is unset. If we prefer the environment, check it first before
assigning the value returned by the kernel. */
if (_rl_screenwidth <= 0)
{
if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")))
_rl_screenwidth = atoi (ss);
if (_rl_screenwidth <= 0)
_rl_screenwidth = wc;
#if !defined (__DJGPP__)
if (_rl_screenwidth <= 0 && term_string_buffer)
_rl_screenwidth = tgetnum ("co");
#endif
}
/* Environment variable LINES overrides setting of "li" if IGNORE_ENV
is unset. */
if (_rl_screenheight <= 0)
{
if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")))
_rl_screenheight = atoi (ss);
if (_rl_screenheight <= 0)
_rl_screenheight = wr;
#if !defined (__DJGPP__)
if (_rl_screenheight <= 0 && term_string_buffer)
_rl_screenheight = tgetnum ("li");
#endif
}
/* If all else fails, default to 80x24 terminal. */
if (_rl_screenwidth <= 1)
_rl_screenwidth = 80;
if (_rl_screenheight <= 0)
_rl_screenheight = 24;
/* If we're being compiled as part of bash, set the environment
variables $LINES and $COLUMNS to new values. Otherwise, just
do a pair of putenv () or setenv () calls. */
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
if (_rl_term_autowrap == 0)
_rl_screenwidth--;
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
}
void
_rl_set_screen_size (rows, cols)
int rows, cols;
{
if (_rl_term_autowrap == -1)
_rl_init_terminal_io (rl_terminal_name);
if (rows > 0)
_rl_screenheight = rows;
if (cols > 0)
{
_rl_screenwidth = cols;
if (_rl_term_autowrap == 0)
_rl_screenwidth--;
}
if (rows > 0 || cols > 0)
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
}
void
rl_set_screen_size (rows, cols)
int rows, cols;
{
_rl_set_screen_size (rows, cols);
}
void
rl_get_screen_size (rows, cols)
int *rows, *cols;
{
if (rows)
*rows = _rl_screenheight;
if (cols)
*cols = _rl_screenwidth;
}
void
rl_reset_screen_size ()
{
_rl_get_screen_size (fileno (rl_instream), 0);
}
void
rl_resize_terminal ()
{
if (readline_echoing_p)
{
_rl_get_screen_size (fileno (rl_instream), 1);
if (CUSTOM_REDISPLAY_FUNC ())
rl_forced_update_display ();
else
_rl_redisplay_after_sigwinch ();
}
}
struct _tc_string {
const char *tc_var;
char **tc_value;
};
/* This should be kept sorted, just in case we decide to change the
search algorithm to something smarter. */
static struct _tc_string tc_strings[] =
{
{ "@7", &_rl_term_at7 },
{ "DC", &_rl_term_DC },
{ "IC", &_rl_term_IC },
{ "ce", &_rl_term_clreol },
{ "cl", &_rl_term_clrpag },
{ "cr", &_rl_term_cr },
{ "dc", &_rl_term_dc },
{ "ei", &_rl_term_ei },
{ "ic", &_rl_term_ic },
{ "im", &_rl_term_im },
{ "kD", &_rl_term_kD }, /* delete */
{ "kH", &_rl_term_kH }, /* home down ?? */
{ "kI", &_rl_term_kI }, /* insert */
{ "kd", &_rl_term_kd },
{ "ke", &_rl_term_ke }, /* end keypad mode */
{ "kh", &_rl_term_kh }, /* home */
{ "kl", &_rl_term_kl },
{ "kr", &_rl_term_kr },
{ "ks", &_rl_term_ks }, /* start keypad mode */
{ "ku", &_rl_term_ku },
{ "le", &_rl_term_backspace },
{ "mm", &_rl_term_mm },
{ "mo", &_rl_term_mo },
{ "nd", &_rl_term_forward_char },
{ "pc", &_rl_term_pc },
{ "up", &_rl_term_up },
{ "vb", &_rl_visible_bell },
{ "vs", &_rl_term_vs },
{ "ve", &_rl_term_ve },
};
#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
/* Read the desired terminal capability strings into BP. The capabilities
are described in the TC_STRINGS table. */
static void
get_term_capabilities (bp)
char **bp;
{
#if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
register int i;
for (i = 0; i < NUM_TC_STRINGS; i++)
*(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp);
#endif
tcap_initialized = 1;
}
int
_rl_init_terminal_io (terminal_name)
const char *terminal_name;
{
const char *term;
char *buffer;
int tty, tgetent_ret;
term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
_rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL;
tty = rl_instream ? fileno (rl_instream) : 0;
if (term == 0)
term = "dumb";
/* I've separated this out for later work on not calling tgetent at all
if the calling application has supplied a custom redisplay function,
(and possibly if the application has supplied a custom input function). */
if (CUSTOM_REDISPLAY_FUNC())
{
tgetent_ret = -1;
}
else
{
if (term_string_buffer == 0)
term_string_buffer = (char *)xmalloc(2032);
if (term_buffer == 0)
term_buffer = (char *)xmalloc(4080);
buffer = term_string_buffer;
tgetent_ret = tgetent (term_buffer, term);
}
if (tgetent_ret <= 0)
{
FREE (term_string_buffer);
FREE (term_buffer);
buffer = term_buffer = term_string_buffer = (char *)NULL;
_rl_term_autowrap = 0; /* used by _rl_get_screen_size */
/* Allow calling application to set default height and width, using
rl_set_screen_size */
if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
{
#if defined (__EMX__)
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
_rl_screenwidth--;
#else /* !__EMX__ */
_rl_get_screen_size (tty, 0);
#endif /* !__EMX__ */
}
/* Defaults. */
if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
{
_rl_screenwidth = 79;
_rl_screenheight = 24;
}
/* Everything below here is used by the redisplay code (tputs). */
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
_rl_term_cr = "\r";
_rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
_rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
_rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_kI = _rl_term_kD = (char *)NULL;
_rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
_rl_term_mm = _rl_term_mo = (char *)NULL;
_rl_term_ve = _rl_term_vs = (char *)NULL;
_rl_term_forward_char = (char *)NULL;
_rl_terminal_can_insert = term_has_meta = 0;
/* Reasonable defaults for tgoto(). Readline currently only uses
tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
change that later... */
PC = '\0';
BC = _rl_term_backspace = "\b";
UP = _rl_term_up;
return 0;
}
get_term_capabilities (&buffer);
/* Set up the variables that the termcap library expects the application
to provide. */
PC = _rl_term_pc ? *_rl_term_pc : 0;
BC = _rl_term_backspace;
UP = _rl_term_up;
if (!_rl_term_cr)
_rl_term_cr = "\r";
_rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
/* Allow calling application to set default height and width, using
rl_set_screen_size */
if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
_rl_get_screen_size (tty, 0);
/* "An application program can assume that the terminal can do
character insertion if *any one of* the capabilities `IC',
`im', `ic' or `ip' is provided." But we can't do anything if
only `ip' is provided, so... */
_rl_terminal_can_insert = (_rl_term_IC || _rl_term_im || _rl_term_ic);
/* Check to see if this terminal has a meta key and clear the capability
variables if there is none. */
term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
if (!term_has_meta)
_rl_term_mm = _rl_term_mo = (char *)NULL;
/* Attempt to find and bind the arrow keys. Do not override already
bound keys in an overzealous attempt, however. */
bind_termcap_arrow_keys (emacs_standard_keymap);
#if defined (VI_MODE)
bind_termcap_arrow_keys (vi_movement_keymap);
bind_termcap_arrow_keys (vi_insertion_keymap);
#endif /* VI_MODE */
return 0;
}
/* Bind the arrow key sequences from the termcap description in MAP. */
static void
bind_termcap_arrow_keys (map)
Keymap map;
{
Keymap xkeymap;
xkeymap = _rl_keymap;
_rl_keymap = map;
rl_bind_keyseq_if_unbound (_rl_term_ku, rl_get_previous_history);
rl_bind_keyseq_if_unbound (_rl_term_kd, rl_get_next_history);
rl_bind_keyseq_if_unbound (_rl_term_kr, rl_forward_char);
rl_bind_keyseq_if_unbound (_rl_term_kl, rl_backward_char);
rl_bind_keyseq_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */
rl_bind_keyseq_if_unbound (_rl_term_at7, rl_end_of_line); /* End */
rl_bind_keyseq_if_unbound (_rl_term_kD, rl_delete);
_rl_keymap = xkeymap;
}
char *
rl_get_termcap (cap)
const char *cap;
{
register int i;
if (tcap_initialized == 0)
return ((char *)NULL);
for (i = 0; i < NUM_TC_STRINGS; i++)
{
if (tc_strings[i].tc_var[0] == cap[0] && strcmp (tc_strings[i].tc_var, cap) == 0)
return *(tc_strings[i].tc_value);
}
return ((char *)NULL);
}
/* Re-initialize the terminal considering that the TERM/TERMCAP variable
has changed. */
int
rl_reset_terminal (terminal_name)
const char *terminal_name;
{
_rl_screenwidth = _rl_screenheight = 0;
_rl_init_terminal_io (terminal_name);
return 0;
}
/* A function for the use of tputs () */
#ifdef _MINIX
void
_rl_output_character_function (c)
int c;
{
putc (c, _rl_out_stream);
}
#else /* !_MINIX */
int
_rl_output_character_function (c)
int c;
{
return putc (c, _rl_out_stream);
}
#endif /* !_MINIX */
/* Write COUNT characters from STRING to the output stream. */
void
_rl_output_some_chars (string, count)
const char *string;
int count;
{
fwrite (string, 1, count, _rl_out_stream);
}
/* Move the cursor back. */
int
_rl_backspace (count)
int count;
{
register int i;
if (_rl_term_backspace)
for (i = 0; i < count; i++)
tputs (_rl_term_backspace, 1, _rl_output_character_function);
else
for (i = 0; i < count; i++)
putc ('\b', _rl_out_stream);
return 0;
}
/* Move to the start of the next line. */
int
rl_crlf ()
{
#if defined (NEW_TTY_DRIVER)
if (_rl_term_cr)
tputs (_rl_term_cr, 1, _rl_output_character_function);
#endif /* NEW_TTY_DRIVER */
putc ('\n', _rl_out_stream);
return 0;
}
/* Ring the terminal bell. */
int
rl_ding ()
{
if (readline_echoing_p)
{
switch (_rl_bell_preference)
{
case NO_BELL:
default:
break;
case VISIBLE_BELL:
if (_rl_visible_bell)
{
tputs (_rl_visible_bell, 1, _rl_output_character_function);
break;
}
/* FALLTHROUGH */
case AUDIBLE_BELL:
fprintf (stderr, "\007");
fflush (stderr);
break;
}
return (0);
}
return (-1);
}
/* **************************************************************** */
/* */
/* Controlling the Meta Key and Keypad */
/* */
/* **************************************************************** */
void
_rl_enable_meta_key ()
{
#if !defined (__DJGPP__)
if (term_has_meta && _rl_term_mm)
tputs (_rl_term_mm, 1, _rl_output_character_function);
#endif
}
void
_rl_control_keypad (on)
int on;
{
#if !defined (__DJGPP__)
if (on && _rl_term_ks)
tputs (_rl_term_ks, 1, _rl_output_character_function);
else if (!on && _rl_term_ke)
tputs (_rl_term_ke, 1, _rl_output_character_function);
#endif
}
/* **************************************************************** */
/* */
/* Controlling the Cursor */
/* */
/* **************************************************************** */
/* Set the cursor appropriately depending on IM, which is one of the
insert modes (insert or overwrite). Insert mode gets the normal
cursor. Overwrite mode gets a very visible cursor. Only does
anything if we have both capabilities. */
void
_rl_set_cursor (im, force)
int im, force;
{
if (_rl_term_ve && _rl_term_vs)
{
if (force || im != rl_insert_mode)
{
if (im == RL_IM_OVERWRITE)
tputs (_rl_term_vs, 1, _rl_output_character_function);
else
tputs (_rl_term_ve, 1, _rl_output_character_function);
}
}
}
+1 -1
View File
@@ -66,7 +66,7 @@
in words, or 1 if it is. */
int _rl_allow_pathname_alphabetic_chars = 0;
static const char *pathname_alphabetic_chars = "/-_=~.#$";
static const char * const pathname_alphabetic_chars = "/-_=~.#$";
int
rl_alphabetic (c)
+445
View File
@@ -0,0 +1,445 @@
/* util.c -- readline utility functions */
/* Copyright (C) 1987-2005 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.
The GNU Readline Library 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.
The GNU Readline Library 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.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
#include "posixjmp.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h> /* for _POSIX_VERSION */
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include <stdio.h>
#include <ctype.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
#if defined (TIOCSTAT_IN_SYS_IOCTL)
# include <sys/ioctl.h>
#endif /* TIOCSTAT_IN_SYS_IOCTL */
/* Some standard library routines. */
#include "readline.h"
#include "rlprivate.h"
#include "xmalloc.h"
/* **************************************************************** */
/* */
/* Utility Functions */
/* */
/* **************************************************************** */
/* Return 0 if C is not a member of the class of characters that belong
in words, or 1 if it is. */
int _rl_allow_pathname_alphabetic_chars = 0;
static const char *pathname_alphabetic_chars = "/-_=~.#$";
int
rl_alphabetic (c)
int c;
{
if (ALPHABETIC (c))
return (1);
return (_rl_allow_pathname_alphabetic_chars &&
strchr (pathname_alphabetic_chars, c) != NULL);
}
#if defined (HANDLE_MULTIBYTE)
int
_rl_walphabetic (wc)
wchar_t wc;
{
int c;
if (iswalnum (wc))
return (1);
c = wc & 0177;
return (_rl_allow_pathname_alphabetic_chars &&
strchr (pathname_alphabetic_chars, c) != NULL);
}
#endif
/* How to abort things. */
int
_rl_abort_internal ()
{
rl_ding ();
rl_clear_message ();
_rl_reset_argument ();
rl_clear_pending_input ();
RL_UNSETSTATE (RL_STATE_MACRODEF);
while (rl_executing_macro)
_rl_pop_executing_macro ();
rl_last_func = (rl_command_func_t *)NULL;
longjmp (readline_top_level, 1);
return (0);
}
int
rl_abort (count, key)
int count, key;
{
return (_rl_abort_internal ());
}
int
rl_tty_status (count, key)
int count, key;
{
#if defined (TIOCSTAT)
ioctl (1, TIOCSTAT, (char *)0);
rl_refresh_line (count, key);
#else
rl_ding ();
#endif
return 0;
}
/* Return a copy of the string between FROM and TO.
FROM is inclusive, TO is not. */
char *
rl_copy_text (from, to)
int from, to;
{
register int length;
char *copy;
/* Fix it if the caller is confused. */
if (from > to)
SWAP (from, to);
length = to - from;
copy = (char *)xmalloc (1 + length);
strncpy (copy, rl_line_buffer + from, length);
copy[length] = '\0';
return (copy);
}
/* Increase the size of RL_LINE_BUFFER until it has enough space to hold
LEN characters. */
void
rl_extend_line_buffer (len)
int len;
{
while (len >= rl_line_buffer_len)
{
rl_line_buffer_len += DEFAULT_BUFFER_SIZE;
rl_line_buffer = (char *)xrealloc (rl_line_buffer, rl_line_buffer_len);
}
_rl_set_the_line ();
}
/* A function for simple tilde expansion. */
int
rl_tilde_expand (ignore, key)
int ignore, key;
{
register int start, end;
char *homedir, *temp;
int len;
end = rl_point;
start = end - 1;
if (rl_point == rl_end && rl_line_buffer[rl_point] == '~')
{
homedir = tilde_expand ("~");
_rl_replace_text (homedir, start, end);
return (0);
}
else if (rl_line_buffer[start] != '~')
{
for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--)
;
start++;
}
end = start;
do
end++;
while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end);
if (whitespace (rl_line_buffer[end]) || end >= rl_end)
end--;
/* If the first character of the current word is a tilde, perform
tilde expansion and insert the result. If not a tilde, do
nothing. */
if (rl_line_buffer[start] == '~')
{
len = end - start + 1;
temp = (char *)xmalloc (len + 1);
strncpy (temp, rl_line_buffer + start, len);
temp[len] = '\0';
homedir = tilde_expand (temp);
xfree (temp);
_rl_replace_text (homedir, start, end);
}
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 */
/* */
/* **************************************************************** */
/* Determine if s2 occurs in s1. If so, return a pointer to the
match in s1. The compare is case insensitive. */
char *
_rl_strindex (s1, s2)
register const char *s1, *s2;
{
register int i, l, len;
for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
if (_rl_strnicmp (s1 + i, s2, l) == 0)
return ((char *) (s1 + i));
return ((char *)NULL);
}
#ifndef HAVE_STRPBRK
/* Find the first occurrence in STRING1 of any character from STRING2.
Return a pointer to the character in STRING1. */
char *
_rl_strpbrk (string1, string2)
const char *string1, *string2;
{
register const char *scan;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
register int i, v;
memset (&ps, 0, sizeof (mbstate_t));
#endif
for (; *string1; string1++)
{
for (scan = string2; *scan; scan++)
{
if (*string1 == *scan)
return ((char *)string1);
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
v = _rl_get_char_len (string1, &ps);
if (v > 1)
string1 += v - 1; /* -1 to account for auto-increment in loop */
}
#endif
}
return ((char *)NULL);
}
#endif
#if !defined (HAVE_STRCASECMP)
/* Compare at most COUNT characters from string1 to string2. Case
doesn't matter. */
int
_rl_strnicmp (string1, string2, count)
char *string1, *string2;
int count;
{
register char ch1, ch2;
while (count)
{
ch1 = *string1++;
ch2 = *string2++;
if (_rl_to_upper(ch1) == _rl_to_upper(ch2))
count--;
else
break;
}
return (count);
}
/* strcmp (), but caseless. */
int
_rl_stricmp (string1, string2)
char *string1, *string2;
{
register char ch1, ch2;
while (*string1 && *string2)
{
ch1 = *string1++;
ch2 = *string2++;
if (_rl_to_upper(ch1) != _rl_to_upper(ch2))
return (1);
}
return (*string1 - *string2);
}
#endif /* !HAVE_STRCASECMP */
/* Stupid comparison routine for qsort () ing strings. */
int
_rl_qsort_string_compare (s1, s2)
char **s1, **s2;
{
#if defined (HAVE_STRCOLL)
return (strcoll (*s1, *s2));
#else
int result;
result = **s1 - **s2;
if (result == 0)
result = strcmp (*s1, *s2);
return result;
#endif
}
/* Function equivalents for the macros defined in chardefs.h. */
#define FUNCTION_FOR_MACRO(f) int (f) (c) int c; { return f (c); }
FUNCTION_FOR_MACRO (_rl_digit_p)
FUNCTION_FOR_MACRO (_rl_digit_value)
FUNCTION_FOR_MACRO (_rl_lowercase_p)
FUNCTION_FOR_MACRO (_rl_pure_alphabetic)
FUNCTION_FOR_MACRO (_rl_to_lower)
FUNCTION_FOR_MACRO (_rl_to_upper)
FUNCTION_FOR_MACRO (_rl_uppercase_p)
/* A convenience function, to force memory deallocation to be performed
by readline. DLLs on Windows apparently require this. */
void
rl_free (mem)
void *mem;
{
if (mem)
free (mem);
}
/* Backwards compatibility, now that savestring has been removed from
all `public' readline header files. */
#undef _rl_savestring
char *
_rl_savestring (s)
const char *s;
{
return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
}
+16 -10
View File
@@ -1,7 +1,7 @@
/* vi_mode.c -- A vi emulation mode for Bash.
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
/* Copyright (C) 1987-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.
@@ -69,7 +69,7 @@ int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */
static int _rl_vi_doing_insert;
/* Command keys which do movement for xxx_to commands. */
static const char *vi_motion = " hl^$0ftFT;,%wbeWBE|";
static const char * const vi_motion = " hl^$0ftFT;,%wbeWBE|`";
/* Keymap used for vi replace characters. Created dynamically since
rarely used. */
@@ -101,7 +101,7 @@ static int _rl_vi_last_key_before_insert;
static int vi_redoing;
/* Text modification commands. These are the `redoable' commands. */
static const char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
static const char * const vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
/* Arrays for the saved marks. */
static int vi_mark_chars['z' - 'a' + 1];
@@ -1033,13 +1033,15 @@ int
rl_vi_delete_to (count, key)
int count, key;
{
int c;
int c, start_pos;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
else if (vi_redoing)
rl_stuff_char (_rl_vi_last_motion);
start_pos = rl_point;
if (rl_vi_domove (key, &c))
{
rl_ding ();
@@ -1048,7 +1050,8 @@ rl_vi_delete_to (count, key)
/* These are the motion commands that do not require adjusting the
mark. */
if ((strchr (" l|h^0bB", c) == 0) && (rl_mark < rl_end))
if (((strchr (" l|h^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
(rl_mark < rl_end))
rl_mark++;
rl_kill_text (rl_point, rl_mark);
@@ -1077,7 +1080,8 @@ rl_vi_change_to (count, key)
/* These are the motion commands that do not require adjusting the
mark. c[wW] are handled by special-case code in rl_vi_domove(),
and already leave the mark at the correct location. */
if ((strchr (" l|hwW^0bB", c) == 0) && (rl_mark < rl_end))
if (((strchr (" l|hwW^0bBFT`", c) == 0) && (rl_point >= start_pos)) &&
(rl_mark < rl_end))
rl_mark++;
/* The cursor never moves with c[wW]. */
@@ -1112,12 +1116,13 @@ int
rl_vi_yank_to (count, key)
int count, key;
{
int c, save;
int c, start_pos;
save = rl_point;
if (_rl_uppercase_p (key))
rl_stuff_char ('$');
start_pos = rl_point;
if (rl_vi_domove (key, &c))
{
rl_ding ();
@@ -1126,14 +1131,15 @@ rl_vi_yank_to (count, key)
/* These are the motion commands that do not require adjusting the
mark. */
if ((strchr (" l|h^0%bB", c) == 0) && (rl_mark < rl_end))
if (((strchr (" l|h^0%bBFT`", c) == 0) && (rl_point >= start_pos)) &&
(rl_mark < rl_end))
rl_mark++;
rl_begin_undo_group ();
rl_kill_text (rl_point, rl_mark);
rl_end_undo_group ();
rl_do_undo ();
rl_point = save;
rl_point = start_pos;
return (0);
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -3859,7 +3859,7 @@ reset_readline_prompt ()
/* A list of tokens which can be followed by newlines, but not by
semi-colons. When concatenating multiple lines of history, the
newline separator for such tokens is replaced with a space. */
static int no_semi_successors[] = {
static const int no_semi_successors[] = {
'\n', '{', '(', ')', ';', '&', '|',
CASE, DO, ELSE, IF, SEMI_SEMI, THEN, UNTIL, WHILE, AND_AND, OR_OR, IN,
0
+9 -12
View File
@@ -2593,10 +2593,7 @@ read_token (command)
}
if (parser_state & PST_REGEXP)
{
itrace("read_token: parser_state & PST_REGEXP; goto tokword");
goto tokword;
}
/* Shell meta-characters. */
if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0))
@@ -3211,10 +3208,10 @@ cond_term ()
op = yylval.word;
#if defined (COND_REGEXP)
else if (tok == WORD && STREQ (yylval.word->word, "=~"))
{
op = yylval.word;
parser_state |= PST_REGEXP;
}
{
op = yylval.word;
parser_state |= PST_REGEXP;
}
#endif
else if (tok == '<' || tok == '>')
op = make_word_from_token (tok); /* ( */
@@ -3245,7 +3242,7 @@ parser_state |= PST_REGEXP;
/* rhs */
tok = read_token (READ);
parser_state &= ~PST_REGEXP;
parser_state &= ~PST_REGEXP;
if (tok == WORD)
{
tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
@@ -3436,9 +3433,9 @@ read_token_word (character)
we need to special-case characters special to both the shell and
regular expressions. Right now, that is only '(' and '|'. */ /*)*/
if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|')) /*)*/
{
if (character == '|')
goto got_character;
{
if (character == '|')
goto got_character;
push_delimiter (dstack, character);
ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
@@ -3453,7 +3450,7 @@ read_token_word (character)
FREE (ttok);
dollar_present = all_digit_token = 0;
goto next_character;
}
}
#endif /* COND_REGEXP */
#ifdef EXTENDED_GLOB
+12
View File
@@ -894,6 +894,16 @@ bind_compfunc_variables (line, ind, lwords, cw, exported)
if (v && exported)
VSETATTR(v, att_exported);
value = inttostr (rl_completion_type, ibuf, sizeof (ibuf));
v = bind_int_variable ("COMP_TYPE", value);
if (v && exported)
VSETATTR(v, att_exported);
value = inttostr (rl_completion_invoking_key, ibuf, sizeof (ibuf));
v = bind_int_variable ("COMP_KEY", value);
if (v && exported)
VSETATTR(v, att_exported);
/* Since array variables can't be exported, we don't bother making the
array of words. */
if (exported == 0)
@@ -914,6 +924,8 @@ unbind_compfunc_variables (exported)
{
unbind_variable ("COMP_LINE");
unbind_variable ("COMP_POINT");
unbind_variable ("COMP_TYPE");
unbind_variable ("COMP_KEY");
#ifdef ARRAY_VARS
unbind_variable ("COMP_WORDS");
unbind_variable ("COMP_CWORD");
+1405
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -375,7 +375,7 @@ here_document_to_fd (redirectee, ri)
char *filename;
int r, fd, fd2;
fd = sh_mktmpfd ("sh-thd", MT_USERANDOM, &filename);
fd = sh_mktmpfd ("sh-thd", MT_USERANDOM|MT_USETMPDIR, &filename);
/* If we failed for some reason other than the file existing, abort */
if (fd < 0)
+1086
View File
File diff suppressed because it is too large Load Diff
+11 -2
View File
@@ -139,6 +139,12 @@ int interactive_shell = 0;
shell exits. */
int hup_on_exit = 0;
/* Non-zero means to list status of running and stopped jobs at shell exit */
int check_jobs_at_exit = 0;
/* Non-zero means to change to a directory name supplied as a command name */
int autocd = 1;
/* Tells what state the shell was in when it started:
0 = non-interactive shell script
1 = interactive
@@ -172,6 +178,9 @@ time_t shell_start_time;
/* Are we running in an emacs shell window? */
int running_under_emacs;
/* Do we have /dev/fd? */
int have_devfd = HAVE_DEV_FD;
/* The name of the .(shell)rc file. */
static char *bashrc_file = "~/.bashrc";
@@ -212,8 +221,8 @@ int posixly_correct = 0; /* Non-zero means posix.2 superset. */
/* Some long-winded argument names. These are obviously new. */
#define Int 1
#define Charp 2
struct {
char *name;
static const struct {
const char *name;
int type;
int *int_value;
char **char_value;
+11 -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.
@@ -139,6 +139,12 @@ int interactive_shell = 0;
shell exits. */
int hup_on_exit = 0;
/* Non-zero means to list status of running and stopped jobs at shell exit */
int check_jobs_at_exit = 0;
/* Non-zero means to change to a directory name supplied as a command name */
int autocd = 1;
/* Tells what state the shell was in when it started:
0 = non-interactive shell script
1 = interactive
@@ -172,6 +178,9 @@ time_t shell_start_time;
/* Are we running in an emacs shell window? */
int running_under_emacs;
/* Do we have /dev/fd? */
int have_devfd = HAVE_DEV_FD;
/* The name of the .(shell)rc file. */
static char *bashrc_file = "~/.bashrc";
@@ -1731,7 +1740,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
@@ -4134,7 +4134,7 @@ make_named_pipe ()
{
char *tname;
tname = sh_mktmpname ("sh-np", MT_USERANDOM);
tname = sh_mktmpname ("sh-np", MT_USERANDOM|MT_USETMPDIR);
if (mkfifo (tname, 0600) < 0)
{
free (tname);
+1 -1
View File
@@ -6970,7 +6970,7 @@ add_string:
sindex = t_index;
goto add_character;
}
report_error (_("bad substitution: no closing \"`\" in %s"), string+t_index);
report_error (_("bad substitution: no closing \"`\" in %s") , string+t_index);
free (string);
free (istring);
return ((temp == &extract_string_error) ? &expand_word_error
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+21
View File
@@ -192,6 +192,8 @@ static SHELL_VAR *get_lineno __P((SHELL_VAR *));
static SHELL_VAR *assign_subshell __P((SHELL_VAR *, char *, arrayind_t));
static SHELL_VAR *get_subshell __P((SHELL_VAR *));
static SHELL_VAR *get_bashpid __P((SHELL_VAR *));
#if defined (HISTORY)
static SHELL_VAR *get_histcmd __P((SHELL_VAR *));
#endif
@@ -1271,6 +1273,22 @@ get_subshell (var)
return (var);
}
static SHELL_VAR *
get_bashpid (var)
SHELL_VAR *var;
{
int pid;
char *p;
pid = getpid ();
p = itos (pid);
FREE (value_cell (var));
VSETATTR (var, att_integer|att_readonly);
var_setvalue (var, p);
return (var);
}
static SHELL_VAR *
get_bash_command (var)
SHELL_VAR *var;
@@ -1452,6 +1470,9 @@ initialize_dynamic_variables ()
INIT_DYNAMIC_VAR ("LINENO", (char *)NULL, get_lineno, assign_lineno);
VSETATTR (v, att_integer);
INIT_DYNAMIC_VAR ("BASHPID", (char *)NULL, get_bashpid, null_assign);
VSETATTR (v, att_integer|att_readonly);
#if defined (HISTORY)
INIT_DYNAMIC_VAR ("HISTCMD", (char *)NULL, get_histcmd, (sh_var_assign_func_t *)NULL);
VSETATTR (v, att_integer);
+4270
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -33,15 +33,15 @@
extern char *shell_name;
/* Defines from version.h */
const char *dist_version = DISTVERSION;
int patch_level = PATCHLEVEL;
int build_version = BUILDVERSION;
const char * const dist_version = DISTVERSION;
const int patch_level = PATCHLEVEL;
const int build_version = BUILDVERSION;
#ifdef RELSTATUS
const char *release_status = RELSTATUS;
const char * const release_status = RELSTATUS;
#else
const char *release_status = (char *)0;
const char * const release_status = (char *)0;
#endif
const char *sccs_version = SCCSVERSION;
const char * const sccs_version = SCCSVERSION;
/* Functions for getting, setting, and displaying the shell version. */

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