commit bash-20070613 snapshot

This commit is contained in:
Chet Ramey
2011-12-07 09:09:21 -05:00
parent 3745eee9b1
commit 234d872963
11 changed files with 271 additions and 32 deletions
+35 -1
View File
@@ -14724,4 +14724,38 @@ jobs.c
the controlling terminal. If it's not, try to open /dev/tty and
assign it to shell_tty. Fixes problems reported by Derek Fawcus
<dfawcus@cisco.com>
6/13
----
support/shobj-conf
- changes to support shared object and shared library creation on AIX
5.x and later versions. From Niklas Edmundsson <nikke@acc.umu.se>
6/17
----
builtins/mkbuiltins.c
- new array of builtins, posix_builtins, containing builtins listed
as special to the command search order by POSIX
- add POSIX_BUILTIN to the builtin flags if the builtin name is one
that's special to the posix command search order
builtins.h
- new define, POSIX_BUILTIN, means that a builtin is special to the
posix command search order
6/22
----
lib/readline/display.c
- new macro, WRAP_OFFSET, intended to replace W_OFFSET. Takes prompt
strings longer than one physical line with invisible characters on
the second line into account when calculating the number of
invisible characters on the current screen line
- use WRAP_OFFSET where appropriate (update_line, _rl_move_cursor_relative)
- change update_line to deal with adjusting _rl_last_c_pos in a
multibyte environment when the prompt has invisible chars on the
second line and redisplay has output the invisible characters
- change _rl_move_cursor_relative to adjust _rl_last_c_pos in a
multibyte environment when the prompt has invisible chars on the
second line and the redisplay draws the invisible character. Fixes
redisplay bug reported by Andreas Schwab <schwab@suse.de>
+40
View File
@@ -14719,3 +14719,43 @@ jobs.c
fail, for subsequent error messages
- change initialize_job_control to turn off job control if the terminal
pgrp == -1 or is not equal to shell_pgrp (with an error message)
- in initialize_job_control, if the shell has been forced interactive
with -i, make sure stderr is hooked to a tty before using it as
the controlling terminal. If it's not, try to open /dev/tty and
assign it to shell_tty. Fixes problems reported by Derek Fawcus
<dfawcus@cisco.com>
6/13
----
support/shobj-conf
- changes to support shared object and shared library creation on AIX
5.x and later versions. From Niklas Edmundsson <nikke@acc.umu.se>
6/17
----
builtins/mkbuiltins.c
- new array of builtins, posix_builtins, containing builtins listed
as special to the command search order by POSIX
- add POSIX_BUILTIN to the builtin flags if the builtin name is one
that's special to the posix command search order
builtins.h
- new define, POSIX_BUILTIN, means that a builtin is special to the
posix command search order
6/22
----
lib/readline/display.c
- new macro, WRAP_OFFSET, intended to replace W_OFFSET. Takes prompt
strings longer than one physical line with invisible characters on
the second line into account when calculating the number of
invisible characters on the current screen line
- use WRAP_OFFSET where appropriate (update_line, _rl_move_cursor_relative)
- change update_line to deal with adjusting _rl_last_c_pos in a
multibyte environment when the prompt has invisible chars on the
second line and redisplay has output the invisible characters
- change _rl_move_cursor_relative to adjust _rl_last_c_pos in a
multibyte environment when the prompt has invisible chars on the
second line and the redisplay draws the invisible character. Fixes
bug reported by Andreas Schwab <schwab@suse.de>
+6 -5
View File
@@ -1,6 +1,6 @@
/* builtins.h -- What a builtin looks like, and where to find them. */
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -35,11 +35,12 @@
#endif
/* Flags describing various things about a builtin. */
#define BUILTIN_ENABLED 0x1 /* This builtin is enabled. */
#define BUILTIN_DELETED 0x2 /* This has been deleted with enable -d. */
#define STATIC_BUILTIN 0x4 /* This builtin is not dynamically loaded. */
#define SPECIAL_BUILTIN 0x8 /* This is a Posix `special' builtin. */
#define BUILTIN_ENABLED 0x01 /* This builtin is enabled. */
#define BUILTIN_DELETED 0x02 /* This has been deleted with enable -d. */
#define STATIC_BUILTIN 0x04 /* This builtin is not dynamically loaded. */
#define SPECIAL_BUILTIN 0x08 /* This is a Posix `special' builtin. */
#define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */
#define POSIX_BUILTIN 0x20 /* This builtins is special in the Posix command search order. */
#define BASE_INDENT 4
+60
View File
@@ -0,0 +1,60 @@
/* builtins.h -- What a builtin looks like, and where to find them. */
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include "command.h"
#include "general.h"
#if defined (ALIAS)
#include "alias.h"
#endif
/* Flags describing various things about a builtin. */
#define BUILTIN_ENABLED 0x1 /* This builtin is enabled. */
#define BUILTIN_DELETED 0x2 /* This has been deleted with enable -d. */
#define STATIC_BUILTIN 0x4 /* This builtin is not dynamically loaded. */
#define SPECIAL_BUILTIN 0x8 /* This is a Posix `special' builtin. */
#define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */
#define BASE_INDENT 4
/* The thing that we build the array of builtins out of. */
struct builtin {
char *name; /* The name that the user types. */
sh_builtin_func_t *function; /* The address of the invoked function. */
int flags; /* One of the #defines above. */
char * const *long_doc; /* NULL terminated array of strings. */
const char *short_doc; /* Short version of documenation. */
char *handle; /* for future use */
};
/* Found in builtins.c, created by builtins/mkbuiltins. */
extern int num_shell_builtins; /* Number of shell builtins. */
extern struct builtin static_shell_builtins[];
extern struct builtin *shell_builtins;
extern struct builtin *current_builtin;
+11 -10
View File
@@ -1,7 +1,7 @@
This file is exec.def, from which is created exec.c.
It implements the builtin "exec" in Bash.
Copyright (C) 1987-2003 Free Software Foundation, Inc.
Copyright (C) 1987-2007 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -23,15 +23,16 @@ $PRODUCES exec.c
$BUILTIN exec
$FUNCTION exec_builtin
$SHORT_DOC exec [-cl] [-a name] file [redirection ...]
Execute FILE, replacing this shell with the specified program.
If FILE is not specified, the redirections take effect in this
shell. If the first argument is `-l', then place a dash in the
zeroth arg passed to FILE, as login does. If the `-c' option
is supplied, FILE is executed with a null environment. The `-a'
option means set argv[0] of the executed process to NAME.
If the file cannot be executed and the shell is not interactive,
then the shell exits, unless the shell option `execfail' is set.
$SHORT_DOC exec [-cl] [-a name] [command [arguments ...]]
Execute COMMAND, replacing this shell with the specified program.
ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,
any redirections take effect in the current shell. If the `-l' option
is supplied, the shell places a dash in the zeroth argument to the
COMMAND, as login does. If the `-c' option is supplied, COMMAND is
executed with an empty environment. The `-a' option causes the shell
to pass NAME as the zeroth argument to COMMAND. If the file cannot be
executed, a non-interactive shell exits, unless the shell option `execfail'
is set.
$END
#include <config.h>
+2 -2
View File
@@ -24,12 +24,12 @@ $PRODUCES exec.c
$BUILTIN exec
$FUNCTION exec_builtin
$SHORT_DOC exec [-cl] [-a name] file [redirection ...]
Exec FILE, replacing this shell with the specified program.
Execute FILE, replacing this shell with the specified program.
If FILE is not specified, the redirections take effect in this
shell. If the first argument is `-l', then place a dash in the
zeroth arg passed to FILE, as login does. If the `-c' option
is supplied, FILE is executed with a null environment. The `-a'
option means to make set argv[0] of the executed process to NAME.
option means set argv[0] of the executed process to NAME.
If the file cannot be executed and the shell is not interactive,
then the shell exits, unless the shell option `execfail' is set.
$END
+21 -1
View File
@@ -71,6 +71,7 @@ extern char *strcpy ();
/* Flag values that builtins can have. */
#define BUILTIN_FLAG_SPECIAL 0x01
#define BUILTIN_FLAG_ASSIGNMENT 0x02
#define BUILTIN_FLAG_POSIX_BUILTIN 0x04
#define BASE_INDENT 4
@@ -154,9 +155,18 @@ char *assignment_builtins[] =
(char *)NULL
};
/* The builtin commands that are special to the POSIX search order. */
char *posix_builtins[] =
{
"alias", "bg", "cd", "command", "false", "fc", "fg", "getopts", "jobs",
"kill", "newgrp", "pwd", "read", "true", "umask", "unalias", "wait",
(char *)NULL
};
/* Forward declarations. */
static int is_special_builtin ();
static int is_assignment_builtin ();
static int is_posix_builtin ();
#if !defined (HAVE_RENAME)
static int rename ();
@@ -800,6 +810,8 @@ builtin_handler (self, defs, arg)
new->flags |= BUILTIN_FLAG_SPECIAL;
if (is_assignment_builtin (name))
new->flags |= BUILTIN_FLAG_ASSIGNMENT;
if (is_posix_builtin (name))
new->flags |= BUILTIN_FLAG_POSIX_BUILTIN;
array_add ((char *)new, defs->builtins);
building_builtin = 1;
@@ -1217,10 +1229,11 @@ write_builtins (defs, structfile, externfile)
else
fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
fprintf (structfile, "%s%s%s, %s_doc,\n",
fprintf (structfile, "%s%s%s%s, %s_doc,\n",
"BUILTIN_ENABLED | STATIC_BUILTIN",
(builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "",
document_name (builtin));
fprintf
@@ -1561,6 +1574,13 @@ is_assignment_builtin (name)
return (_find_in_table (name, assignment_builtins));
}
static int
is_posix_builtin (name)
char *name;
{
return (_find_in_table (name, posix_builtins));
}
#if !defined (HAVE_RENAME)
static int
rename (from, to)
+26 -3
View File
@@ -1,7 +1,7 @@
/* mkbuiltins.c - Create builtins.c, builtext.h, and builtdoc.c from
a single source file called builtins.def. */
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -71,6 +71,7 @@ extern char *strcpy ();
/* Flag values that builtins can have. */
#define BUILTIN_FLAG_SPECIAL 0x01
#define BUILTIN_FLAG_ASSIGNMENT 0x02
#define BUILTIN_FLAG_POSIX_BUILTIN 0x04
#define BASE_INDENT 4
@@ -154,9 +155,18 @@ char *assignment_builtins[] =
(char *)NULL
};
/* The builtin commands that are special to the POSIX search order. */
char *posix_builtins[] =
{
"alias", "bg", "cd", "command", "false", "fc", "fg", "getopts", "jobs",
"kill", "newgrp", "pwd", "read", "true", "umask", "unalias", "wait",
(char *)NULL
};
/* Forward declarations. */
static int is_special_builtin ();
static int is_assignment_builtin ();
static int is_posix_builtin ();
#if !defined (HAVE_RENAME)
static int rename ();
@@ -800,6 +810,11 @@ builtin_handler (self, defs, arg)
new->flags |= BUILTIN_FLAG_SPECIAL;
if (is_assignment_builtin (name))
new->flags |= BUILTIN_FLAG_ASSIGNMENT;
if (is_posix_builtin (name))
{
fprintf(stderr, "%s: added BUILTIN_FLAG_POSIX_BUILTIN\n", name);
new->flags |= BUILTIN_FLAG_POSIX_BUILTIN;
}
array_add ((char *)new, defs->builtins);
building_builtin = 1;
@@ -1080,7 +1095,7 @@ char *structfile_header[] = {
"/* This file is manufactured by ./mkbuiltins, and should not be",
" edited by hand. See the source to mkbuiltins for details. */",
"",
"/* Copyright (C) 1987-2002 Free Software Foundation, Inc.",
"/* Copyright (C) 1987-2007 Free Software Foundation, Inc.",
"",
" This file is part of GNU Bash, the Bourne Again SHell.",
"",
@@ -1217,10 +1232,11 @@ write_builtins (defs, structfile, externfile)
else
fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
fprintf (structfile, "%s%s%s, %s_doc,\n",
fprintf (structfile, "%s%s%s%s, %s_doc,\n",
"BUILTIN_ENABLED | STATIC_BUILTIN",
(builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
(builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "",
document_name (builtin));
fprintf
@@ -1561,6 +1577,13 @@ is_assignment_builtin (name)
return (_find_in_table (name, assignment_builtins));
}
static int
is_posix_builtin (name)
char *name;
{
return (_find_in_table (name, posix_builtins));
}
#if !defined (HAVE_RENAME)
static int
rename (from, to)
+30 -3
View File
@@ -938,6 +938,9 @@ rl_redisplay ()
second and subsequent lines start at inv_lbreaks[N], offset by
OFFSET (which has already been calculated above). */
#define WRAP_OFFSET(line, offset) ((line == 0) \
? (offset ? prompt_invis_chars_first_line : 0) \
: ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
@@ -973,6 +976,13 @@ rl_redisplay ()
_rl_last_c_pos > wrap_offset &&
o_cpos < prompt_last_invisible)
_rl_last_c_pos -= wrap_offset;
else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
(MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
cpos_adjusted == 0 &&
_rl_last_c_pos != o_cpos &&
_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - (wrap_offset-prompt_invis_chars_first_line)))
_rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
/* If this is the line with the prompt, we might need to
compensate for invisible characters in the new line. Do
@@ -992,6 +1002,19 @@ rl_redisplay ()
if (nleft)
_rl_clear_to_eol (nleft);
}
#if 0
/* This segment is intended to handle the case where the prompt
has invisible characters on the second line and the new line
to be displayed needs to clear the rest of the old characters
out (e.g., when printing the i-search prompt). In general,
the case of the new line being shorter than the old.
Incomplete */
else if (linenum == prompt_last_screen_line &&
prompt_physical_chars > _rl_screenwidth &&
wrap_offset != prompt_invis_chars_first_line &&
_rl_last_c_pos == out &&
#endif
/* Since the new first line is now visible, save its length. */
if (linenum == 0)
@@ -1244,7 +1267,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
temp = _rl_last_c_pos;
else
temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
&& _rl_last_v_pos == current_line - 1)
{
@@ -1805,7 +1828,7 @@ _rl_move_cursor_relative (new, data)
int woff; /* number of invisible chars on current line */
int cpos, dpos; /* current and desired cursor positions */
woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
cpos = _rl_last_c_pos;
#if defined (HANDLE_MULTIBYTE)
/* If we have multibyte characters, NEW is indexed by the buffer point in
@@ -1819,7 +1842,11 @@ _rl_move_cursor_relative (new, data)
/* 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 ((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 &&
new > (prompt_last_invisible-_rl_screenwidth-wrap_offset)))
{
dpos -= woff;
/* Since this will be assigned to _rl_last_c_pos at the end (more
+37 -4
View File
@@ -938,6 +938,9 @@ rl_redisplay ()
second and subsequent lines start at inv_lbreaks[N], offset by
OFFSET (which has already been calculated above). */
#define WRAP_OFFSET(line, offset) ((line == 0) \
? (offset ? prompt_invis_chars_first_line : 0) \
: ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
@@ -973,6 +976,13 @@ rl_redisplay ()
_rl_last_c_pos > wrap_offset &&
o_cpos < prompt_last_invisible)
_rl_last_c_pos -= wrap_offset;
else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
(MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
cpos_adjusted == 0 &&
_rl_last_c_pos != o_cpos &&
_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - (wrap_offset-prompt_invis_chars_first_line)))
_rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
/* If this is the line with the prompt, we might need to
compensate for invisible characters in the new line. Do
@@ -992,6 +1002,18 @@ rl_redisplay ()
if (nleft)
_rl_clear_to_eol (nleft);
}
#if 0
/* This segment is intended to handle the case where the prompt
has invisible characters on the second line and the new line
to be displayed needs to clear the rest of the old characters
out (e.g., when printing the i-search prompt). In general,
the case of the new line being shorter than the old.
Incomplete */
else if (linenum == 1 && prompt_physical_chars > _rl_screenwidth &&
wrap_offset != prompt_invis_chars_first_line &&
_rl_last_c_pos == out &&
#endif
/* Since the new first line is now visible, save its length. */
if (linenum == 0)
@@ -1244,7 +1266,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
temp = _rl_last_c_pos;
else
temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
&& _rl_last_v_pos == current_line - 1)
{
@@ -1553,7 +1575,15 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (lendiff < 0)
{
_rl_output_some_chars (nfd, temp);
_rl_last_c_pos += col_temp;
_rl_last_c_pos += _rl_col_width (nfd, 0, temp);
/* If nfd begins before any invisible characters in the prompt,
adjust _rl_last_c_pos to account for wrap_offset and set
cpos_adjusted to let the caller know. */
if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
}
return;
}
/* Sometimes it is cheaper to print the characters rather than
@@ -1797,7 +1827,7 @@ _rl_move_cursor_relative (new, data)
int woff; /* number of invisible chars on current line */
int cpos, dpos; /* current and desired cursor positions */
woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
cpos = _rl_last_c_pos;
#if defined (HANDLE_MULTIBYTE)
/* If we have multibyte characters, NEW is indexed by the buffer point in
@@ -1811,7 +1841,10 @@ _rl_move_cursor_relative (new, data)
/* 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 ((new > prompt_last_invisible) || /* XXX - don't use woff here */
(prompt_physical_chars > _rl_screenwidth && _rl_last_v_pos == 1 &&
wrap_offset != woff &&
new > (prompt_last_invisible-_rl_screenwidth-wrap_offset)))
{
dpos -= woff;
/* Since this will be assigned to _rl_last_c_pos at the end (more
+3 -3
View File
@@ -10,7 +10,7 @@
# Chet Ramey
# chet@po.cwru.edu
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
# Copyright (C) 1996-2007 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
@@ -247,7 +247,7 @@ osf*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
aix4.[2-9]*-*gcc*) # lightly tested by jik@cisco.com
aix4.[2-9]*-*gcc*|aix[5-9].*-*gcc*) # lightly tested by jik@cisco.com
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='ld'
SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
@@ -258,7 +258,7 @@ aix4.[2-9]*-*gcc*) # lightly tested by jik@cisco.com
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
aix4.[2-9]*)
aix4.[2-9]*|aix[5-9].*)
SHOBJ_CFLAGS=-K
SHOBJ_LD='ld'
SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'