mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-09 13:10:50 +02:00
commit bash-20090723 snapshot
This commit is contained in:
@@ -318,3 +318,8 @@ bash-2.0 were significant.)
|
||||
pipeline is a simple command). This is not as Posix specifies. There is
|
||||
work underway to update this portion of the standard; the bash-4.0
|
||||
behavior attempts to capture the consensus at the time of release.
|
||||
|
||||
43. Bash-4.0 fixes a Posix mode bug that caused the . (source) builtin to
|
||||
search the current directory for its filename argument, even if "." is
|
||||
not in $PATH. Posix says that the shell shouldn't look in $PWD in this
|
||||
case.
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
This document details the incompatibilities between this version of bash,
|
||||
bash-4.0, and the previous widely-available versions, bash-1.14 (which is
|
||||
still the `standard' version for a few Linux distributions) and bash-2.x.
|
||||
These were discovered by users of bash-2.x and 3.x, so this list is not
|
||||
comprehensive. Some of these incompatibilities occur between the current
|
||||
version and versions 2.0 and above. (The differences between bash-1.14 and
|
||||
bash-2.0 were significant.)
|
||||
|
||||
1. Bash uses a new quoting syntax, $"...", to do locale-specific
|
||||
string translation. Users who have relied on the (undocumented)
|
||||
behavior of bash-1.14 will have to change their scripts. For
|
||||
instance, if you are doing something like this to get the value of
|
||||
a variable whose name is the value of a second variable:
|
||||
|
||||
eval var2=$"$var1"
|
||||
|
||||
you will have to change to a different syntax.
|
||||
|
||||
This capability is directly supported by bash-2.0:
|
||||
|
||||
var2=${!var1}
|
||||
|
||||
This alternate syntax will work portably between bash-1.14 and bash-2.0:
|
||||
|
||||
eval var2=\$${var1}
|
||||
|
||||
2. One of the bugs fixed in the YACC grammar tightens up the rules
|
||||
concerning group commands ( {...} ). The `list' that composes the
|
||||
body of the group command must be terminated by a newline or
|
||||
semicolon. That's because the braces are reserved words, and are
|
||||
recognized as such only when a reserved word is legal. This means
|
||||
that while bash-1.14 accepted shell function definitions like this:
|
||||
|
||||
foo() { : }
|
||||
|
||||
bash-2.0 requires this:
|
||||
|
||||
foo() { :; }
|
||||
|
||||
This is also an issue for commands like this:
|
||||
|
||||
mkdir dir || { echo 'could not mkdir' ; exit 1; }
|
||||
|
||||
The syntax required by bash-2.0 is also accepted by bash-1.14.
|
||||
|
||||
3. The options to `bind' have changed to make them more consistent with
|
||||
the rest of the bash builtins. If you are using `bind -d' to list
|
||||
the readline key bindings in a form that can be re-read, use `bind -p'
|
||||
instead. If you were using `bind -v' to list the key bindings, use
|
||||
`bind -P' instead.
|
||||
|
||||
4. The `long' invocation options must now be prefixed by `--' instead
|
||||
of `-'. (The old form is still accepted, for the time being.)
|
||||
|
||||
5. There was a bug in the version of readline distributed with bash-1.14
|
||||
that caused it to write badly-formatted key bindings when using
|
||||
`bind -d'. The only key sequences that were affected are C-\ (which
|
||||
should appear as \C-\\ in a key binding) and C-" (which should appear
|
||||
as \C-\"). If these key sequences appear in your inputrc, as, for
|
||||
example,
|
||||
|
||||
"\C-\": self-insert
|
||||
|
||||
they will need to be changed to something like the following:
|
||||
|
||||
"\C-\\": self-insert
|
||||
|
||||
6. A number of people complained about having to use ESC to terminate an
|
||||
incremental search, and asked for an alternate mechanism. Bash-2.03
|
||||
uses the value of the settable readline variable `isearch-terminators'
|
||||
to decide which characters should terminate an incremental search. If
|
||||
that variable has not been set, ESC and Control-J will terminate a
|
||||
search.
|
||||
|
||||
7. Some variables have been removed: MAIL_WARNING, notify, history_control,
|
||||
command_oriented_history, glob_dot_filenames, allow_null_glob_expansion,
|
||||
nolinks, hostname_completion_file, noclobber, no_exit_on_failed_exec, and
|
||||
cdable_vars. Most of them are now implemented with the new `shopt'
|
||||
builtin; others were already implemented by `set'. Here is a list of
|
||||
correspondences:
|
||||
|
||||
MAIL_WARNING shopt mailwarn
|
||||
notify set -o notify
|
||||
history_control HISTCONTROL
|
||||
command_oriented_history shopt cmdhist
|
||||
glob_dot_filenames shopt dotglob
|
||||
allow_null_glob_expansion shopt nullglob
|
||||
nolinks set -o physical
|
||||
hostname_completion_file HOSTFILE
|
||||
noclobber set -o noclobber
|
||||
no_exit_on_failed_exec shopt execfail
|
||||
cdable_vars shopt cdable_vars
|
||||
|
||||
8. `ulimit' now sets both hard and soft limits and reports the soft limit
|
||||
by default (when neither -H nor -S is specified). This is compatible
|
||||
with versions of sh and ksh that implement `ulimit'. The bash-1.14
|
||||
behavior of, for example,
|
||||
|
||||
ulimit -c 0
|
||||
|
||||
can be obtained with
|
||||
|
||||
ulimit -S -c 0
|
||||
|
||||
It may be useful to define an alias:
|
||||
|
||||
alias ulimit="ulimit -S"
|
||||
|
||||
9. Bash-2.01 uses a new quoting syntax, $'...' to do ANSI-C string
|
||||
translation. Backslash-escaped characters in ... are expanded and
|
||||
replaced as specified by the ANSI C standard.
|
||||
|
||||
10. The sourcing of startup files has changed somewhat. This is explained
|
||||
more completely in the INVOCATION section of the manual page.
|
||||
|
||||
A non-interactive shell not named `sh' and not in posix mode reads
|
||||
and executes commands from the file named by $BASH_ENV. A
|
||||
non-interactive shell started by `su' and not in posix mode will read
|
||||
startup files. No other non-interactive shells read any startup files.
|
||||
|
||||
An interactive shell started in posix mode reads and executes commands
|
||||
from the file named by $ENV.
|
||||
|
||||
11. The <> redirection operator was changed to conform to the POSIX.2 spec.
|
||||
In the absence of any file descriptor specification preceding the `<>',
|
||||
file descriptor 0 is used. In bash-1.14, this was the behavior only
|
||||
when in POSIX mode. The bash-1.14 behavior may be obtained with
|
||||
|
||||
<>filename 1>&0
|
||||
|
||||
12. The `alias' builtin now checks for invalid options and takes a `-p'
|
||||
option to display output in POSIX mode. If you have old aliases beginning
|
||||
with `-' or `+', you will have to add the `--' to the alias command
|
||||
that declares them:
|
||||
|
||||
alias -x='chmod a-x' --> alias -- -x='chmod a-x'
|
||||
|
||||
13. The behavior of range specificiers within bracket matching expressions
|
||||
in the pattern matcher (e.g., [A-Z]) depends on the current locale,
|
||||
specifically the value of the LC_COLLATE environment variable. Setting
|
||||
this variable to C or POSIX will result in the traditional ASCII behavior
|
||||
for range comparisons. If the locale is set to something else, e.g.,
|
||||
en_US (specified by the LANG or LC_ALL variables), collation order is
|
||||
locale-dependent. For example, the en_US locale sorts the upper and
|
||||
lower case letters like this:
|
||||
|
||||
AaBb...Zz
|
||||
|
||||
so a range specification like [A-Z] will match every letter except `z'.
|
||||
Other locales collate like
|
||||
|
||||
aAbBcC...zZ
|
||||
|
||||
which means that [A-Z] matches every letter except `a'.
|
||||
|
||||
The portable way to specify upper case letters is [:upper:] instead of
|
||||
A-Z; lower case may be specified as [:lower:] instead of a-z.
|
||||
|
||||
Look at the manual pages for setlocale(3), strcoll(3), and, if it is
|
||||
present, locale(1).
|
||||
|
||||
You can find your current locale information by running locale(1):
|
||||
|
||||
caleb.ins.cwru.edu(2)$ locale
|
||||
LANG=en_US
|
||||
LC_CTYPE="en_US"
|
||||
LC_NUMERIC="en_US"
|
||||
LC_TIME="en_US"
|
||||
LC_COLLATE="en_US"
|
||||
LC_MONETARY="en_US"
|
||||
LC_MESSAGES="en_US"
|
||||
LC_ALL=en_US
|
||||
|
||||
My advice is to put
|
||||
|
||||
export LC_COLLATE=C
|
||||
|
||||
into /etc/profile and inspect any shell scripts run from cron for
|
||||
constructs like [A-Z]. This will prevent things like
|
||||
|
||||
rm [A-Z]*
|
||||
|
||||
from removing every file in the current directory except those beginning
|
||||
with `z' and still allow individual users to change the collation order.
|
||||
Users may put the above command into their own profiles as well, of course.
|
||||
|
||||
14. Bash versions up to 1.14.7 included an undocumented `-l' operator to
|
||||
the `test/[' builtin. It was a unary operator that expanded to the
|
||||
length of its string argument. This let you do things like
|
||||
|
||||
test -l $variable -lt 20
|
||||
|
||||
for example.
|
||||
|
||||
This was included for backwards compatibility with old versions of the
|
||||
Bourne shell, which did not provide an easy way to obtain the length of
|
||||
the value of a shell variable.
|
||||
|
||||
This operator is not part of the POSIX standard, because one can (and
|
||||
should) use ${#variable} to get the length of a variable's value.
|
||||
Bash-2.x does not support it.
|
||||
|
||||
15. Bash no longer auto-exports the HOME, PATH, SHELL, TERM, HOSTNAME,
|
||||
HOSTTYPE, MACHTYPE, or OSTYPE variables. If they appear in the initial
|
||||
environment, the export attribute will be set, but if bash provides a
|
||||
default value, they will remain local to the current shell.
|
||||
|
||||
16. Bash no longer initializes the FUNCNAME, GROUPS, or DIRSTACK variables
|
||||
to have special behavior if they appear in the initial environment.
|
||||
|
||||
17. Bash no longer removes the export attribute from the SSH_CLIENT or
|
||||
SSH2_CLIENT variables, and no longer attempts to discover whether or
|
||||
not it has been invoked by sshd in order to run the startup files.
|
||||
|
||||
18. Bash no longer requires that the body of a function be a group command;
|
||||
any compound command is accepted.
|
||||
|
||||
19. As of bash-3.0, the pattern substitution operators no longer perform
|
||||
quote removal on the pattern before attempting the match. This is the
|
||||
way the pattern removal functions behave, and is more consistent.
|
||||
|
||||
20. After bash-3.0 was released, I reimplemented tilde expansion, incorporating
|
||||
it into the mainline word expansion code. This fixes the bug that caused
|
||||
the results of tilde expansion to be re-expanded. There is one
|
||||
incompatibility: a ${paramOPword} expansion within double quotes will not
|
||||
perform tilde expansion on WORD. This is consistent with the other
|
||||
expansions, and what POSIX specifies.
|
||||
|
||||
21. A number of variables have the integer attribute by default, so the +=
|
||||
assignment operator returns expected results: RANDOM, LINENO, MAILCHECK,
|
||||
HISTCMD, OPTIND.
|
||||
|
||||
22. Bash-3.x is much stricter about $LINENO correctly reflecting the line
|
||||
number in a script; assignments to LINENO have little effect.
|
||||
|
||||
23. By default, readline binds the terminal special characters to their
|
||||
readline equivalents. As of bash-3.1/readline-5.1, this is optional and
|
||||
controlled by the bind-tty-special-chars readline variable.
|
||||
|
||||
24. The \W prompt string expansion abbreviates $HOME as `~'. The previous
|
||||
behavior is available with ${PWD##/*/}.
|
||||
|
||||
25. The arithmetic exponentiation operator is right-associative as of bash-3.1.
|
||||
|
||||
26. The rules concerning valid alias names are stricter, as per POSIX.2.
|
||||
|
||||
27. The Readline key binding functions now obey the convert-meta setting active
|
||||
when the binding takes place, as the dispatch code does when characters
|
||||
are read and processed.
|
||||
|
||||
28. The historical behavior of `trap' reverting signal disposition to the
|
||||
original handling in the absence of a valid first argument is implemented
|
||||
only if the first argument is a valid signal number.
|
||||
|
||||
29. In versions of bash after 3.1, the ${parameter//pattern/replacement}
|
||||
expansion does not interpret `%' or `#' specially. Those anchors don't
|
||||
have any real meaning when replacing every match.
|
||||
|
||||
30. Beginning with bash-3.1, the combination of posix mode and enabling the
|
||||
`xpg_echo' option causes echo to ignore all options, not looking for `-n'
|
||||
|
||||
31. Beginning with bash-3.2, bash follows the Bourne-shell-style (and POSIX-
|
||||
style) rules for parsing the contents of old-style backquoted command
|
||||
substitutions. Previous versions of bash attempted to recursively parse
|
||||
embedded quoted strings and shell constructs; bash-3.2 uses strict POSIX
|
||||
rules to find the closing backquote and simply passes the contents of the
|
||||
command substitution to a subshell for parsing and execution.
|
||||
|
||||
32. Beginning with bash-3.2, bash uses access(2) when executing primaries for
|
||||
the test builtin and the [[ compound command, rather than looking at the
|
||||
file permission bits obtained with stat(2). This obeys restrictions of
|
||||
the file system (e.g., read-only or noexec mounts) not available via stat.
|
||||
|
||||
33. Bash-3.2 adopts the convention used by other string and pattern matching
|
||||
operators for the `[[' compound command, and matches any quoted portion
|
||||
of the right-hand-side argument to the =~ operator as a string rather
|
||||
than a regular expression.
|
||||
|
||||
34. Bash-4.0 allows the behavior in the previous item to be modified using
|
||||
the notion of a shell `compatibility level'.
|
||||
|
||||
35. Bash-3.2 (patched) and Bash-4.0 fix a bug that leaves the shell in an
|
||||
inconsistent internal state following an assignment error. One of the
|
||||
changes means that compound commands or { ... } grouping commands are
|
||||
aborted under some circumstances in which they previously were not.
|
||||
This is what Posix specifies.
|
||||
|
||||
36. Bash-4.0 now allows process substitution constructs to pass unchanged
|
||||
through brace expansion, so any expansion of the contents will have to be
|
||||
separately specified, and each process subsitution will have to be
|
||||
separately entered.
|
||||
|
||||
37. Bash-4.0 now allows SIGCHLD to interrupt the wait builtin, as Posix
|
||||
specifies, so the SIGCHLD trap is no longer always invoked once per
|
||||
exiting child if you are using `wait' to wait for all children.
|
||||
|
||||
38. Since bash-4.0 now follows Posix rules for finding the closing delimiter
|
||||
of a $() command substitution, it will not behave as previous versions
|
||||
did, but will catch more syntax and parsing errors before spawning a
|
||||
subshell to evaluate the command substitution.
|
||||
|
||||
39. The programmable completion code uses the same set of delimiting characters
|
||||
as readline when breaking the command line into words, rather than the
|
||||
set of shell metacharacters, so programmable completion and readline
|
||||
should be more consistent.
|
||||
|
||||
40. When the read builtin times out, it attempts to assign any input read to
|
||||
specified variables, which also causes variables to be set to the empty
|
||||
string if there is not enough input. Previous versions discarded the
|
||||
characters read.
|
||||
|
||||
41. Beginning with bash-4.0, when one of the commands in a pipeline is killed
|
||||
by a SIGINT while executing a command list, the shell acts as if it
|
||||
received the interrupt.
|
||||
|
||||
42. Bash-4.0 changes the handling of the set -e option so that the shell exits
|
||||
if a pipeline fails (and not just if the last command in the failing
|
||||
pipeline is a simple command). This is not as Posix specifies. There is
|
||||
work underway to update this portion of the standard; the bash-4.0
|
||||
behavior attempts to capture the consensus at the time of release.
|
||||
@@ -8226,3 +8226,43 @@ subst.c
|
||||
- fix off-by-one error in pos_params when computing positional
|
||||
parameters beginning with index 0. Bug and fix from Isaac Good
|
||||
<isaacgood@gmail.com>
|
||||
|
||||
7/24
|
||||
----
|
||||
lib/readline/display.c
|
||||
- add code to _rl_move_cursor_relative and _rl_col_width to short-
|
||||
circuit a few special cases: prompt string and prompt string plus
|
||||
line contents, both starting from 0. Saves a bunch of calls to
|
||||
multibyte character functions using already-computed information.
|
||||
As a side effect, fixes bug reported by Lasse Karkkainen
|
||||
<tronic+8qug@trn.iki.fi>
|
||||
|
||||
subst.c
|
||||
- fixed a problem in split_at_delims that could leave *cwp set to -1
|
||||
if the line ends in IFS whitespace and SENTINEL is one of those
|
||||
whitespace characters. Fixes problem with setting COMP_CWORD for
|
||||
programmable completion reported by Ville Skytta <ville.skytta@iki.fi>
|
||||
|
||||
bashline.c
|
||||
- change bash_execute_unix_command to clear the current line (if the
|
||||
terminal supplies the "ce" attribute) instead of moving to a new
|
||||
line. Inspired by report from Henning Bekel <h.bekel@googlemail.com>
|
||||
|
||||
builtins/printf.def
|
||||
- changes to allow printf -v var to assign to array indices, the way
|
||||
the read builtin can. Suggested by Christopher F. A. Johnson
|
||||
<cfajohnson@gmail.com>
|
||||
|
||||
lib/readline/complete.c
|
||||
- fix rl_old_menu_complete and rl_menu_complete to appropriately set
|
||||
and unset RL_STATE_COMPLETING while generating the list of matches.
|
||||
Fixes debian bug #538013 reported by Jerome Reybert
|
||||
<jreybert@gmail.com>
|
||||
|
||||
7/25
|
||||
----
|
||||
execute_cmd.c
|
||||
- change execute_builtin to temporarily turn off and restore the ERR
|
||||
trap for the eval/source/command builtins in the same way as we
|
||||
temporarily disable and restore the setting of the -e option.
|
||||
Fixes bug reported by Henning Garus <henning.garus@googlemail.com>
|
||||
|
||||
+33
-1
@@ -8224,5 +8224,37 @@ trap.c
|
||||
----
|
||||
subst.c
|
||||
- fix off-by-one error in pos_params when computing positional
|
||||
parameters beginning with 0. Bug and fix from Isaac Good
|
||||
parameters beginning with index 0. Bug and fix from Isaac Good
|
||||
<isaacgood@gmail.com>
|
||||
|
||||
7/24
|
||||
----
|
||||
lib/readline/display.c
|
||||
- add code to _rl_move_cursor_relative and _rl_col_width to short-
|
||||
circuit a few special cases: prompt string and prompt string plus
|
||||
line contents, both starting from 0. Saves a bunch of calls to
|
||||
multibyte character functions using already-computed information.
|
||||
As a side effect, fixes bug reported by Lasse Karkkainen
|
||||
<tronic+8qug@trn.iki.fi>
|
||||
|
||||
subst.c
|
||||
- fixed a problem in split_at_delims that could leave *cwp set to -1
|
||||
if the line ends in IFS whitespace and SENTINEL is one of those
|
||||
whitespace characters. Fixes problem with setting COMP_CWORD for
|
||||
programmable completion reported by Ville Skytta <ville.skytta@iki.fi>
|
||||
|
||||
bashline.c
|
||||
- change bash_execute_unix_command to clear the current line (if the
|
||||
terminal supplies the "ce" attribute) instead of moving to a new
|
||||
line. Inspired by report from Henning Bekel <h.bekel@googlemail.com>
|
||||
|
||||
builtins/printf.def
|
||||
- changes to allow printf -v var to assign to array indices, the way
|
||||
the read builtin can. Suggested by Christopher F. A. Johnson
|
||||
<cfajohnson@gmail.com>
|
||||
|
||||
lib/readline/complete.c
|
||||
- fix rl_old_menu_complete and rl_menu_complete to appropriately set
|
||||
and unset RL_STATE_COMPLETING while generating the list of matches.
|
||||
Fixes debian bug #538013 reported by Jerome Reybert
|
||||
<jreybert@gmail.com>
|
||||
|
||||
+23
-4
@@ -82,6 +82,9 @@
|
||||
extern int bash_brace_completion __P((int, int));
|
||||
#endif /* BRACE_COMPLETION */
|
||||
|
||||
/* To avoid including curses.h/term.h/termcap.h and that whole mess. */
|
||||
extern int tputs __P((const char *string, int nlines, int (*outx)(int)));
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
/* Functions bound to keys in Readline for Bash users. */
|
||||
@@ -146,6 +149,7 @@ static char *bash_dequote_filename __P((char *, int));
|
||||
static char *quote_word_break_chars __P((char *));
|
||||
static char *bash_quote_filename __P((char *, int, char *));
|
||||
|
||||
static int putx __P((int));
|
||||
static int bash_execute_unix_command __P((int, int));
|
||||
static void init_unix_command_map __P((void));
|
||||
static int isolate_sequence __P((char *, int, int, int *));
|
||||
@@ -3379,6 +3383,13 @@ bash_quote_filename (s, rtype, qcp)
|
||||
/* Support for binding readline key sequences to Unix commands. */
|
||||
static Keymap cmd_xmap;
|
||||
|
||||
static int
|
||||
putx(c)
|
||||
int c;
|
||||
{
|
||||
putc (c, rl_outstream);
|
||||
}
|
||||
|
||||
static int
|
||||
bash_execute_unix_command (count, key)
|
||||
int count; /* ignored */
|
||||
@@ -3386,10 +3397,10 @@ bash_execute_unix_command (count, key)
|
||||
{
|
||||
Keymap ckmap; /* current keymap */
|
||||
Keymap xkmap; /* unix command executing keymap */
|
||||
register int i;
|
||||
register int i, r;
|
||||
intmax_t mi;
|
||||
sh_parser_state_t ps;
|
||||
char *cmd, *value, *l;
|
||||
char *cmd, *value, *l, *ce;
|
||||
SHELL_VAR *v;
|
||||
char ibuf[INT_STRLEN_BOUND(int) + 1];
|
||||
|
||||
@@ -3425,7 +3436,15 @@ bash_execute_unix_command (count, key)
|
||||
return 1;
|
||||
}
|
||||
|
||||
rl_crlf (); /* move to a new line */
|
||||
ce = rl_get_termcap ("ce");
|
||||
if (ce) /* clear current line */
|
||||
{
|
||||
fprintf (rl_outstream, "\r");
|
||||
tputs (ce, 1, putx);
|
||||
fflush (rl_outstream);
|
||||
}
|
||||
else
|
||||
rl_crlf (); /* move to a new line */
|
||||
|
||||
v = bind_variable ("READLINE_LINE", rl_line_buffer, 0);
|
||||
if (v)
|
||||
@@ -3438,7 +3457,7 @@ bash_execute_unix_command (count, key)
|
||||
array_needs_making = 1;
|
||||
|
||||
save_parser_state (&ps);
|
||||
parse_and_execute (cmd, "bash_execute_unix_command", SEVAL_NOHIST|SEVAL_NOFREE);
|
||||
r = parse_and_execute (cmd, "bash_execute_unix_command", SEVAL_NOHIST|SEVAL_NOFREE);
|
||||
restore_parser_state (&ps);
|
||||
|
||||
v = find_variable ("READLINE_LINE");
|
||||
|
||||
+20
-6
@@ -146,6 +146,7 @@ static char *bash_dequote_filename __P((char *, int));
|
||||
static char *quote_word_break_chars __P((char *));
|
||||
static char *bash_quote_filename __P((char *, int, char *));
|
||||
|
||||
static int putx __P((int));
|
||||
static int bash_execute_unix_command __P((int, int));
|
||||
static void init_unix_command_map __P((void));
|
||||
static int isolate_sequence __P((char *, int, int, int *));
|
||||
@@ -3379,6 +3380,13 @@ bash_quote_filename (s, rtype, qcp)
|
||||
/* Support for binding readline key sequences to Unix commands. */
|
||||
static Keymap cmd_xmap;
|
||||
|
||||
static int
|
||||
putx(c)
|
||||
int c;
|
||||
{
|
||||
putc (c, rl_outstream);
|
||||
}
|
||||
|
||||
static int
|
||||
bash_execute_unix_command (count, key)
|
||||
int count; /* ignored */
|
||||
@@ -3386,11 +3394,10 @@ bash_execute_unix_command (count, key)
|
||||
{
|
||||
Keymap ckmap; /* current keymap */
|
||||
Keymap xkmap; /* unix command executing keymap */
|
||||
register int i;
|
||||
register int i, r;
|
||||
intmax_t mi;
|
||||
int save_point;
|
||||
sh_parser_state_t ps;
|
||||
char *cmd, *value, *l;
|
||||
char *cmd, *value, *l, *ce;
|
||||
SHELL_VAR *v;
|
||||
char ibuf[INT_STRLEN_BOUND(int) + 1];
|
||||
|
||||
@@ -3426,13 +3433,20 @@ bash_execute_unix_command (count, key)
|
||||
return 1;
|
||||
}
|
||||
|
||||
rl_crlf (); /* move to a new line */
|
||||
ce = rl_get_termcap ("ce");
|
||||
if (ce) /* clear current line */
|
||||
{
|
||||
fprintf (rl_outstream, "\r");
|
||||
tputs (ce, 1, putx);
|
||||
fflush (rl_outstream);
|
||||
}
|
||||
else
|
||||
rl_crlf (); /* move to a new line */
|
||||
|
||||
v = bind_variable ("READLINE_LINE", rl_line_buffer, 0);
|
||||
if (v)
|
||||
VSETATTR (v, att_exported);
|
||||
l = value_cell (v);
|
||||
save_point = rl_point;
|
||||
value = inttostr (rl_point, ibuf, sizeof (ibuf));
|
||||
v = bind_int_variable ("READLINE_POINT", value);
|
||||
if (v)
|
||||
@@ -3440,7 +3454,7 @@ bash_execute_unix_command (count, key)
|
||||
array_needs_making = 1;
|
||||
|
||||
save_parser_state (&ps);
|
||||
parse_and_execute (cmd, "bash_execute_unix_command", SEVAL_NOHIST|SEVAL_NOFREE);
|
||||
r = parse_and_execute (cmd, "bash_execute_unix_command", SEVAL_NOHIST|SEVAL_NOFREE);
|
||||
restore_parser_state (&ps);
|
||||
|
||||
v = find_variable ("READLINE_LINE");
|
||||
|
||||
+24
-2
@@ -135,7 +135,7 @@ extern int errno;
|
||||
{ \
|
||||
if (vflag) \
|
||||
{ \
|
||||
bind_variable (vname, vbuf, 0); \
|
||||
bind_printf_variable (vname, vbuf, 0); \
|
||||
stupidly_hack_special_variables (vname); \
|
||||
} \
|
||||
if (conv_bufsize > 4096 ) \
|
||||
@@ -186,6 +186,7 @@ static char *getstr __P((void));
|
||||
static int getint __P((void));
|
||||
static intmax_t getintmax __P((void));
|
||||
static uintmax_t getuintmax __P((void));
|
||||
static SHELL_VAR *bind_printf_variable __P((char *, char *, int));
|
||||
|
||||
#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN)
|
||||
typedef long double floatmax_t;
|
||||
@@ -234,7 +235,12 @@ printf_builtin (list)
|
||||
switch (ch)
|
||||
{
|
||||
case 'v':
|
||||
if (legal_identifier (vname = list_optarg))
|
||||
vname = list_optarg;
|
||||
#if defined (ARRAY_VARS)
|
||||
if (legal_identifier (vname) || valid_array_reference (vname))
|
||||
#else
|
||||
if (legal_identifier (vname))
|
||||
#endif
|
||||
{
|
||||
vflag = 1;
|
||||
vblen = 0;
|
||||
@@ -1091,3 +1097,19 @@ asciicode ()
|
||||
garglist = garglist->next;
|
||||
return (ch);
|
||||
}
|
||||
|
||||
static SHELL_VAR *
|
||||
bind_printf_variable (name, value, flags)
|
||||
char *name;
|
||||
char *value;
|
||||
int flags;
|
||||
{
|
||||
#if defined (ARRAY_VARS)
|
||||
if (valid_array_reference (name) == 0)
|
||||
return (bind_variable (name, value, flags));
|
||||
else
|
||||
return (assign_array_element (name, value, flags));
|
||||
#else /* !ARRAY_VARS */
|
||||
return bind_variable (name, value, flags);
|
||||
#endif /* !ARRAY_VARS */
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,130 +1,125 @@
|
||||
*** ../bash-4.0-patched/variables.c 2009-01-04 14:32:46.000000000 -0500
|
||||
--- variables.c 2009-06-29 09:17:20.000000000 -0400
|
||||
*** ../bash-4.0-patched/bashline.c 2009-01-08 09:29:24.000000000 -0500
|
||||
--- bashline.c 2009-07-16 14:13:41.000000000 -0400
|
||||
***************
|
||||
*** 222,228 ****
|
||||
--- 222,230 ----
|
||||
static SHELL_VAR *get_hashcmd __P((SHELL_VAR *));
|
||||
static SHELL_VAR *assign_hashcmd __P((SHELL_VAR *, char *, arrayind_t, char *));
|
||||
+ # if defined (ALIAS)
|
||||
static SHELL_VAR *build_aliasvar __P((SHELL_VAR *));
|
||||
static SHELL_VAR *get_aliasvar __P((SHELL_VAR *));
|
||||
static SHELL_VAR *assign_aliasvar __P((SHELL_VAR *, char *, arrayind_t, char *));
|
||||
+ # endif
|
||||
#endif
|
||||
*** 1387,1391 ****
|
||||
/* If the word starts in `~', and there is no slash in the word, then
|
||||
try completing this word as a username. */
|
||||
! if (!matches && *text == '~' && !xstrchr (text, '/'))
|
||||
matches = rl_completion_matches (text, rl_username_completion_function);
|
||||
|
||||
--- 1387,1391 ----
|
||||
/* If the word starts in `~', and there is no slash in the word, then
|
||||
try completing this word as a username. */
|
||||
! if (matches ==0 && *text == '~' && mbschr (text, '/') == 0)
|
||||
matches = rl_completion_matches (text, rl_username_completion_function);
|
||||
|
||||
***************
|
||||
*** 253,256 ****
|
||||
--- 255,259 ----
|
||||
static int visible_var __P((SHELL_VAR *));
|
||||
static int visible_and_exported __P((SHELL_VAR *));
|
||||
+ static int export_environment_candidate __P((SHELL_VAR *));
|
||||
static int local_and_exported __P((SHELL_VAR *));
|
||||
static int variable_in_context __P((SHELL_VAR *));
|
||||
*** 2667,2675 ****
|
||||
local_dirname = *dirname;
|
||||
|
||||
! if (xstrchr (local_dirname, '$'))
|
||||
should_expand_dirname = 1;
|
||||
else
|
||||
{
|
||||
! t = xstrchr (local_dirname, '`');
|
||||
if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
|
||||
should_expand_dirname = 1;
|
||||
--- 2667,2675 ----
|
||||
local_dirname = *dirname;
|
||||
|
||||
! if (mbschr (local_dirname, '$'))
|
||||
should_expand_dirname = 1;
|
||||
else
|
||||
{
|
||||
! t = mbschr (local_dirname, '`');
|
||||
if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
|
||||
should_expand_dirname = 1;
|
||||
***************
|
||||
*** 376,383 ****
|
||||
# endif
|
||||
#endif
|
||||
else if (legal_identifier (name))
|
||||
{
|
||||
temp_var = bind_variable (name, string, 0);
|
||||
! VSETATTR (temp_var, (att_exported | att_imported));
|
||||
array_needs_making = 1;
|
||||
*** 3226,3230 ****
|
||||
*r++ = *++p;
|
||||
if (*p == '\0')
|
||||
! break;
|
||||
continue;
|
||||
}
|
||||
--- 379,393 ----
|
||||
# endif
|
||||
#endif
|
||||
+ #if 0
|
||||
else if (legal_identifier (name))
|
||||
+ #else
|
||||
+ else
|
||||
+ #endif
|
||||
{
|
||||
temp_var = bind_variable (name, string, 0);
|
||||
! if (legal_identifier (name))
|
||||
! VSETATTR (temp_var, (att_exported | att_imported));
|
||||
! else
|
||||
! VSETATTR (temp_var, (att_exported | att_imported | att_invisible));
|
||||
array_needs_making = 1;
|
||||
--- 3226,3230 ----
|
||||
*r++ = *++p;
|
||||
if (*p == '\0')
|
||||
! return ret; /* XXX - was break; */
|
||||
continue;
|
||||
}
|
||||
***************
|
||||
*** 868,872 ****
|
||||
av = array_cell (vv);
|
||||
strcpy (d, dist_version);
|
||||
! s = xstrchr (d, '.');
|
||||
if (s)
|
||||
*s++ = '\0';
|
||||
--- 878,882 ----
|
||||
av = array_cell (vv);
|
||||
strcpy (d, dist_version);
|
||||
! s = strchr (d, '.');
|
||||
if (s)
|
||||
*s++ = '\0';
|
||||
*** 3272,3276 ****
|
||||
/* OK, we have an unquoted character. Check its presence in
|
||||
rl_completer_word_break_characters. */
|
||||
! if (xstrchr (rl_completer_word_break_characters, *s))
|
||||
*r++ = '\\';
|
||||
/* XXX -- check for standalone tildes here and backslash-quote them */
|
||||
--- 3272,3276 ----
|
||||
/* OK, we have an unquoted character. Check its presence in
|
||||
rl_completer_word_break_characters. */
|
||||
! if (mbschr (rl_completer_word_break_characters, *s))
|
||||
*r++ = '\\';
|
||||
/* XXX -- check for standalone tildes here and backslash-quote them */
|
||||
***************
|
||||
*** 1549,1552 ****
|
||||
--- 1559,1563 ----
|
||||
}
|
||||
|
||||
+ #if defined (ALIAS)
|
||||
static SHELL_VAR *
|
||||
build_aliasvar (self)
|
||||
*** 3314,3318 ****
|
||||
quoted correctly using backslashes (a backslash-newline pair is
|
||||
special to the shell parser). */
|
||||
! if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && xstrchr (s, '\n'))
|
||||
cs = COMPLETE_SQUOTE;
|
||||
else if (*qcp == '"')
|
||||
--- 3314,3318 ----
|
||||
quoted correctly using backslashes (a backslash-newline pair is
|
||||
special to the shell parser). */
|
||||
! if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && mbschr (s, '\n'))
|
||||
cs = COMPLETE_SQUOTE;
|
||||
else if (*qcp == '"')
|
||||
***************
|
||||
*** 1601,1604 ****
|
||||
--- 1612,1617 ----
|
||||
return (build_aliasvar (self));
|
||||
}
|
||||
+ #endif /* ALIAS */
|
||||
+
|
||||
#endif /* ARRAY_VARS */
|
||||
*** 3322,3330 ****
|
||||
#if defined (BANG_HISTORY)
|
||||
else if (*qcp == '\0' && history_expansion && cs == COMPLETE_DQUOTE &&
|
||||
! history_expansion_inhibited == 0 && xstrchr (s, '!'))
|
||||
cs = COMPLETE_BSQUOTE;
|
||||
|
||||
if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE &&
|
||||
! history_expansion_inhibited == 0 && xstrchr (s, '!'))
|
||||
{
|
||||
cs = COMPLETE_BSQUOTE;
|
||||
--- 3322,3330 ----
|
||||
#if defined (BANG_HISTORY)
|
||||
else if (*qcp == '\0' && history_expansion && cs == COMPLETE_DQUOTE &&
|
||||
! history_expansion_inhibited == 0 && mbschr (s, '!'))
|
||||
cs = COMPLETE_BSQUOTE;
|
||||
|
||||
if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE &&
|
||||
! history_expansion_inhibited == 0 && mbschr (s, '!'))
|
||||
{
|
||||
cs = COMPLETE_BSQUOTE;
|
||||
***************
|
||||
*** 1696,1700 ****
|
||||
--- 1709,1715 ----
|
||||
|
||||
v = init_dynamic_assoc_var ("BASH_CMDS", get_hashcmd, assign_hashcmd, att_nofree);
|
||||
+ # if defined (ALIAS)
|
||||
v = init_dynamic_assoc_var ("BASH_ALIASES", get_aliasvar, assign_aliasvar, att_nofree);
|
||||
+ # endif
|
||||
#endif
|
||||
|
||||
*** 3389,3393 ****
|
||||
register int i;
|
||||
intmax_t mi;
|
||||
- int save_point;
|
||||
sh_parser_state_t ps;
|
||||
char *cmd, *value, *l;
|
||||
--- 3389,3392 ----
|
||||
***************
|
||||
*** 3083,3086 ****
|
||||
--- 3098,3111 ----
|
||||
}
|
||||
|
||||
+ /* Candidate variables for the export environment are either valid variables
|
||||
+ with the export attribute or invalid variables inherited from the initial
|
||||
+ environment and simply passed through. */
|
||||
+ static int
|
||||
+ export_environment_candidate (var)
|
||||
+ SHELL_VAR *var;
|
||||
+ {
|
||||
+ return (exported_p (var) && (invisible_p (var) == 0 || imported_p (var)));
|
||||
+ }
|
||||
+
|
||||
/* Return non-zero if VAR is a local variable in the current context and
|
||||
is exported. */
|
||||
*** 3433,3437 ****
|
||||
VSETATTR (v, att_exported);
|
||||
l = value_cell (v);
|
||||
- save_point = rl_point;
|
||||
value = inttostr (rl_point, ibuf, sizeof (ibuf));
|
||||
v = bind_int_variable ("READLINE_POINT", value);
|
||||
--- 3432,3435 ----
|
||||
***************
|
||||
*** 3439,3443 ****
|
||||
--- 3464,3472 ----
|
||||
SHELL_VAR **vars;
|
||||
|
||||
+ #if 0
|
||||
vars = map_over (visible_and_exported, vcxt);
|
||||
+ #else
|
||||
+ vars = map_over (export_environment_candidate, vcxt);
|
||||
+ #endif
|
||||
|
||||
if (vars == 0)
|
||||
***************
|
||||
*** 3588,3592 ****
|
||||
export_env[export_env_index = 0] = (char *)NULL;
|
||||
|
||||
! /* Make a dummy variable context from the temporary_env, stick it on
|
||||
the front of shell_variables, call make_var_export_array on the
|
||||
whole thing to flatten it, and convert the list of SHELL_VAR *s
|
||||
--- 3617,3621 ----
|
||||
export_env[export_env_index = 0] = (char *)NULL;
|
||||
|
||||
! /* Make a dummy variable context from the temporary_env, stick it on
|
||||
the front of shell_variables, call make_var_export_array on the
|
||||
whole thing to flatten it, and convert the list of SHELL_VAR *s
|
||||
*** 3451,3455 ****
|
||||
{
|
||||
i = mi;
|
||||
! if (i != save_point)
|
||||
{
|
||||
rl_point = i;
|
||||
--- 3449,3453 ----
|
||||
{
|
||||
i = mi;
|
||||
! if (i != rl_point)
|
||||
{
|
||||
rl_point = i;
|
||||
|
||||
+18
-3
@@ -3814,25 +3814,35 @@ execute_builtin (builtin, words, flags, subshell)
|
||||
{
|
||||
int old_e_flag, result, eval_unwind;
|
||||
int isbltinenv;
|
||||
char *error_trap;
|
||||
|
||||
#if 0
|
||||
/* XXX -- added 12/11 */
|
||||
terminate_immediately++;
|
||||
#endif
|
||||
|
||||
error_trap = 0;
|
||||
old_e_flag = exit_immediately_on_error;
|
||||
/* The eval builtin calls parse_and_execute, which does not know about
|
||||
the setting of flags, and always calls the execution functions with
|
||||
flags that will exit the shell on an error if -e is set. If the
|
||||
eval builtin is being called, and we're supposed to ignore the exit
|
||||
value of the command, we turn the -e flag off ourselves, then
|
||||
restore it when the command completes. This is also a problem (as
|
||||
below) for the command and source/. builtins. */
|
||||
value of the command, we turn the -e flag off ourselves and disable
|
||||
the ERR trap, then restore them when the command completes. This is
|
||||
also a problem (as below) for the command and source/. builtins. */
|
||||
if (subshell == 0 && (flags & CMD_IGNORE_RETURN) &&
|
||||
(builtin == eval_builtin || builtin == command_builtin || builtin == source_builtin))
|
||||
{
|
||||
begin_unwind_frame ("eval_builtin");
|
||||
unwind_protect_int (exit_immediately_on_error);
|
||||
error_trap = TRAP_STRING (ERROR_TRAP);
|
||||
if (error_trap)
|
||||
{
|
||||
error_trap = savestring (error_trap);
|
||||
add_unwind_protect (xfree, error_trap);
|
||||
add_unwind_protect (set_error_trap, error_trap);
|
||||
restore_default_signal (ERROR_TRAP);
|
||||
}
|
||||
exit_immediately_on_error = 0;
|
||||
eval_unwind = 1;
|
||||
}
|
||||
@@ -3883,6 +3893,11 @@ execute_builtin (builtin, words, flags, subshell)
|
||||
if (eval_unwind)
|
||||
{
|
||||
exit_immediately_on_error += old_e_flag;
|
||||
if (error_trap)
|
||||
{
|
||||
set_error_trap (error_trap);
|
||||
xfree (error_trap);
|
||||
}
|
||||
discard_unwind_frame ("eval_builtin");
|
||||
}
|
||||
|
||||
|
||||
+18
-4
@@ -3814,6 +3814,7 @@ execute_builtin (builtin, words, flags, subshell)
|
||||
{
|
||||
int old_e_flag, result, eval_unwind;
|
||||
int isbltinenv;
|
||||
char *error_trap;
|
||||
|
||||
#if 0
|
||||
/* XXX -- added 12/11 */
|
||||
@@ -3825,14 +3826,22 @@ execute_builtin (builtin, words, flags, subshell)
|
||||
the setting of flags, and always calls the execution functions with
|
||||
flags that will exit the shell on an error if -e is set. If the
|
||||
eval builtin is being called, and we're supposed to ignore the exit
|
||||
value of the command, we turn the -e flag off ourselves, then
|
||||
restore it when the command completes. This is also a problem (as
|
||||
below) for the command and source/. builtins. */
|
||||
value of the command, we turn the -e flag off ourselves and disable
|
||||
the ERR trap, then restore them when the command completes. This is
|
||||
also a problem (as below) for the command and source/. builtins. */
|
||||
if (subshell == 0 && (flags & CMD_IGNORE_RETURN) &&
|
||||
(builtin == eval_builtin || builtin == command_builtin || builtin == source_builtin))
|
||||
{
|
||||
begin_unwind_frame ("eval_builtin");
|
||||
unwind_protect_int (exit_immediately_on_error);
|
||||
error_trap = TRAP_STRING (ERROR_TRAP);
|
||||
if (error_trap)
|
||||
{
|
||||
error_trap = savestring (error_trap);
|
||||
add_unwind_protect (xfree, error_trap);
|
||||
add_unwind_protect (set_error_trap, error_trap);
|
||||
restore_default_signal (ERROR_TRAP);
|
||||
}
|
||||
exit_immediately_on_error = 0;
|
||||
eval_unwind = 1;
|
||||
}
|
||||
@@ -3883,6 +3892,11 @@ execute_builtin (builtin, words, flags, subshell)
|
||||
if (eval_unwind)
|
||||
{
|
||||
exit_immediately_on_error += old_e_flag;
|
||||
if (error_trap)
|
||||
{
|
||||
set_error_trap (error_trap);
|
||||
xfree (error_trap);
|
||||
}
|
||||
discard_unwind_frame ("eval_builtin");
|
||||
}
|
||||
|
||||
@@ -4372,7 +4386,7 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
command = (char *)NULL;
|
||||
if (restricted && xstrchr (pathname, '/'))
|
||||
if (restricted && mbschr (pathname, '/'))
|
||||
{
|
||||
internal_error (_("%s: restricted: cannot specify `/' in command names"),
|
||||
pathname);
|
||||
|
||||
@@ -2220,6 +2220,8 @@ rl_old_menu_complete (count, invoking_key)
|
||||
|
||||
rl_completion_invoking_key = invoking_key;
|
||||
|
||||
RL_SETSTATE(RL_STATE_COMPLETING);
|
||||
|
||||
/* Only the completion entry function can change these. */
|
||||
set_completion_defaults ('%');
|
||||
|
||||
@@ -2259,9 +2261,12 @@ rl_old_menu_complete (count, invoking_key)
|
||||
FREE (orig_text);
|
||||
orig_text = (char *)0;
|
||||
completion_changed_buffer = 0;
|
||||
RL_UNSETSTATE(RL_STATE_COMPLETING);
|
||||
return (0);
|
||||
}
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_COMPLETING);
|
||||
|
||||
for (match_list_size = 0; matches[match_list_size]; match_list_size++)
|
||||
;
|
||||
/* matches[0] is lcd if match_list_size > 1, but the circular buffer
|
||||
@@ -2337,6 +2342,8 @@ rl_menu_complete (count, ignore)
|
||||
|
||||
full_completion = 0;
|
||||
|
||||
RL_SETSTATE(RL_STATE_COMPLETING);
|
||||
|
||||
/* Only the completion entry function can change these. */
|
||||
set_completion_defaults ('%');
|
||||
|
||||
@@ -2378,9 +2385,12 @@ rl_menu_complete (count, ignore)
|
||||
FREE (orig_text);
|
||||
orig_text = (char *)0;
|
||||
completion_changed_buffer = 0;
|
||||
RL_UNSETSTATE(RL_STATE_COMPLETING);
|
||||
return (0);
|
||||
}
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_COMPLETING);
|
||||
|
||||
for (match_list_size = 0; matches[match_list_size]; match_list_size++)
|
||||
;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+37
-3
@@ -1899,6 +1899,7 @@ _rl_move_cursor_relative (new, data)
|
||||
register int i;
|
||||
int woff; /* number of invisible chars on current line */
|
||||
int cpos, dpos; /* current and desired cursor positions */
|
||||
int adjust;
|
||||
|
||||
woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
|
||||
cpos = _rl_last_c_pos;
|
||||
@@ -1914,15 +1915,34 @@ _rl_move_cursor_relative (new, data)
|
||||
as long as we are past them and they are counted by _rl_col_width. */
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
dpos = _rl_col_width (data, 0, new);
|
||||
adjust = 1;
|
||||
/* Try to short-circuit common cases and eliminate a bunch of multibyte
|
||||
character function calls. */
|
||||
/* 1. prompt string */
|
||||
if (new == local_prompt_len && memcmp (data, local_prompt, new) == 0)
|
||||
{
|
||||
dpos = prompt_visible_length;
|
||||
cpos_adjusted = 1;
|
||||
adjust = 0;
|
||||
}
|
||||
/* 2. prompt_string + line contents */
|
||||
else if (new > local_prompt_len && local_prompt && memcmp (data, local_prompt, local_prompt_len) == 0)
|
||||
{
|
||||
dpos = prompt_visible_length + _rl_col_width (data, local_prompt_len, new);
|
||||
cpos_adjusted = 1;
|
||||
adjust = 0;
|
||||
}
|
||||
else
|
||||
dpos = _rl_col_width (data, 0, new);
|
||||
|
||||
/* Use NEW when comparing against the last invisible character in the
|
||||
prompt string, since they're both buffer indices and DPOS is a
|
||||
desired display position. */
|
||||
if ((new > prompt_last_invisible) || /* XXX - don't use woff here */
|
||||
if (adjust && ((new > prompt_last_invisible) || /* XXX - don't use woff here */
|
||||
(prompt_physical_chars >= _rl_screenwidth &&
|
||||
_rl_last_v_pos == prompt_last_screen_line &&
|
||||
wrap_offset >= woff && dpos >= woff &&
|
||||
new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset)))
|
||||
new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset))))
|
||||
/* XXX last comparison might need to be >= */
|
||||
{
|
||||
dpos -= woff;
|
||||
@@ -2586,6 +2606,20 @@ _rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1");
|
||||
point = 0;
|
||||
max = end;
|
||||
|
||||
/* Try to short-circuit common cases. The adjustment to remove wrap_offset
|
||||
is done by the caller. */
|
||||
/* 1. prompt string */
|
||||
if (start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0)
|
||||
return (prompt_visible_length + wrap_offset);
|
||||
/* 2. prompt string + line contents */
|
||||
else if (start == 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0)
|
||||
{
|
||||
tmp = prompt_visible_length + wrap_offset;
|
||||
/* XXX - try to call ourselves recursively with non-prompt portion */
|
||||
tmp += _rl_col_width (str, local_prompt_len, end);
|
||||
return (tmp);
|
||||
}
|
||||
|
||||
while (point < start)
|
||||
{
|
||||
tmp = mbrlen (str + point, max, &ps);
|
||||
|
||||
@@ -1740,7 +1740,7 @@ split_at_delims (string, slen, delims, sentinel, nwp, cwp)
|
||||
|
||||
ret = (WORD_LIST *)NULL;
|
||||
|
||||
/* Remove sequences of whitspace characters at the start of the string, as
|
||||
/* Remove sequences of whitespace characters at the start of the string, as
|
||||
long as those characters are delimiters. */
|
||||
for (i = 0; member (string[i], d) && spctabnl (string[i]); i++)
|
||||
;
|
||||
@@ -1810,9 +1810,10 @@ split_at_delims (string, slen, delims, sentinel, nwp, cwp)
|
||||
|
||||
/* Special case for SENTINEL at the end of STRING. If we haven't found
|
||||
the word containing SENTINEL yet, and the index we're looking for is at
|
||||
the end of STRING, add an additional null argument and set the current
|
||||
word pointer to that. */
|
||||
if (cwp && cw == -1 && sentinel >= slen)
|
||||
the end of STRING (or past the end of the previously-found token,
|
||||
possible if the end of the line is composed solely of IFS whitespace)
|
||||
add an additional null argument and set the current word pointer to that. */
|
||||
if (cwp && cw == -1 && (sentinel >= slen || sentinel >= te))
|
||||
{
|
||||
if (whitespace (string[sentinel - 1]))
|
||||
{
|
||||
|
||||
@@ -1740,7 +1740,7 @@ split_at_delims (string, slen, delims, sentinel, nwp, cwp)
|
||||
|
||||
ret = (WORD_LIST *)NULL;
|
||||
|
||||
/* Remove sequences of whitspace characters at the start of the string, as
|
||||
/* Remove sequences of whitespace characters at the start of the string, as
|
||||
long as those characters are delimiters. */
|
||||
for (i = 0; member (string[i], d) && spctabnl (string[i]); i++)
|
||||
;
|
||||
@@ -1812,7 +1812,7 @@ split_at_delims (string, slen, delims, sentinel, nwp, cwp)
|
||||
the word containing SENTINEL yet, and the index we're looking for is at
|
||||
the end of STRING, add an additional null argument and set the current
|
||||
word pointer to that. */
|
||||
if (cwp && cw == -1 && sentinel >= slen)
|
||||
if (cwp && cw == -1 && (sentinel >= slen || sentinel >= te))
|
||||
{
|
||||
if (whitespace (string[sentinel - 1]))
|
||||
{
|
||||
@@ -2742,7 +2742,7 @@ pos_params (string, start, end, quoted)
|
||||
save = params = t;
|
||||
}
|
||||
|
||||
for (i = 1; params && i < start; i++)
|
||||
for (i = start ? 1 : 0; params && i < start; i++)
|
||||
params = params->next;
|
||||
if (params == 0)
|
||||
return ((char *)NULL);
|
||||
|
||||
Reference in New Issue
Block a user