commit bash-20040624 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 12:58:21 -05:00
parent 9f422431d6
commit da5b17cd60
28 changed files with 2484 additions and 873 deletions
+59
View File
@@ -9490,3 +9490,62 @@ subst.c
- in string_extract_double_quoted, cope with extract_delimited_string
returning NULL, as it can when attempting completion on an unclosed
command substitution
6/24
----
lib/readline/complete.c
- change print_filename to add a `/' to listed directory names if
`mark-directories' has been enabled
builtins/umask.def
- make sure that the mask passed to parse_symbolic_mode has all but
the operative low eight bits masked off, to avoid complementing
all 0s to -1, which is the error return code. This makes things
like `a=rwx' and `ugo=rwx' work and turn off the umask
6/26
----
builtins/getopts.def
- when `getopts' reaches the end of options, unset OPTARG before
returning EOF. In response to a bug report from Apple
configure.in
- when cross-compiling, don't set CPPFLAGS_FOR_BUILD and
LDFLAGS_FOR_BUILD from CPPFLAGS and LDFLAGS, respectively, since
those are for the target instead of the build platform (report
from robert@schwebel.de)
shell.c
- a shell whose standard error (but not standard output) is directed
to a terminal should be interactive, according to POSIX/SUS. This
means that sh > sh.out will start an interactive shell. Bug report
from llattanzi@apple.com
doc/{bash.1,bashref.texi}
- change mention of standard output to standard error in definition
of interactive shell
lib/readline/vi_mode.c
- new convenience function, rl_vi_start_inserting, calls
_rl_vi_set_last to save the last textmod command state and then calls
rl_vi_insertion_mode to enter insert mode
- change functions to use rl_vi_start_inserting
lib/readline/readline.h
- extern declaration for rl_vi_start_inserting
bashline.c
- new function for vi-mode completion, bash_vi_complete. Does
filename expansion as POSIX specifies, unlike the default readline
bindings (which don't know about globbing). Bound to `\', `*',
and `=' in vi command keymap. Internals very similar to
rl_vi_complete; just calls bash glob expansion functions
lib/readline/vi_mode.c
- change rl_vi_change_char so that an entire change is a single
undoable event, rather than each individual change in a [count]r
command
- fix rl_vi_change_char so that replacing characters up to EOL works
rather than generating rl_ding
- fix rl_vi_change_case so that replacing characters up to EOL works
rather than generating rl_ding
+60 -1
View File
@@ -9487,4 +9487,63 @@ lib/readline/display.c
6/2
---
subst.c
- in
- in string_extract_double_quoted, cope with extract_delimited_string
returning NULL, as it can when attempting completion on an unclosed
command substitution
6/24
----
lib/readline/complete.c
- change print_filename to add a `/' to listed directory names if
`mark-directories' has been enabled
builtins/umask.def
- make sure that the mask passed to parse_symbolic_mode has all but
the operative low eight bits masked off, to avoid complementing
all 0s to -1, which is the error return code. This makes things
like `a=rwx' and `ugo=rwx' work and turn off the umask
6/26
----
builtins/getopts.def
- when `getopts' reaches the end of options, unset OPTARG before
returning EOF. In response to a bug report from Apple
configure.in
- when cross-compiling, don't set CPPFLAGS_FOR_BUILD and
LDFLAGS_FOR_BUILD from CPPFLAGS and LDFLAGS, respectively, since
those are for the target instead of the build platform (report
from robert@schwebel.de)
shell.c
- a shell whose standard error (but not standard output) is directed
to a terminal should be interactive, according to POSIX/SUS. This
means that sh > sh.out will start an interactive shell. Bug report
from llattanzi@apple.com
doc/{bash.1,bashref.texi}
- change mention of standard output to standard error in definition
of interactive shell
lib/readline/vi_mode.c
- new convenience function, rl_vi_start_inserting, calls
_rl_vi_set_last to save the last textmod command state and then calls
rl_vi_insertion_mode to enter insert mode
- change functions to use rl_vi_start_inserting
lib/readline/readline.h
- extern declaration for rl_vi_start_inserting
bashline.c
- new function for vi-mode completion, bash_vi_complete. Does
filename expansion as POSIX specifies, unlike the default readline
bindings (which don't know about globbing). Bound to `\', `*',
and `=' in vi command keymap. Internals very similar to
rl_vi_complete; just calls bash glob expansion functions
lib/readline/vi_mode.c
- change rl_vi_change_char so that an entire change is a single
undoable event, rather than each individual change in a [count]r
command
- fix rl_vi_change_char so that replacing characters up to EOL works
rather than generating rl_ding
+196
View File
@@ -0,0 +1,196 @@
This is a terse description of the new features added to bash-3.0 since
the release of bash-2.05b. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.
1. New Features in Bash
a. ANSI string expansion now implements the \x{hexdigits} escape.
b. There is a new loadable `strftime' builtin.
c. New variable, COMP_WORDBREAKS, which controls the readline completer's
idea of word break characters.
d. The `type' builtin no longer reports on aliases unless alias expansion
will actually be performed.
e. HISTCONTROL is now a colon-separated list of values, which permits
more extensibility and backwards compatibility.
f. HISTCONTROL may now include the `erasedups' option, which causes all lines
matching a line being added to be removed from the history list.
g. `configure' has a new `--enable-multibyte' argument that permits multibyte
character support to be disabled even on systems that support it.
h. New variables to support the bash debugger: BASH_ARGC, BASH_ARGV,
BASH_SOURCE, BASH_LINENO, BASH_SUBSHELL, BASH_EXECUTION_STRING,
BASH_COMMAND
i. FUNCNAME has been changed to support the debugger: it's now an array
variable.
j. for, case, select, arithmetic commands now keep line number information
for the debugger.
k. There is a new `RETURN' trap executed when a function or sourced script
returns (not inherited child processes; inherited by command substitution
if function tracing is enabled and the debugger is active).
l. New invocation option: --debugger. Enables debugging and turns on new
`extdebug' shell option.
m. New `functrace' and `errtrace' options to `set -o' cause DEBUG and ERR
traps, respectively, to be inherited by shell functions. Equivalent to
`set -T' and `set -E' respectively. The `functrace' option also controls
whether or not the DEBUG trap is inherited by sourced scripts.
n. The DEBUG trap is run before binding the variable and running the action
list in a `for' command, binding the selection variable and running the
query in a `select' command, and before attempting a match in a `case'
command.
o. New `--enable-debugger' option to `configure' to compile in the debugger
support code.
p. `declare -F' now prints out extra line number and source file information
if the `extdebug' option is set.
q. If `extdebug' is enabled, a non-zero return value from a DEBUG trap causes
the next command to be skipped, and a return value of 2 while in a
function or sourced script forces a `return'.
r. New `caller' builtin to provide a call stack for the bash debugger.
s. The DEBUG trap is run just before the first command in a function body is
executed, for the debugger.
t. `for', `select', and `case' command heads are printed when `set -x' is
enabled.
u. There is a new {x..y} brace expansion, which is shorthand for {x.x+1,
x+2,...,y}. x and y can be integers or single characters; the sequence
may ascend or descend; the increment is always 1.
v. New ksh93-like ${!array[@]} expansion, expands to all the keys (indices)
of array.
w. New `force_fignore' shopt option; if enabled, suffixes specified by
FIGNORE cause words to be ignored when performing word completion even
if they're the only possibilities.
x. New `gnu_errfmt' shopt option; if enabled, error messages follow the `gnu
style' (filename:lineno:message) format.
y. New `-o bashdefault' option to complete and compgen; if set, causes the
whole set of bash completions to be performed if the compspec doesn't
result in a match.
z. New `-o plusdirs' option to complete and compgen; if set, causes directory
name completion to be performed and the results added to the rest of the
possible completions.
aa. `kill' is available as a builtin even when the shell is built without
job control.
bb. New HISTTIMEFORMAT variable; value is a format string to pass to
strftime(3). If set and not null, the `history' builtin prints out
timestamp information according to the specified format when displaying
history entries. If set, bash tells the history library to write out
timestamp information when the history file is written.
cc. The [[ ... ]] command has a new binary `=~' operator that performs
extended regular expression (egrep-like) matching.
dd. `configure' has a new `--enable-cond-regexp' option (enabled by default)
to enable the =~ operator and regexp matching in [[ ... ]].
ee. Subexpressions matched by the =~ operator are placed in the new
BASH_REMATCH array variable.
ff. New `failglob' option that causes an expansion error when pathname
expansion fails to produce a match.
gg. New `set -o pipefail' option that causes a pipeline to return a failure
status if any of the processes in the pipeline fail, not just the last
one.
hh. printf builtin understands two new escape sequences: \" and \?.
ii. `echo -e' understands two new escape sequences: \" and \?.
jj. The GNU `gettext' package and libintl have been integrated; the shell's
messages can be translated into different languages.
kk. The `\W' prompt expansion now abbreviates $HOME as `~', like `\w'.
ll. The error message printed when bash cannot open a shell script supplied
as argument 1 now includes the name of the shell, to better identify
the error as coming from bash.
mm. A bug that caused here documents to not work if the directory the shell
used for the temporary files was not writable has been fixed.
nn. The parameter pattern removal and substitution expansions are now much
faster and more efficient when using multibyte characters.
oo. Fixed a bug in the `shift' builtin that could cause core dumps when
reporting an out-of-range argument.
pp. The `jobs', `kill', and `wait' builtins now accept job control notation
even if job control is not enabled.
qq. The historical behavior of `trap' that allows a missing `action' argument
to cause each specified signal's handling to be reset to its default is
now only supported when `trap' is given a single non-option argument.
2. New Features in Readline
a. History expansion has a new `a' modifier equivalent to the `g' modifier
for compatibility with the BSD csh.
b. History expansion has a new `G' modifier equivalent to the BSD csh `g'
modifier, which performs a substitution once per word.
c. All non-incremental search operations may now undo the operation of
replacing the current line with the history line.
d. The text inserted by an `a' command in vi mode can be reinserted with
`.'.
e. New bindable variable, `show-all-if-unmodified'. If set, the readline
completer will list possible completions immediately if there is more
than one completion and partial completion cannot be performed.
f. There is a new application-callable `free_history_entry()' function.
g. History list entries now contain timestamp information; the history file
functions know how to read and write timestamp information associated
with each entry.
h. Four new key binding functions have been added:
rl_bind_key_if_unbound()
rl_bind_key_if_unbound_in_map()
rl_bind_keyseq_if_unbound()
rl_bind_keyseq_if_unbound_in_map()
i. New application variable, rl_completion_quote_character, set to any
quote character readline finds before it calls the application completion
function.
j. New application variable, rl_completion_suppress_quote, settable by an
application completion function. If set to non-zero, readline does not
attempt to append a closing quote to a completed word.
k. New application variable, rl_completion_found_quote, set to a non-zero
value if readline determines that the word to be completed is quoted.
Set before readline calls any application completion function.
l. New function hook, rl_completion_word_break_hook, called when readline
needs to break a line into words when completion is attempted. Allows
the word break characters to vary based on position in the line.
m. New bindable command: unix-filename-rubout. Does the same thing as
unix-word-rubout, but adds `/' to the set of word delimiters.
+9 -2
View File
@@ -1,5 +1,5 @@
@%:@! /bin/sh
@%:@ From configure.in for Bash 3.0, version 3.163, from autoconf version AC_ACVERSION.
@%:@ From configure.in for Bash 3.0, version 3.164, from autoconf version AC_ACVERSION.
@%:@ Guess values for system-dependent variables and create Makefiles.
@%:@ Generated by GNU Autoconf 2.57 for bash 3.0-rc1.
@%:@
@@ -3974,7 +3974,14 @@ if test "$opt_static_link" = yes; then
fi
fi
test -z "$CPPFLAGS_FOR_BUILD" && CPPFLAGS_FOR_BUILD="$CPPFLAGS"
if test "X$cross_compiling" = "Xno"; then
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"}
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
else
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""}
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""}
fi
test -z "$CFLAGS_FOR_BUILD" && CFLAGS_FOR_BUILD="-g"
+82 -82
View File
@@ -15,96 +15,96 @@
'configure.in'
],
{
'AC_FUNC_MEMCMP' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_PROG_MAKE_SET' => 1,
'AC_PROG_INSTALL' => 1,
'AH_OUTPUT' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
'AC_PROG_AWK' => 1,
'AC_FUNC_FSEEKO' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_HEADER_STDC' => 1,
'AC_CHECK_MEMBERS' => 1,
'AC_PROG_CPP' => 1,
'AC_FUNC_MBRTOWC' => 1,
'AC_SUBST' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'AC_CONFIG_HEADERS' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
'AC_INIT' => 1,
'm4_pattern_allow' => 1,
'AC_PROG_INSTALL' => 1,
'AC_PROG_LEX' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AM_CONDITIONAL' => 1,
'AC_PATH_X' => 1,
'AC_INIT' => 1,
'm4_pattern_forbid' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'AC_PROG_LIBTOOL' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_HEADER_TIME' => 1,
'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_SUBST' => 1,
'AC_C_INLINE' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_PROG_MAKE_SET' => 1,
'AC_CHECK_FUNCS' => 1,
'AH_OUTPUT' => 1,
'AC_CHECK_TYPES' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_HEADER_STAT' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'm4_include' => 1,
'AC_PROG_CXX' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_FUNC_MMAP' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
'AC_PROG_LN_S' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_PATH_X' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_REALLOC' => 1,
'AM_MAINTAINER_MODE' => 1,
'AC_C_INLINE' => 1,
'AC_PROG_RANLIB' => 1,
'AC_FUNC_STAT' => 1,
'AC_CHECK_FUNCS' => 1,
'AC_FUNC_ERROR_AT_LINE' => 1,
'AC_PROG_CC' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_CONFIG_FILES' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_FUNC_ALLOCA' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AM_CONDITIONAL' => 1,
'AC_FUNC_CHOWN' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_CHECK_TYPES' => 1,
'AC_PROG_LEX' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_PROG_YACC' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_CHECK_LIB' => 1,
'AC_LIBSOURCE' => 1,
'AC_FUNC_STRNLEN' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_FUNC_SETPGRP' => 1,
'AC_PROG_CXX' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_HEADER_TIME' => 1,
'AC_FUNC_MMAP' => 1,
'AC_TYPE_PID_T' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_HEADER_STAT' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_C_VOLATILE' => 1,
'AC_HEADER_MAJOR' => 1,
'AC_TYPE_UID_T' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_FUNC_FORK' => 1,
'AC_STRUCT_TM' => 1,
'AC_C_CONST' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'm4_pattern_forbid' => 1,
'AC_CANONICAL_HOST' => 1,
'include' => 1
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_CONFIG_FILES' => 1,
'AC_PROG_CPP' => 1,
'AC_FUNC_ALLOCA' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_LIBSOURCE' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'm4_pattern_allow' => 1,
'AC_PROG_CC' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_HEADER_MAJOR' => 1,
'AC_PROG_YACC' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_PROG_AWK' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_FUNC_ERROR_AT_LINE' => 1,
'AC_C_VOLATILE' => 1,
'AC_TYPE_UID_T' => 1,
'AC_FUNC_FSEEKO' => 1,
'AC_FUNC_STRNLEN' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_STRUCT_TM' => 1,
'AC_CHECK_MEMBERS' => 1,
'include' => 1,
'AC_FUNC_REALLOC' => 1,
'AC_FUNC_STAT' => 1,
'AC_FUNC_SETPGRP' => 1,
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_PROG_RANLIB' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_TYPE_PID_T' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_FUNC_MBRTOWC' => 1,
'AC_FUNC_CHOWN' => 1
}
], 'Request' )
);
+671 -671
View File
File diff suppressed because it is too large Load Diff
+46
View File
@@ -193,11 +193,13 @@ static int bash_glob_completion_internal __P((int));
static int bash_glob_complete_word __P((int, int));
static int bash_glob_expand_word __P((int, int));
static int bash_glob_list_expansions __P((int, int));
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
static int edit_and_execute_command __P((int, int, int, char *));
#if defined (VI_MODE)
static int vi_edit_and_execute_command __P((int, int));
static int bash_vi_complete __P((int, int));
#endif
static int emacs_edit_and_execute_command __P((int, int));
@@ -463,6 +465,10 @@ initialize_readline ()
# if defined (ALIAS)
rl_bind_key_if_unbound_in_map ('@', posix_edit_macros, vi_movement_keymap);
# endif
rl_bind_key_in_map ('\\', bash_vi_complete, vi_movement_keymap);
rl_bind_key_in_map ('*', bash_vi_complete, vi_movement_keymap);
rl_bind_key_in_map ('=', bash_vi_complete, vi_movement_keymap);
#endif
rl_completer_quote_characters = "'\"";
@@ -2608,6 +2614,46 @@ bash_specific_completion (what_to_do, generator)
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
#if defined (VI_MODE)
/* Completion, from vi mode's point of view. This is a modified version of
rl_vi_complete which uses the bash globbing code to implement what POSIX
specifies, which is to append a `*' and attempt filename generation (which
has the side effect of expanding any globbing characters in the word). */
static int
bash_vi_complete (count, key)
int count, key;
{
#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
int r;
if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
{
if (!whitespace (rl_line_buffer[rl_point + 1]))
rl_vi_end_word (1, 'E');
rl_point++;
}
rl_explicit_arg = 1; /* XXX - force glob_complete_word to append `*' */
if (key == '*') /* Expansion and replacement. */
r = bash_glob_expand_word (count, key);
else if (key == '=') /* List possible completions. */
r = bash_glob_list_expansions (count, key);
else if (key == '\\') /* Standard completion */
r = bash_glob_complete_word (count, key);
else
r = rl_complete (0, key);
if (key == '*' || key == '\\')
rl_vi_start_inserting (key, 1, 1);
return (r);
#else
return rl_vi_complete (count, key);
#endif /* !SPECIFIC_COMPLETION_FUNCTIONS */
}
#endif /* VI_MODE */
/* Filename quoting for completion. */
/* A function to strip unquoted quote characters (single quotes, double
quotes, and backslashes). It allows single quotes to appear
+47 -1
View File
@@ -193,11 +193,13 @@ static int bash_glob_completion_internal __P((int));
static int bash_glob_complete_word __P((int, int));
static int bash_glob_expand_word __P((int, int));
static int bash_glob_list_expansions __P((int, int));
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
static int edit_and_execute_command __P((int, int, int, char *));
#if defined (VI_MODE)
static int vi_edit_and_execute_command __P((int, int));
static int bash_vi_complete __P((int, int));
#endif
static int emacs_edit_and_execute_command __P((int, int));
@@ -463,6 +465,10 @@ initialize_readline ()
# if defined (ALIAS)
rl_bind_key_if_unbound_in_map ('@', posix_edit_macros, vi_movement_keymap);
# endif
rl_bind_key_in_map ('\\', bash_vi_complete, vi_movement_keymap);
rl_bind_key_in_map ('*', bash_vi_complete, vi_movement_keymap);
rl_bind_key_in_map ('=', bash_vi_complete, vi_movement_keymap);
#endif
rl_completer_quote_characters = "'\"";
@@ -1765,7 +1771,7 @@ cleanup_expansion_error ()
hist_verify = old_verify;
#endif
if (to_free != rl_line_buffer)
free (to_free);
FREE (to_free);
putc ('\r', rl_outstream);
rl_forced_update_display ();
}
@@ -2608,6 +2614,46 @@ bash_specific_completion (what_to_do, generator)
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
#if defined (VI_MODE)
/* Completion, from vi mode's point of view. This is a modified version of
rl_vi_complete which uses the bash globbing code to implement what POSIX
specifies, which is to append a `*' and attempt filename generation (which
has the side effect of expanding any globbing characters in the word). */
static int
bash_vi_complete (count, key)
int count, key;
{
#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
int r;
if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
{
if (!whitespace (rl_line_buffer[rl_point + 1]))
rl_vi_end_word (1, 'E');
rl_point++;
}
rl_explicit_arg = 1; /* XXX - force `*' to be appended */
if (key == '*') /* Expansion and replacement. */
r = bash_glob_expand_word (count, key);
else if (key == '=') /* List possible completions. */
r = bash_glob_list_expansions (count, key);
else if (key == '\\') /* Standard completion */
r = bash_glob_complete_word (count, key);
else
r = rl_complete (0, key);
if (key == '*' || key == '\\')
rl_vi_start_inserting (key, 1, 1);
return (r);
#else
return rl_vi_complete (count, key);
#endif /* !SPECIFIC_COMPLETION_FUNCTIONS */
}
#endif /* VI_MODE */
/* Filename quoting for completion. */
/* A function to strip unquoted quote characters (single quotes, double
quotes, and backslashes). It allows single quotes to appear
+1
View File
@@ -245,6 +245,7 @@ dogetopts (argc, argv)
if (ret == G_EOF)
{
unbind_variable ("OPTARG");
getopts_bind_variable (name, "?");
return (EXECUTION_FAILURE);
}
+322
View File
@@ -0,0 +1,322 @@
This file is getopts.def, from which is created getopts.c.
It implements the builtin "getopts" in Bash.
Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES getopts.c
$BUILTIN getopts
$FUNCTION getopts_builtin
$SHORT_DOC getopts optstring name [arg]
Getopts is used by shell procedures to parse positional parameters.
OPTSTRING contains the option letters to be recognized; if a letter
is followed by a colon, the option is expected to have an argument,
which should be separated from it by white space.
Each time it is invoked, getopts will place the next option in the
shell variable $name, initializing name if it does not exist, and
the index of the next argument to be processed into the shell
variable OPTIND. OPTIND is initialized to 1 each time the shell or
a shell script is invoked. When an option requires an argument,
getopts places that argument into the shell variable OPTARG.
getopts reports errors in one of two ways. If the first character
of OPTSTRING is a colon, getopts uses silent error reporting. In
this mode, no error messages are printed. If an invalid option is
seen, getopts places the option character found into OPTARG. If a
required argument is not found, getopts places a ':' into NAME and
sets OPTARG to the option character found. If getopts is not in
silent mode, and an invalid option is seen, getopts places '?' into
NAME and unsets OPTARG. If a required argument is not found, a '?'
is placed in NAME, OPTARG is unset, and a diagnostic message is
printed.
If the shell variable OPTERR has the value 0, getopts disables the
printing of error messages, even if the first character of
OPTSTRING is not a colon. OPTERR has the value 1 by default.
Getopts normally parses the positional parameters ($0 - $9), but if
more arguments are given, they are parsed instead.
$END
#include <config.h>
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include "../bashansi.h"
#include "../shell.h"
#include "common.h"
#include "bashgetopt.h"
#include "getopt.h"
#define G_EOF -1
#define G_INVALID_OPT -2
#define G_ARG_MISSING -3
extern char *this_command_name;
static int getopts_bind_variable __P((char *, char *));
static int dogetopts __P((int, char **));
/* getopts_reset is magic code for when OPTIND is reset. N is the
value that has just been assigned to OPTIND. */
void
getopts_reset (newind)
int newind;
{
sh_optind = newind;
sh_badopt = 0;
}
static int
getopts_bind_variable (name, value)
char *name, *value;
{
SHELL_VAR *v;
if (legal_identifier (name))
{
v = bind_variable (name, value);
return (v && (readonly_p (v) == 0)) ? EXECUTION_SUCCESS : EXECUTION_FAILURE;
}
else
{
sh_invalidid (name);
return (EXECUTION_FAILURE);
}
}
/* Error handling is now performed as specified by Posix.2, draft 11
(identical to that of ksh-88). The special handling is enabled if
the first character of the option string is a colon; this handling
disables diagnostic messages concerning missing option arguments
and invalid option characters. The handling is as follows.
INVALID OPTIONS:
name -> "?"
if (special_error) then
OPTARG = option character found
no error output
else
OPTARG unset
diagnostic message
fi
MISSING OPTION ARGUMENT;
if (special_error) then
name -> ":"
OPTARG = option character found
else
name -> "?"
OPTARG unset
diagnostic message
fi
*/
static int
dogetopts (argc, argv)
int argc;
char **argv;
{
int ret, special_error, old_opterr, i, n;
char strval[2], numval[16];
char *optstr; /* list of options */
char *name; /* variable to get flag val */
char *t;
if (argc < 3)
{
builtin_usage ();
return (EX_USAGE);
}
/* argv[0] is "getopts". */
optstr = argv[1];
name = argv[2];
argc -= 2;
argv += 2;
special_error = optstr[0] == ':';
if (special_error)
{
old_opterr = sh_opterr;
optstr++;
sh_opterr = 0; /* suppress diagnostic messages */
}
if (argc > 1)
{
sh_getopt_restore_state (argv);
t = argv[0];
argv[0] = dollar_vars[0];
ret = sh_getopt (argc, argv, optstr);
argv[0] = t;
}
else if (rest_of_args == (WORD_LIST *)NULL)
{
for (i = 0; i < 10 && dollar_vars[i]; i++)
;
sh_getopt_restore_state (dollar_vars);
ret = sh_getopt (i, dollar_vars, optstr);
}
else
{
register WORD_LIST *words;
char **v;
for (i = 0; i < 10 && dollar_vars[i]; i++)
;
for (words = rest_of_args; words; words = words->next, i++)
;
v = strvec_create (i + 1);
for (i = 0; i < 10 && dollar_vars[i]; i++)
v[i] = dollar_vars[i];
for (words = rest_of_args; words; words = words->next, i++)
v[i] = words->word->word;
v[i] = (char *)NULL;
sh_getopt_restore_state (v);
ret = sh_getopt (i, v, optstr);
free (v);
}
if (special_error)
sh_opterr = old_opterr;
/* Set the OPTIND variable in any case, to handle "--" skipping. It's
highly unlikely that 14 digits will be too few. */
if (sh_optind < 10)
{
numval[14] = sh_optind + '0';
numval[15] = '\0';
i = 14;
}
else
{
numval[i = 15] = '\0';
n = sh_optind;
do
{
numval[--i] = (n % 10) + '0';
}
while (n /= 10);
}
bind_variable ("OPTIND", numval + i);
/* If an error occurred, decide which one it is and set the return
code appropriately. In all cases, the option character in error
is in OPTOPT. If an invalid option was encountered, OPTARG is
NULL. If a required option argument was missing, OPTARG points
to a NULL string (that is, sh_optarg[0] == 0). */
if (ret == '?')
{
if (sh_optarg == NULL)
ret = G_INVALID_OPT;
else if (sh_optarg[0] == '\0')
ret = G_ARG_MISSING;
}
if (ret == G_EOF)
{
getopts_bind_variable (name, "?");
return (EXECUTION_FAILURE);
}
if (ret == G_INVALID_OPT)
{
/* Invalid option encountered. */
ret = getopts_bind_variable (name, "?");
if (special_error)
{
strval[0] = (char)sh_optopt;
strval[1] = '\0';
bind_variable ("OPTARG", strval);
}
else
unbind_variable ("OPTARG");
return (ret);
}
if (ret == G_ARG_MISSING)
{
/* Required argument missing. */
if (special_error)
{
ret = getopts_bind_variable (name, ":");
strval[0] = (char)sh_optopt;
strval[1] = '\0';
bind_variable ("OPTARG", strval);
}
else
{
ret = getopts_bind_variable (name, "?");
unbind_variable ("OPTARG");
}
return (ret);
}
bind_variable ("OPTARG", sh_optarg);
strval[0] = (char) ret;
strval[1] = '\0';
return (getopts_bind_variable (name, strval));
}
/* The getopts builtin. Build an argv, and call dogetopts with it. */
int
getopts_builtin (list)
WORD_LIST *list;
{
char **av;
int ac, ret;
if (list == 0)
{
builtin_usage ();
return EX_USAGE;
}
reset_internal_getopt ();
if (internal_getopt (list, "") != -1)
{
builtin_usage ();
return (EX_USAGE);
}
list = loptend;
av = make_builtin_argv (list, &ac);
ret = dogetopts (ac, av);
free ((char *)av);
return (ret);
}
+2 -2
View File
@@ -1,7 +1,7 @@
This file is umask.def, from which is created umask.c.
It implements the builtin "umask" in Bash.
Copyright (C) 1987-2002 Free Software Foundation, Inc.
Copyright (C) 1987-2004 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -300,7 +300,7 @@ symbolic_umask (list)
/* All work is done with the complement of the umask -- it's
more intuitive and easier to deal with. It is complemented
again before being returned. */
bits = parse_symbolic_mode (list->word->word, ~um);
bits = parse_symbolic_mode (list->word->word, ~um & 0777);
if (bits == -1)
return (-1);
Vendored
+9 -2
View File
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in for Bash 3.0, version 3.163, from autoconf version AC_ACVERSION.
# From configure.in for Bash 3.0, version 3.164, from autoconf version AC_ACVERSION.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.57 for bash 3.0-rc1.
#
@@ -3974,7 +3974,14 @@ if test "$opt_static_link" = yes; then
fi
fi
test -z "$CPPFLAGS_FOR_BUILD" && CPPFLAGS_FOR_BUILD="$CPPFLAGS"
if test "X$cross_compiling" = "Xno"; then
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"}
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
else
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""}
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""}
fi
test -z "$CFLAGS_FOR_BUILD" && CFLAGS_FOR_BUILD="-g"
+9 -2
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.0, version 3.163, from autoconf version] AC_ACVERSION)dnl
AC_REVISION([for Bash 3.0, version 3.164, from autoconf version] AC_ACVERSION)dnl
define(bashvers, 3.0)
define(relstatus, rc1)
@@ -433,7 +433,14 @@ if test "$opt_static_link" = yes; then
fi
fi
test -z "$CPPFLAGS_FOR_BUILD" && CPPFLAGS_FOR_BUILD="$CPPFLAGS"
if test "X$cross_compiling" = "Xno"; then
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"}
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
else
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""}
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""}
fi
test -z "$CFLAGS_FOR_BUILD" && CFLAGS_FOR_BUILD="-g"
AC_SUBST(CFLAGS)
+8 -17
View File
@@ -5,7 +5,7 @@ dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
# Copyright (C) 1987-2003 Free Software Foundation, Inc.
# Copyright (C) 1987-2004 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
@@ -22,10 +22,10 @@ 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.0, version 3.159, from autoconf version] AC_ACVERSION)dnl
AC_REVISION([for Bash 3.0, version 3.163, from autoconf version] AC_ACVERSION)dnl
define(bashvers, 3.0)
define(relstatus, alpha)
define(relstatus, rc1)
AC_INIT(bash, bashvers-relstatus, bug-bash@gnu.org)
@@ -679,13 +679,15 @@ AC_FUNC_MMAP
AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify dcgettext mempcpy \
munmap stpcpy strcspn strdup])
INTL_DEP= INTL_INC=
INTL_DEP= INTL_INC= LIBINTL_H=
if test "x$USE_INCLUDED_LIBINTL" = "xyes"; then
INTL_DEP='${INTL_LIBDIR}/libintl.a'
INTL_INC='-I${INTL_LIBSRC}'
INTL_INC='-I${INTL_LIBSRC} -I${INTL_BUILDDIR}'
LIBINTL_H='${INTL_BUILDDIR}/libintl.h'
fi
AC_SUBST(INTL_DEP)
AC_SUBST(INTL_INC)
AC_SUBST(LIBINTL_H)
dnl
dnl End of checks needed by files in lib/intl
@@ -798,6 +800,7 @@ BASH_STRUCT_TERMIOS_LDISC
BASH_STRUCT_TERMIO_LDISC
BASH_STRUCT_DIRENT_D_INO
BASH_STRUCT_DIRENT_D_FILENO
BASH_STRUCT_DIRENT_D_NAMLEN
BASH_STRUCT_WINSIZE
BASH_STRUCT_TIMEVAL
AC_CHECK_MEMBERS([struct stat.st_blocks])
@@ -830,18 +833,6 @@ else
AC_DEFINE(HAVE_STD_UNSETENV)
fi
dnl I have removed this check. The existing libc FNM_EXTMATCH implementation
dnl (glibc-2.2.4) disagrees with bash on the matching of incorrectly-formed
dnl patterns (bash treats them as strings or characters to be matched without
dnl any special meaning) and has one outright bug: a[X-]b should match
dnl both a-b and aXb.
dnl
dnl Once Ulrich and I get together on this, the check can return
dnl
dnl chet 10/31/2001
dnl
dnl BASH_FUNC_FNMATCH_EXTMATCH
BASH_FUNC_PRINTF_A_FORMAT
dnl presence and behavior of OS functions
+3 -3
View File
@@ -6,12 +6,12 @@
.\" Case Western Reserve University
.\" chet@po.CWRU.Edu
.\"
.\" Last Change: Thu May 27 21:40:47 EDT 2004
.\" Last Change: Sat Jun 26 14:26:44 EDT 2004
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2004 May 27" "GNU Bash-3.0"
.TH BASH 1 "2004 June 26" "GNU Bash-3.0"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -269,7 +269,7 @@ An \fIinteractive\fP shell is one started without non-option arguments
and without the
.B \-c
option
whose standard input and output are
whose standard input and error are
both connected to terminals (as determined by
.IR isatty (3)),
or one started with the
+7 -10
View File
@@ -7089,18 +7089,15 @@ to the processes named by
or
.IR jobspec .
.I sigspec
is either a signal name such as
is either a case-insensitive signal name such as
.SM
.B SIGKILL
or a signal number;
.I signum
is a signal number. If
.I sigspec
is a signal name, the name may be
given with or without the
(with or without the
.SM
.B SIG
prefix.
prefix) or a signal number;
.I signum
is a signal number.
If
.I sigspec
is not present, then
@@ -8186,8 +8183,8 @@ If
.I arg
is absent (and there is a single \fIsigspec\fP) or
.BR \- ,
all specified signals are
reset to their original values (the values they had
each specified signal is
reset to its original disposition (the value it had
upon entrance to the shell).
If
.I arg
+1 -1
View File
@@ -5046,7 +5046,7 @@ the same, but the effective user id is not reset.
An interactive shell
is one started without non-option arguments, unless @option{-s} is
specified, without specifiying the @option{-c} option, and
whose input and output are both
whose input and error output are both
connected to terminals (as determined by @code{isatty(3)}),
or one started with the @option{-i} option.
+5 -4
View File
@@ -2975,8 +2975,8 @@ trap [-lp] [@var{arg}] [@var{sigspec} @dots{}]
The commands in @var{arg} are to be read and executed when the
shell receives signal @var{sigspec}. If @var{arg} is absent (and
there is a single @var{sigspec}) or
equal to @samp{-}, all specified signals are reset to the values
they had when the shell was started.
equal to @samp{-}, each specified signal's disposition is reset
to the value it had when the shell was started.
If @var{arg} is the null string, then the signal specified by
each @var{sigspec} is ignored by the shell and commands it invokes.
If @var{arg} is not present and @option{-p} has been supplied,
@@ -6199,8 +6199,9 @@ kill -l [@var{exit_status}]
@end example
Send a signal specified by @var{sigspec} or @var{signum} to the process
named by job specification @var{jobspec} or process @sc{id} @var{pid}.
@var{sigspec} is either a signal name such as @code{SIGINT} (with or without
the @code{SIG} prefix) or a signal number; @var{signum} is a signal number.
@var{sigspec} is either a case-insensitive signal name such as
@code{SIGINT} (with or without the @code{SIG} prefix)
or a signal number; @var{signum} is a signal number.
If @var{sigspec} and @var{signum} are not present, @code{SIGTERM} is used.
The @option{-l} option lists the signal names.
If any arguments are supplied when @option{-l} is given, the names of the
+3 -3
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2004 Free Software Foundation, Inc.
@set EDITION 3.0
@set VERSION 3.0-rc1
@set UPDATED 27 May 2004
@set UPDATED-MONTH May 2004
@set UPDATED 26 June 2004
@set UPDATED-MONTH June 2004
@set LASTCHANGE Thu May 27 22:10:33 EDT 2004
@set LASTCHANGE Sat Jun 26 14:26:27 EDT 2004
+2 -2
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2004 Free Software Foundation, Inc.
@set EDITION 3.0
@set VERSION 3.0-rc1
@set UPDATED 24 May 2004
@set UPDATED 27 May 2004
@set UPDATED-MONTH May 2004
@set LASTCHANGE Mon May 24 14:57:25 EDT 2004
@set LASTCHANGE Thu May 27 22:10:33 EDT 2004
+31 -10
View File
@@ -99,6 +99,8 @@ rl_compdisp_func_t *rl_completion_display_matches_hook = (rl_compdisp_func_t *)N
static int stat_char PARAMS((char *));
#endif
static int path_isdir PARAMS((const char *));
static char *rl_quote_filename PARAMS((char *, int, char *));
static void set_completion_defaults PARAMS((int));
@@ -451,6 +453,15 @@ _rl_internal_pager (lines)
return 0;
}
static int
path_isdir (filename)
const char *filename;
{
struct stat finfo;
return (stat (filename, &finfo) == 0 && S_ISDIR (finfo.st_mode));
}
#if defined (VISIBLE_STATS)
/* Return the character which best describes FILENAME.
`@' for symbolic links
@@ -671,17 +682,16 @@ static int
print_filename (to_print, full_pathname)
char *to_print, *full_pathname;
{
int printed_len;
char *s;
#if defined (VISIBLE_STATS)
char c, *new_full_pathname;
int extension_char, slen, tlen;
#endif
int printed_len, extension_char, slen, tlen;
char *s, c, *new_full_pathname;
printed_len = fnprint (to_print);
#if defined (VISIBLE_STATS)
if (rl_filename_completion_desired && rl_visible_stats)
if (rl_filename_completion_desired && (rl_visible_stats || _rl_complete_mark_directories))
#else
if (rl_filename_completion_desired && _rl_complete_mark_directories)
#endif
{
/* If to_print != full_pathname, to_print is the basename of the
path passed. In this case, we try to expand the directory
@@ -708,7 +718,13 @@ print_filename (to_print, full_pathname)
new_full_pathname[slen] = '/';
strcpy (new_full_pathname + slen + 1, to_print);
extension_char = stat_char (new_full_pathname);
#if defined (VISIBLE_STATS)
if (rl_visible_stats)
extension_char = stat_char (new_full_pathname);
else
#endif
if (path_isdir (new_full_pathname))
extension_char = '/';
free (new_full_pathname);
to_print[-1] = c;
@@ -716,7 +732,13 @@ print_filename (to_print, full_pathname)
else
{
s = tilde_expand (full_pathname);
extension_char = stat_char (s);
#if defined (VISIBLE_STATS)
if (rl_visible_stats)
extension_char = stat_char (s);
else
#endif
if (path_isdir (new_full_pathname))
extension_char = '/';
}
free (s);
@@ -726,7 +748,6 @@ print_filename (to_print, full_pathname)
printed_len++;
}
}
#endif /* VISIBLE_STATS */
return printed_len;
}
+2
View File
@@ -259,6 +259,8 @@ 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));
+828
View File
@@ -0,0 +1,828 @@
/* Readline.h -- the names of functions callable from within readline. */
/* Copyright (C) 1987-2004 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 0x0500 /* Readline 5.0 */
#define RL_VERSION_MAJOR 5
#define RL_VERSION_MINOR 0
/* 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_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));
/* 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 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 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));
/* 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 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, 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;
/* 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 0x00000 /* no state; before first call */
#define RL_STATE_INITIALIZING 0x00001 /* initializing */
#define RL_STATE_INITIALIZED 0x00002 /* initialization done */
#define RL_STATE_TERMPREPPED 0x00004 /* terminal is prepped */
#define RL_STATE_READCMD 0x00008 /* reading a command key */
#define RL_STATE_METANEXT 0x00010 /* reading input after ESC */
#define RL_STATE_DISPATCHING 0x00020 /* dispatching to a command */
#define RL_STATE_MOREINPUT 0x00040 /* reading more input in a command function */
#define RL_STATE_ISEARCH 0x00080 /* doing incremental search */
#define RL_STATE_NSEARCH 0x00100 /* doing non-inc search */
#define RL_STATE_SEARCH 0x00200 /* doing a history search */
#define RL_STATE_NUMERICARG 0x00400 /* reading numeric argument */
#define RL_STATE_MACROINPUT 0x00800 /* getting input from a macro */
#define RL_STATE_MACRODEF 0x01000 /* defining keyboard macro */
#define RL_STATE_OVERWRITE 0x02000 /* overwrite mode */
#define RL_STATE_COMPLETING 0x04000 /* doing completion */
#define RL_STATE_SIGHANDLER 0x08000 /* in readline sighandler */
#define RL_STATE_UNDOING 0x10000 /* doing an undo */
#define RL_STATE_INPUTPENDING 0x20000 /* rl_execute_next called */
#define RL_STATE_TTYCSAVED 0x40000 /* tty special chars saved */
#define RL_STATE_DONE 0x80000 /* 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;
/* 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_ */
+32 -20
View File
@@ -136,6 +136,16 @@ _rl_vi_set_last (key, repeat, sign)
_rl_vi_last_arg_sign = sign;
}
/* A convenience function that calls _rl_vi_set_last to save the last command
information and enters insertion mode. */
void
rl_vi_start_inserting (key, repeat, sign)
int key, repeat, sign;
{
_rl_vi_set_last (key, repeat, sign);
rl_vi_insertion_mode (1, key);
}
/* Is the command C a VI mode text modification command? */
int
_rl_vi_textmod_command (c)
@@ -298,10 +308,8 @@ rl_vi_complete (ignore, key)
rl_complete (0, key);
if (key == '*' || key == '\\')
{
_rl_vi_set_last (key, 1, rl_arg_sign);
rl_vi_insertion_mode (1, key);
}
rl_vi_start_inserting (key, 1, rl_arg_sign);
return (0);
}
@@ -311,8 +319,7 @@ rl_vi_tilde_expand (ignore, key)
int ignore, key;
{
rl_tilde_expand (0, key);
_rl_vi_set_last (key, 1, rl_arg_sign); /* XXX */
rl_vi_insertion_mode (1, key);
rl_vi_start_inserting (key, 1, rl_arg_sign);
return (0);
}
@@ -727,12 +734,13 @@ int
rl_vi_change_case (count, ignore)
int count, ignore;
{
char c = 0;
int c, p;
/* Don't try this on an empty line. */
if (rl_point >= rl_end)
return (0);
c = 0;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
return (_rl_vi_change_mbchar_case (count));
@@ -754,8 +762,11 @@ rl_vi_change_case (count, ignore)
/* Vi is kind of strange here. */
if (c)
{
p = rl_point;
rl_begin_undo_group ();
rl_delete (1, c);
rl_vi_delete (1, c);
if (rl_point < p) /* Did we retreat at EOL? */
rl_point++;
_rl_insert_char (1, c);
rl_end_undo_group ();
rl_vi_check ();
@@ -1020,8 +1031,7 @@ rl_vi_change_to (count, key)
/* `C' does not save the text inserted for undoing or redoing. */
if (_rl_uppercase_p (key) == 0)
_rl_vi_doing_insert = 1;
_rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
rl_vi_insertion_mode (1, key);
rl_vi_start_inserting (key, rl_numeric_arg, rl_arg_sign);
}
return (0);
@@ -1270,14 +1280,14 @@ rl_vi_bracktype (c)
/* XXX - think about reading an entire mbchar with _rl_read_mbchar and
inserting it in one bunch instead of the loop below (like in
rl_vi_char_search or _rl_vi_change_mbchar_case. Set c to mbchar[0]
rl_vi_char_search or _rl_vi_change_mbchar_case). Set c to mbchar[0]
for test against 033 or ^C. Make sure that _rl_read_mbchar does
this right. */
int
rl_vi_change_char (count, key)
int count, key;
{
int c;
int c, p;
if (vi_redoing)
c = _rl_vi_last_replacement;
@@ -1291,11 +1301,11 @@ rl_vi_change_char (count, key)
if (c == '\033' || c == CTRL ('C'))
return -1;
rl_begin_undo_group ();
while (count-- && rl_point < rl_end)
{
rl_begin_undo_group ();
rl_delete (1, c);
p = rl_point;
rl_vi_delete (1, c);
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
while (_rl_insert_char (1, c))
@@ -1306,12 +1316,14 @@ rl_vi_change_char (count, key)
}
else
#endif
_rl_insert_char (1, c);
if (count == 0)
rl_backward_char (1, c);
rl_end_undo_group ();
{
if (rl_point < p) /* Did we retreat at EOL? */
rl_point++;
_rl_insert_char (1, c);
}
}
rl_end_undo_group ();
return (0);
}
+27 -19
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, 1989, 1992 Free Software Foundation, Inc.
/* Copyright (C) 1987-2004 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.
@@ -136,6 +136,16 @@ _rl_vi_set_last (key, repeat, sign)
_rl_vi_last_arg_sign = sign;
}
/* A convenience function that calls _rl_vi_set_last to save the last command
information and enters insertion mode. */
void
rl_vi_start_inserting (key, repeat, sign)
int key, repeat, sign;
{
_rl_vi_set_last (key, repeat, sign);
rl_vi_insertion_mode (1, key);
}
/* Is the command C a VI mode text modification command? */
int
_rl_vi_textmod_command (c)
@@ -298,10 +308,8 @@ rl_vi_complete (ignore, key)
rl_complete (0, key);
if (key == '*' || key == '\\')
{
_rl_vi_set_last (key, 1, rl_arg_sign);
rl_vi_insertion_mode (1, key);
}
rl_vi_start_inserting (key, 1, rl_arg_sign);
return (0);
}
@@ -311,8 +319,7 @@ rl_vi_tilde_expand (ignore, key)
int ignore, key;
{
rl_tilde_expand (0, key);
_rl_vi_set_last (key, 1, rl_arg_sign); /* XXX */
rl_vi_insertion_mode (1, key);
rl_vi_start_inserting (key, 1, rl_arg_sign);
return (0);
}
@@ -1020,8 +1027,7 @@ rl_vi_change_to (count, key)
/* `C' does not save the text inserted for undoing or redoing. */
if (_rl_uppercase_p (key) == 0)
_rl_vi_doing_insert = 1;
_rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
rl_vi_insertion_mode (1, key);
rl_vi_start_inserting (key, rl_numeric_arg, rl_arg_sign);
}
return (0);
@@ -1270,14 +1276,14 @@ rl_vi_bracktype (c)
/* XXX - think about reading an entire mbchar with _rl_read_mbchar and
inserting it in one bunch instead of the loop below (like in
rl_vi_char_search or _rl_vi_change_mbchar_case. Set c to mbchar[0]
rl_vi_char_search or _rl_vi_change_mbchar_case). Set c to mbchar[0]
for test against 033 or ^C. Make sure that _rl_read_mbchar does
this right. */
int
rl_vi_change_char (count, key)
int count, key;
{
int c;
int c, p;
if (vi_redoing)
c = _rl_vi_last_replacement;
@@ -1291,11 +1297,11 @@ rl_vi_change_char (count, key)
if (c == '\033' || c == CTRL ('C'))
return -1;
rl_begin_undo_group ();
while (count-- && rl_point < rl_end)
{
rl_begin_undo_group ();
rl_delete (1, c);
p = rl_point;
rl_vi_delete (1, c);
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
while (_rl_insert_char (1, c))
@@ -1306,12 +1312,14 @@ rl_vi_change_char (count, key)
}
else
#endif
_rl_insert_char (1, c);
if (count == 0)
rl_backward_char (1, c);
rl_end_undo_group ();
{
if (rl_point < p) /* Did we retreat at EOL? */
rl_point++;
_rl_insert_char (1, c);
}
}
rl_end_undo_group ();
return (0);
}
+2 -2
View File
@@ -477,7 +477,7 @@ main (argc, argv, env)
no -c command
no arguments remaining or the -s flag given
standard input is a terminal
standard output is a terminal
standard error is a terminal
Refer to Posix.2, the description of the `sh' utility. */
if (forced_interactive || /* -i flag */
@@ -486,7 +486,7 @@ main (argc, argv, env)
((arg_index == argc) || /* no remaining args or... */
read_from_stdin) && /* -s flag with args, and */
isatty (fileno (stdin)) && /* Input is a terminal and */
isatty (fileno (stdout)))) /* output is a terminal. */
isatty (fileno (stderr)))) /* error output is a terminal. */
init_interactive ();
else
init_noninteractive ();
+19 -18
View File
@@ -1,6 +1,6 @@
/* shell.c -- GNU's idea of the POSIX shell specification. */
/* Copyright (C) 1987-2003 Free Software Foundation, Inc.
/* Copyright (C) 1987-2004 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -1332,25 +1332,8 @@ open_shell_script (script_name)
ARRAY *funcname_a, *bash_source_a, *bash_lineno_a;
#endif
free (dollar_vars[0]);
dollar_vars[0] = savestring (script_name);
filename = savestring (script_name);
#if defined (ARRAY_VARS)
GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a);
GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a);
GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a);
array_push (bash_source_a, filename);
if (bash_lineno_a)
{
t = itos (executing_line_number ());
array_push (bash_lineno_a, t);
free (t);
}
array_push (funcname_a, "main");
#endif
fd = open (filename, O_RDONLY);
if ((fd < 0) && (errno == ENOENT) && (absolute_program (filename) == 0))
{
@@ -1375,6 +1358,24 @@ open_shell_script (script_name)
exit ((e == ENOENT) ? EX_NOTFOUND : EX_NOINPUT);
}
free (dollar_vars[0]);
dollar_vars[0] = savestring (script_name);
#if defined (ARRAY_VARS)
GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a);
GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a);
GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a);
array_push (bash_source_a, filename);
if (bash_lineno_a)
{
t = itos (executing_line_number ());
array_push (bash_lineno_a, t);
free (t);
}
array_push (funcname_a, "main");
#endif
#ifdef HAVE_DEV_FD
fd_is_tty = isatty (fd);
#else
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
BUILD_DIR=/usr/local/build/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR