commit bash-20040311 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 12:55:32 -05:00
parent 5ba8ff6eaa
commit 762a763b05
42 changed files with 22224 additions and 137 deletions
+20
View File
@@ -1,3 +1,23 @@
This document details the changes between this version, bash-3.0-rc1,
and the previous version, bash-3.0-beta1.
1. Changes to Bash
a. Fixed a bug that caused incorrect behavior when referecing element 0 of
an array using $array, element 0 was unset, and `set -u' was enabled.
b. System-specific changes for: SCO Unix 3.2, Tandem.
c. Fixed a bug that caused inappropriate word splitting when a variable was
expanded within a double-quoted string that also included $@.
d. Fixed a bug that caused `pwd' to not display anything in physical mode
when the file system had changed underneath the shell.
e. Fixed a bug in the pre- and post- increment and decrement parsing in the
expression evaluator that caused errors when the operands and corresponding
operators were separated by whitespace.
------------------------------------------------------------------------------
This document details the changes between this version, bash-3.0-beta1,
and the previous version, bash-3.0-alpha.
+68
View File
@@ -9234,3 +9234,71 @@ subst.c
of just the escape characters if the expansion appears between
double quotes or in a here-document (for simple variable expansions
or expansions of positional parameters)
3/8
---
subst.c
- analogous changes to parameter_brace_expand_word to fix the same
quoting problem as on 3/4; fix callers to understand that the
value returned might be quoted now and should be dequoted if
necessary
- add a `quoted' argument to get_var_and_type, change callers
- change today's fix and fix from 3/4 to not call quote_string if the
value is "" (because quote_string turns that into CTLNUL\0)
3/9
---
builtins/cd.def
- resetpwd() now takes a `caller' argument so it can be used by pwd
as well as cd
- change pwd_builtin to call resetpwd() if sh_physpath() fails to
return a valid pathname
3/14
----
expr.c
- reworked exp0 and readtok() to make post-increment and post-decrement
into real tokens, which may be separated from their accompanying
variables by whitesapce
- made analogous changes to readtok() to make pre-increment and
pre-decrement work when separated from their accompanying identifier
by whitespace
3/18
----
lib/readline/misc.c
- in rl_maybe_unsave_line, don't force rl_replace_line to clear
the undo_list, since it might point directly at an undo list
from a history entry (to which we have no handle)
3/19
----
lib/readline/display.c
- rl_save_prompt and rl_restore_prompt now save and restore the value
of prompt_physical_chars
- set prompt_physical_chars in rl_redisplay when expand_prompt has
not been called (e.g., when rl_display_prompt is set and is not
equal to rl_prompt, like when searching)
lib/readline/histexpand.c
- don't call add_history in history_expand if the `:p' modifier is
supplied; leave that to the calling application. This means that
`history -p', for example, will not add anything to the history
list (as documented), nor will history expansions invoked by
emacs-mode M-C-e line editing
config-bot.h
- check whether HAVE_DECL_SYS_SIGLIST is defined to 1 rather than just
defined, to work around newer versions of autoconf defining it to 0
config.h.in
- change default status of HAVE_MALLOC to #undef instead of #define
bashhist.c
- extern declarations for rl_done and rl_dispatching
- don't call re_edit from pre_process_line unless rl_dispatcing is zero,
so we don't call it from something like shell-expand-line
- change pre_process_line to add an expanded history specification
that returned `print only' to the history list, since history_expand
no longer does it (and, when using readline, do it only when
rl_dispatching is zero)
+73 -1
View File
@@ -9218,8 +9218,80 @@ expr.c
- make the exponentiation operator (**) associative, so things like
2**3**4 work right (change `if' to `while')
3/2
3/3
---
lib/sh/strftime.c
- SCO Unix 3.2, like Solaris, requires that the system's `timezone'
variable be declared as long
lib/readline/{bind,histfile,input,parens}.c
- changes for Tandem (including `floss.h' (?))
3/4
---
subst.c
- change param_expand to quote the entire expanded string instead
of just the escape characters if the expansion appears between
double quotes or in a here-document (for simple variable expansions
or expansions of positional parameters)
3/8
---
subst.c
- analogous changes to parameter_brace_expand_word to fix the same
quoting problem as on 3/4; fix callers to understand that the
value returned might be quoted now and should be dequoted if
necessary
- add a `quoted' argument to get_var_and_type, change callers
- change today's fix and fix from 3/4 to not call quote_string if the
value is "" (because quote_string turns that into CTLNUL\0)
3/9
---
builtins/cd.def
- resetpwd() now takes a `caller' argument so it can be used by pwd
as well as cd
- change pwd_builtin to call resetpwd() if sh_physpath() fails to
return a valid pathname
3/14
----
expr.c
- reworked exp0 and readtok() to make post-increment and post-decrement
into real tokens, which may be separated from their accompanying
variables by whitesapce
- made analogous changes to readtok() to make pre-increment and
pre-decrement work when separated from their accompanying identifier
by whitespace
3/19
----
lib/readline/display.c
- rl_save_prompt and rl_restore_prompt now save and restore the value
of prompt_physical_chars
- set prompt_physical_chars in rl_redisplay when expand_prompt has
not been called (e.g., when rl_display_prompt is set and is not
equal to rl_prompt, like when searching)
lib/readline/histexpand.c
- don't call add_history in history_expand if the `:p' modifier is
supplied; leave that to the calling application. This means that
`history -p', for example, will not add anything to the history
list (as documented), nor will history expansions invoked by
emacs-mode M-C-e line editing
config-bot.h
- check whether HAVE_DECL_SYS_SIGLIST is defined to 1 rather than just
defined, to work around newer versions of autoconf defining it to 0
config.h.in
- change default status of HAVE_MALLOC to #undef instead of #define
bashhist.c
- extern declarations for rl_done and rl_dispatching
- don't call re_edit from pre_process_line unless rl_dispatcing is zero,
so we don't call it from something like shell-expand-line
- change pre_process_line to add an expanded history specification
that returned `print only' to the history list, since history_expand
no longer does it (and, when using readline, do it only when
rl_dispatching is zero)
-1
View File
@@ -1 +0,0 @@
CWRU.chlog
+9285
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
CWRU.chlog
+4
View File
@@ -682,6 +682,8 @@ tests/arith-for.tests f
tests/arith-for.right f
tests/arith.tests f
tests/arith.right f
tests/arith1.sub f
tests/arith2.sub f
tests/array.tests f
tests/array.right f
tests/array-at-star f
@@ -708,6 +710,7 @@ tests/dbg-support2.right f
tests/dbg-support2.tests f
tests/dollar-at-star f
tests/dollar-at1.sub f
tests/dollar-at2.sub f
tests/dollar-star1.sub f
tests/dollar.right f
tests/dstack.tests f
@@ -803,6 +806,7 @@ tests/read1.sub f
tests/read2.sub f
tests/read3.sub f
tests/read4.sub f
tests/read5.sub f
tests/redir.tests f
tests/redir.right f
tests/redir1.sub f
+85 -85
View File
@@ -15,96 +15,96 @@
'configure.in'
],
{
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_FUNC_CHOWN' => 1,
'AM_CONDITIONAL' => 1,
'AC_FUNC_ALLOCA' => 1,
'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_PROG_LN_S' => 1,
'AC_CHECK_FUNCS' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_HEADER_TIME' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_SUBST' => 1,
'AC_LIBSOURCE' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_PROG_CXX' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_FUNC_STAT' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_PROG_AWK' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CONFIG_FILES' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_C_VOLATILE' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AC_TYPE_MODE_T' => 1,
'm4_pattern_allow' => 1,
'AC_FUNC_MMAP' => 1,
'AC_PROG_RANLIB' => 1,
'AC_HEADER_MAJOR' => 1,
'AC_FUNC_ERROR_AT_LINE' => 1,
'AC_FUNC_FSEEKO' => 1,
'm4_pattern_forbid' => 1,
'AC_PATH_X' => 1,
'AC_TYPE_UID_T' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_PROG_INSTALL' => 1,
'AC_INIT' => 1,
'AC_CHECK_LIB' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_SETPGRP' => 1,
'AC_HEADER_STAT' => 1,
'AC_FUNC_STRCOLL' => 1,
'm4_include' => 1,
'AC_STRUCT_ST_BLOCKS' => 1,
'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_REALLOC' => 1,
'include' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_PROG_CPP' => 1,
'AC_TYPE_PID_T' => 1,
'AC_C_INLINE' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_HEADER_STDC' => 1,
'AC_FUNC_STRNLEN' => 1,
'AC_FUNC_MBRTOWC' => 1,
'AC_C_CONST' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AC_CHECK_MEMBERS' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_CHECK_TYPES' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AM_CONDITIONAL' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_PROG_YACC' => 1,
'AC_C_INLINE' => 1,
'include' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_PROG_CC' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AH_OUTPUT' => 1,
'AC_PROG_LEX' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_PROG_MAKE_SET' => 1
'AC_TYPE_PID_T' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_STRUCT_TM' => 1,
'AC_PROG_CXX' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_HEADER_TIME' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
'AC_FUNC_ERROR_AT_LINE' => 1,
'AC_FUNC_STAT' => 1,
'm4_pattern_allow' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'AC_CHECK_LIB' => 1,
'AC_HEADER_STAT' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_FUNC_CHOWN' => 1,
'AC_CONFIG_FILES' => 1,
'AC_CHECK_FUNCS' => 1,
'AC_LIBSOURCE' => 1,
'AC_CHECK_TYPES' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AC_PROG_INSTALL' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_FUNC_STRNLEN' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_PROG_MAKE_SET' => 1,
'AC_PROG_YACC' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_INIT' => 1,
'AC_FUNC_REALLOC' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_SETPGRP' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_PROG_CC' => 1,
'AC_CHECK_MEMBERS' => 1,
'AH_OUTPUT' => 1,
'AC_HEADER_STDC' => 1,
'AM_MAINTAINER_MODE' => 1,
'AC_SUBST' => 1,
'AC_FUNC_MBRTOWC' => 1,
'AC_PROG_CPP' => 1,
'AC_FUNC_FSEEKO' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_C_CONST' => 1,
'AC_PATH_X' => 1,
'AC_PROG_LEX' => 1,
'AC_FUNC_ALLOCA' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
'm4_include' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_HEADER_MAJOR' => 1,
'AC_TYPE_UID_T' => 1,
'AC_PROG_RANLIB' => 1,
'AC_C_VOLATILE' => 1,
'm4_pattern_forbid' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_PROG_AWK' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AC_PROG_LN_S' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_FUNC_OBSTACK' => 1
}
], 'Request' )
);
+10 -2
View File
@@ -1,6 +1,6 @@
/* bashhist.c -- bash interface to the GNU history library. */
/* Copyright (C) 1993 Free Software Foundation, Inc.
/* Copyright (C) 1993-2004 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -52,6 +52,7 @@
#if defined (READLINE)
# include "bashline.h"
extern int rl_done, rl_dispatching; /* should really include readline.h */
#endif
#if !defined (errno)
@@ -444,12 +445,19 @@ pre_process_line (line, print_changes, addit)
/* If there was an error, return NULL. */
if (expanded < 0 || expanded == 2) /* 2 == print only */
{
# if defined (READLINE)
if (expanded == 2 && rl_dispatching == 0 && *history_value)
# else
if (expanded == 2 && *history_value)
# endif /* !READLINE */
maybe_add_history (history_value);
free (history_value);
# if defined (READLINE)
/* New hack. We can allow the user to edit the
failed history expansion. */
if (history_reediting && expanded < 0)
if (history_reediting && expanded < 0 && rl_done)
re_edit (line);
# endif /* READLINE */
return ((char *)NULL);
+813
View File
@@ -0,0 +1,813 @@
/* bashhist.c -- bash interface to the GNU history library. */
/* Copyright (C) 1993 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
#if defined (HISTORY)
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include "bashtypes.h"
#include <stdio.h>
#include <errno.h>
#include "bashansi.h"
#include "posixstat.h"
#include "filecntl.h"
#include "bashintl.h"
#include "shell.h"
#include "flags.h"
#include "input.h"
#include "parser.h" /* for the struct dstack stuff. */
#include "pathexp.h" /* for the struct ignorevar stuff */
#include "bashhist.h" /* matching prototypes and declarations */
#include "builtins/common.h"
#include <readline/history.h>
#include <glob/glob.h>
#include <glob/strmatch.h>
#if defined (READLINE)
# include "bashline.h"
extern int rl_done, rl_dispatching; /* should really include readline.h */
#endif
#if !defined (errno)
extern int errno;
#endif
static int histignore_item_func __P((struct ign *));
static int check_history_control __P((char *));
static void hc_erasedups __P((char *));
static void really_add_history __P((char *));
static struct ignorevar histignore =
{
"HISTIGNORE",
(struct ign *)0,
0,
(char *)0,
(sh_iv_item_func_t *)histignore_item_func,
};
#define HIGN_EXPAND 0x01
/* Declarations of bash history variables. */
/* Non-zero means to remember lines typed to the shell on the history
list. This is different than the user-controlled behaviour; this
becomes zero when we read lines from a file, for example. */
int remember_on_history = 1;
/* The number of lines that Bash has added to this history session. The
difference between the number of the top element in the history list
(offset from history_base) and the number of lines in the history file.
Appending this session's history to the history file resets this to 0. */
int history_lines_this_session;
/* The number of lines that Bash has read from the history file. */
int history_lines_in_file;
#if defined (BANG_HISTORY)
/* Non-zero means do no history expansion on this line, regardless
of what history_expansion says. */
int history_expansion_inhibited;
#endif
/* With the old default, every line was saved in the history individually.
I.e., if the user enters:
bash$ for i in a b c
> do
> echo $i
> done
Each line will be individually saved in the history.
bash$ history
10 for i in a b c
11 do
12 echo $i
13 done
14 history
If the variable command_oriented_history is set, multiple lines
which form one command will be saved as one history entry.
bash$ for i in a b c
> do
> echo $i
> done
bash$ history
10 for i in a b c
do
echo $i
done
11 history
The user can then recall the whole command all at once instead
of just being able to recall one line at a time.
This is now enabled by default.
*/
int command_oriented_history = 1;
/* Set to 1 if the first line of a possibly-multi-line command was saved
in the history list. Managed by maybe_add_history(), but global so
the history-manipluating builtins can see it. */
int current_command_first_line_saved = 0;
/* Non-zero means to store newlines in the history list when using
command_oriented_history rather than trying to use semicolons. */
int literal_history;
/* Non-zero means to append the history to the history file at shell
exit, even if the history has been stifled. */
int force_append_history;
/* A nit for picking at history saving. Flags have the following values:
Value == 0 means save all lines parsed by the shell on the history.
Value & HC_IGNSPACE means save all lines that do not start with a space.
Value & HC_IGNDUPS means save all lines that do not match the last
line saved.
Value & HC_ERASEDUPS means to remove all other matching lines from the
history list before saving the latest line. */
int history_control;
/* Set to 1 if the last command was added to the history list successfully
as a separate history entry; set to 0 if the line was ignored or added
to a previous entry as part of command-oriented-history processing. */
int hist_last_line_added;
#if defined (READLINE)
/* If non-zero, and readline is being used, the user is offered the
chance to re-edit a failed history expansion. */
int history_reediting;
/* If non-zero, and readline is being used, don't directly execute a
line with history substitution. Reload it into the editing buffer
instead and let the user further edit and confirm with a newline. */
int hist_verify;
#endif /* READLINE */
/* Non-zero means to not save function definitions in the history list. */
int dont_save_function_defs;
/* Variables declared in other files used here. */
extern int current_command_line_count;
extern struct dstack dstack;
static int bash_history_inhibit_expansion __P((char *, int));
#if defined (READLINE)
static void re_edit __P((char *));
#endif
static int history_expansion_p __P((char *));
static int shell_comment __P((char *));
static int should_expand __P((char *));
static HIST_ENTRY *last_history_entry __P((void));
static char *expand_histignore_pattern __P((char *));
static int history_should_ignore __P((char *));
/* Is the history expansion starting at string[i] one that should not
be expanded? */
static int
bash_history_inhibit_expansion (string, i)
char *string;
int i;
{
/* The shell uses ! as a pattern negation character in globbing [...]
expressions, so let those pass without expansion. */
if (i > 0 && (string[i - 1] == '[') && member (']', string + i + 1))
return (1);
/* The shell uses ! as the indirect expansion character, so let those
expansions pass as well. */
else if (i > 1 && string[i - 1] == '{' && string[i - 2] == '$' &&
member ('}', string + i + 1))
return (1);
#if defined (EXTENDED_GLOB)
else if (extended_glob && i > 1 && string[i+1] == '(' && member (')', string + i + 2))
return (1);
#endif
else
return (0);
}
void
bash_initialize_history ()
{
history_quotes_inhibit_expansion = 1;
history_search_delimiter_chars = ";&()|<>";
history_inhibit_expansion_function = bash_history_inhibit_expansion;
sv_histchars ("histchars");
}
void
bash_history_reinit (interact)
int interact;
{
#if defined (BANG_HISTORY)
history_expansion = interact != 0;
history_expansion_inhibited = 1;
#endif
remember_on_history = interact != 0;
history_inhibit_expansion_function = bash_history_inhibit_expansion;
}
void
bash_history_disable ()
{
remember_on_history = 0;
#if defined (BANG_HISTORY)
history_expansion_inhibited = 1;
#endif
}
void
bash_history_enable ()
{
remember_on_history = 1;
#if defined (BANG_HISTORY)
history_expansion_inhibited = 0;
#endif
history_inhibit_expansion_function = bash_history_inhibit_expansion;
sv_history_control ("HISTCONTROL");
sv_histignore ("HISTIGNORE");
}
/* Load the history list from the history file. */
void
load_history ()
{
char *hf;
struct stat buf;
/* Truncate history file for interactive shells which desire it.
Note that the history file is automatically truncated to the
size of HISTSIZE if the user does not explicitly set the size
differently. */
set_if_not ("HISTFILESIZE", get_string_value ("HISTSIZE"));
sv_histsize ("HISTFILESIZE");
/* Read the history in HISTFILE into the history list. */
hf = get_string_value ("HISTFILE");
if (hf && *hf && stat (hf, &buf) == 0)
{
read_history (hf);
using_history ();
history_lines_in_file = where_history ();
}
}
#ifdef INCLUDE_UNUSED
/* Write the existing history out to the history file. */
void
save_history ()
{
char *hf;
struct stat buf;
hf = get_string_value ("HISTFILE");
if (hf && *hf && stat (hf, &buf) == 0)
{
/* Append only the lines that occurred this session to
the history file. */
using_history ();
if (history_lines_this_session < where_history () || force_append_history)
append_history (history_lines_this_session, hf);
else
write_history (hf);
sv_histsize ("HISTFILESIZE");
}
}
#endif
int
maybe_append_history (filename)
char *filename;
{
int fd, result;
struct stat buf;
result = EXECUTION_SUCCESS;
if (history_lines_this_session && (history_lines_this_session < where_history ()))
{
/* If the filename was supplied, then create it if necessary. */
if (stat (filename, &buf) == -1 && errno == ENOENT)
{
fd = open (filename, O_WRONLY|O_CREAT, 0600);
if (fd < 0)
{
builtin_error (_("%s: cannot create: %s"), filename, strerror (errno));
return (EXECUTION_FAILURE);
}
close (fd);
}
result = append_history (history_lines_this_session, filename);
history_lines_in_file += history_lines_this_session;
history_lines_this_session = 0;
}
return (result);
}
/* If this is an interactive shell, then append the lines executed
this session to the history file. */
int
maybe_save_shell_history ()
{
int result;
char *hf;
struct stat buf;
result = 0;
if (history_lines_this_session)
{
hf = get_string_value ("HISTFILE");
if (hf && *hf)
{
/* If the file doesn't exist, then create it. */
if (stat (hf, &buf) == -1)
{
int file;
file = open (hf, O_CREAT | O_TRUNC | O_WRONLY, 0600);
if (file != -1)
close (file);
}
/* Now actually append the lines if the history hasn't been
stifled. If the history has been stifled, rewrite the
history file. */
using_history ();
if (history_lines_this_session <= where_history () || force_append_history)
{
result = append_history (history_lines_this_session, hf);
history_lines_in_file += history_lines_this_session;
}
else
{
result = write_history (hf);
history_lines_in_file = history_lines_this_session;
}
history_lines_this_session = 0;
sv_histsize ("HISTFILESIZE");
}
}
return (result);
}
#if defined (READLINE)
/* Tell readline () that we have some text for it to edit. */
static void
re_edit (text)
char *text;
{
if (bash_input.type == st_stdin)
bash_re_edit (text);
}
#endif /* READLINE */
/* Return 1 if this line needs history expansion. */
static int
history_expansion_p (line)
char *line;
{
register char *s;
for (s = line; *s; s++)
if (*s == history_expansion_char || *s == history_subst_char)
return 1;
return 0;
}
/* Do pre-processing on LINE. If PRINT_CHANGES is non-zero, then
print the results of expanding the line if there were any changes.
If there is an error, return NULL, otherwise the expanded line is
returned. If ADDIT is non-zero the line is added to the history
list after history expansion. ADDIT is just a suggestion;
REMEMBER_ON_HISTORY can veto, and does.
Right now this does history expansion. */
char *
pre_process_line (line, print_changes, addit)
char *line;
int print_changes, addit;
{
char *history_value;
char *return_value;
int expanded;
return_value = line;
expanded = 0;
# if defined (BANG_HISTORY)
/* History expand the line. If this results in no errors, then
add that line to the history if ADDIT is non-zero. */
if (!history_expansion_inhibited && history_expansion && history_expansion_p (line))
{
expanded = history_expand (line, &history_value);
if (expanded)
{
if (print_changes)
{
if (expanded < 0)
internal_error ("%s", history_value);
#if defined (READLINE)
else if (hist_verify == 0 || expanded == 2)
#else
else
#endif
fprintf (stderr, "%s\n", history_value);
}
/* If there was an error, return NULL. */
if (expanded < 0 || expanded == 2) /* 2 == print only */
{
# if defined (READLINE)
if (expanded == 2 && rl_dispatching == 0 && *history_value)
# else
if (expanded == 2 && *history_value)
# endif /* !READLINE */
maybe_add_history (history_value);
free (history_value);
# if defined (READLINE)
/* New hack. We can allow the user to edit the
failed history expansion. */
if (history_reediting && expanded < 0 && rl_done)
re_edit (line);
# endif /* READLINE */
return ((char *)NULL);
}
# if defined (READLINE)
if (hist_verify && expanded == 1)
{
re_edit (history_value);
return ((char *)NULL);
}
# endif
}
/* Let other expansions know that return_value can be free'ed,
and that a line has been added to the history list. Note
that we only add lines that have something in them. */
expanded = 1;
return_value = history_value;
}
# endif /* BANG_HISTORY */
if (addit && remember_on_history && *return_value)
maybe_add_history (return_value);
#if 0
if (expanded == 0)
return_value = savestring (line);
#endif
return (return_value);
}
/* Return 1 if the first non-whitespace character in LINE is a `#', indicating
* that the line is a shell comment. */
static int
shell_comment (line)
char *line;
{
char *p;
for (p = line; p && *p && whitespace (*p); p++)
;
return (p && *p == '#');
}
#ifdef INCLUDE_UNUSED
/* Remove shell comments from LINE. A `#' and anything after it is a comment.
This isn't really useful yet, since it doesn't handle quoting. */
static char *
filter_comments (line)
char *line;
{
char *p;
for (p = line; p && *p && *p != '#'; p++)
;
if (p && *p == '#')
*p = '\0';
return (line);
}
#endif
/* Check LINE against what HISTCONTROL says to do. Returns 1 if the line
should be saved; 0 if it should be discarded. */
static int
check_history_control (line)
char *line;
{
HIST_ENTRY *temp;
int r;
if (history_control == 0)
return 1;
/* ignorespace or ignoreboth */
if ((history_control & HC_IGNSPACE) && *line == ' ')
return 0;
/* ignoredups or ignoreboth */
if (history_control & HC_IGNDUPS)
{
using_history ();
temp = previous_history ();
r = (temp == 0 || STREQ (temp->line, line) == 0);
using_history ();
if (r == 0)
return r;
}
return 1;
}
/* Remove all entries matching LINE from the history list. Triggered when
HISTCONTROL includes `erasedups'. */
static void
hc_erasedups (line)
char *line;
{
HIST_ENTRY *temp;
int r;
using_history ();
while (temp = previous_history ())
{
if (STREQ (temp->line, line))
{
r = where_history ();
remove_history (r);
}
}
using_history ();
}
/* Add LINE to the history list, handling possibly multi-line compound
commands. We note whether or not we save the first line of each command
(which is usually the entire command and history entry), and don't add
the second and subsequent lines of a multi-line compound command if we
didn't save the first line. We don't usually save shell comment lines in
compound commands in the history, because they could have the effect of
commenting out the rest of the command when the entire command is saved as
a single history entry (when COMMAND_ORIENTED_HISTORY is enabled). If
LITERAL_HISTORY is set, we're saving lines in the history with embedded
newlines, so it's OK to save comment lines. We also make sure to save
multiple-line quoted strings or other constructs. */
void
maybe_add_history (line)
char *line;
{
hist_last_line_added = 0;
/* Don't use the value of history_control to affect the second
and subsequent lines of a multi-line command (old code did
this only when command_oriented_history is enabled). */
if (current_command_line_count > 1)
{
if (current_command_first_line_saved &&
(literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0))
bash_add_history (line);
return;
}
/* This is the first line of a (possible multi-line) command. Note whether
or not we should save the first line and remember it. */
current_command_first_line_saved = check_add_history (line, 0);
}
/* Just check LINE against HISTCONTROL and HISTIGNORE and add it to the
history if it's OK. Used by `history -s' as well as maybe_add_history().
Returns 1 if the line was saved in the history, 0 otherwise. */
int
check_add_history (line, force)
char *line;
int force;
{
if (check_history_control (line) && history_should_ignore (line) == 0)
{
/* We're committed to saving the line. If the user has requested it,
remove other matching lines from the history. */
if (history_control & HC_ERASEDUPS)
hc_erasedups (line);
if (force)
{
really_add_history (line);
using_history ();
}
else
bash_add_history (line);
return 1;
}
return 0;
}
/* Add a line to the history list.
The variable COMMAND_ORIENTED_HISTORY controls the style of history
remembering; when non-zero, and LINE is not the first line of a
complete parser construct, append LINE to the last history line instead
of adding it as a new line. */
void
bash_add_history (line)
char *line;
{
int add_it, offset, curlen;
HIST_ENTRY *current, *old;
char *chars_to_add, *new_line;
add_it = 1;
if (command_oriented_history && current_command_line_count > 1)
{
chars_to_add = literal_history ? "\n" : history_delimiting_chars ();
using_history ();
current = previous_history ();
if (current)
{
/* If the previous line ended with an escaped newline (escaped
with backslash, but otherwise unquoted), then remove the quoted
newline, since that is what happens when the line is parsed. */
curlen = strlen (current->line);
if (dstack.delimiter_depth == 0 && current->line[curlen - 1] == '\\' &&
current->line[curlen - 2] != '\\')
{
current->line[curlen - 1] = '\0';
curlen--;
chars_to_add = "";
}
new_line = (char *)xmalloc (1
+ curlen
+ strlen (line)
+ strlen (chars_to_add));
sprintf (new_line, "%s%s%s", current->line, chars_to_add, line);
offset = where_history ();
old = replace_history_entry (offset, new_line, current->data);
free (new_line);
if (old)
free_history_entry (old);
add_it = 0;
}
}
if (add_it)
really_add_history (line);
using_history ();
}
static void
really_add_history (line)
char *line;
{
hist_last_line_added = 1;
add_history (line);
history_lines_this_session++;
}
int
history_number ()
{
using_history ();
return (get_string_value ("HISTSIZE") ? history_base + where_history () : 1);
}
static int
should_expand (s)
char *s;
{
char *p;
for (p = s; p && *p; p++)
{
if (*p == '\\')
p++;
else if (*p == '&')
return 1;
}
return 0;
}
static int
histignore_item_func (ign)
struct ign *ign;
{
if (should_expand (ign->val))
ign->flags |= HIGN_EXPAND;
return (0);
}
void
setup_history_ignore (varname)
char *varname;
{
setup_ignore_patterns (&histignore);
}
static HIST_ENTRY *
last_history_entry ()
{
HIST_ENTRY *he;
using_history ();
he = previous_history ();
using_history ();
return he;
}
char *
last_history_line ()
{
HIST_ENTRY *he;
he = last_history_entry ();
if (he == 0)
return ((char *)NULL);
return he->line;
}
static char *
expand_histignore_pattern (pat)
char *pat;
{
HIST_ENTRY *phe;
char *ret;
phe = last_history_entry ();
if (phe == (HIST_ENTRY *)0)
return (savestring (pat));
ret = strcreplace (pat, '&', phe->line, 1);
return ret;
}
/* Return 1 if we should not put LINE into the history according to the
patterns in HISTIGNORE. */
static int
history_should_ignore (line)
char *line;
{
register int i, match;
char *npat;
if (histignore.num_ignores == 0)
return 0;
for (i = match = 0; i < histignore.num_ignores; i++)
{
if (histignore.ignores[i].flags & HIGN_EXPAND)
npat = expand_histignore_pattern (histignore.ignores[i].val);
else
npat = histignore.ignores[i].val;
match = strmatch (npat, line, FNMATCH_EXTFLAG) != FNM_NOMATCH;
if (histignore.ignores[i].flags & HIGN_EXPAND)
free (npat);
if (match)
break;
}
return match;
}
#endif /* HISTORY */
+1 -1
View File
@@ -1765,7 +1765,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 ();
}
+2981
View File
File diff suppressed because it is too large Load Diff
+11 -4
View File
@@ -122,13 +122,14 @@ bindpwd (no_symlinks)
/* Call get_working_directory to reset the value of
the_current_working_directory () */
static char *
resetpwd ()
resetpwd (caller)
char *caller;
{
char *tdir;
FREE (the_current_working_directory);
the_current_working_directory = (char *)NULL;
tdir = get_working_directory ("cd");
tdir = get_working_directory (caller);
return (tdir);
}
@@ -337,6 +338,12 @@ pwd_builtin (list)
directory = tcwd ? (verbatim_pwd ? sh_physpath (tcwd, 0) : tcwd)
: get_working_directory ("pwd");
/* Try again using getcwd() if canonicalization fails (for instance, if
the file system has changed state underneath bash). */
if (tcwd && directory == 0)
directory = resetpwd ("pwd");
#undef tcwd
if (directory)
@@ -416,7 +423,7 @@ change_to_directory (newdir, nolinks)
/* If canonicalization failed, but the chdir succeeded, reset the
shell's idea of the_current_working_directory. */
if (canon_failed)
resetpwd ();
resetpwd ("cd");
else
{
FREE (the_current_working_directory);
@@ -439,7 +446,7 @@ change_to_directory (newdir, nolinks)
verbatim. If we succeed, reinitialize the_current_working_directory. */
if (chdir (newdir) == 0)
{
tdir = resetpwd ();
tdir = resetpwd ("cd");
FREE (tdir);
return (1);
+1 -1
View File
@@ -56,7 +56,7 @@
#endif
/* backwards compatibility between different autoconf versions */
#if defined (HAVE_DECL_SYS_SIGLIST) && !defined (SYS_SIGLIST_DECLARED)
#if HAVE_DECL_SYS_SIGLIST && !defined (SYS_SIGLIST_DECLARED)
# define SYS_SIGLIST_DECLARED
#endif
+181
View File
@@ -0,0 +1,181 @@
/* config-bot.h */
/* modify settings or make new ones based on what autoconf tells us. */
/* Copyright (C) 1989-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. */
/*********************************************************/
/* Modify or set defines based on the configure results. */
/*********************************************************/
#if !defined (HAVE_VPRINTF) && defined (HAVE_DOPRNT)
# define USE_VFPRINTF_EMULATION
# define HAVE_VPRINTF
#endif
#if defined (HAVE_SYS_RESOURCE_H) && defined (HAVE_GETRLIMIT)
# define HAVE_RESOURCE
#endif
#if !defined (GETPGRP_VOID)
# define HAVE_BSD_PGRP
#endif
/* Try this without testing __STDC__ for the time being. */
#if defined (HAVE_STDARG_H)
# define PREFER_STDARG
# define USE_VARARGS
#else
# if defined (HAVE_VARARGS_H)
# define PREFER_VARARGS
# define USE_VARARGS
# endif
#endif
#if defined (HAVE_SYS_SOCKET_H) && defined (HAVE_GETPEERNAME) && defined (HAVE_NETINET_IN_H)
# define HAVE_NETWORK
#endif
#if defined (HAVE_REGEX_H) && defined (HAVE_REGCOMP) && defined (HAVE_REGEXEC)
# define HAVE_POSIX_REGEXP
#endif
/* backwards compatibility between different autoconf versions */
#if defined (HAVE_DECL_SYS_SIGLIST) && !defined (SYS_SIGLIST_DECLARED)
# define SYS_SIGLIST_DECLARED
#endif
/***********************************************************************/
/* Unset defines based on what configure reports as missing or broken. */
/***********************************************************************/
/* Ultrix botches type-ahead when switching from canonical to
non-canonical mode, at least through version 4.3 */
#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix)
# define TERMIOS_MISSING
#endif
/* If we have a getcwd(3), but it calls popen(), #undef HAVE_GETCWD so
the replacement in getcwd.c will be built. */
#if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN)
# undef HAVE_GETCWD
#endif
#if !defined (HAVE_DEV_FD) && defined (NAMED_PIPES_MISSING)
# undef PROCESS_SUBSTITUTION
#endif
#if defined (JOB_CONTROL_MISSING)
# undef JOB_CONTROL
#endif
#if defined (STRCOLL_BROKEN)
# undef HAVE_STRCOLL
#endif
#if !defined (HAVE_POSIX_REGEXP)
# undef COND_REGEXP
#endif
/* If the shell is called by this name, it will become restricted. */
#if defined (RESTRICTED_SHELL)
# define RESTRICTED_SHELL_NAME "rbash"
#endif
/***********************************************************/
/* Make sure feature defines have necessary prerequisites. */
/***********************************************************/
/* BANG_HISTORY requires HISTORY. */
#if defined (BANG_HISTORY) && !defined (HISTORY)
# define HISTORY
#endif /* BANG_HISTORY && !HISTORY */
#if defined (READLINE) && !defined (HISTORY)
# define HISTORY
#endif
#if defined (PROGRAMMABLE_COMPLETION) && !defined (READLINE)
# undef PROGRAMMABLE_COMPLETION
#endif
#if !defined (V9_ECHO)
# undef DEFAULT_ECHO_TO_XPG
#endif
#if !defined (PROMPT_STRING_DECODE)
# undef PPROMPT
# define PPROMPT "$ "
#endif
/************************************************/
/* check multibyte capability for I18N code */
/************************************************/
/* For platforms which support the ISO C amendement 1 functionality we
support user defined character classes. */
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
# include <wchar.h>
# include <wctype.h>
# if defined (HAVE_MBSRTOWCS) && defined (HAVE_MBRTOWC) && defined (HAVE_MBRLEN) && defined (HAVE_WCWIDTH)
/* system is supposed to support XPG5 */
# define HANDLE_MULTIBYTE 1
# endif
#endif
/* If we don't want multibyte chars even on a system that supports them, let
the configuring user turn multibyte support off. */
#if defined (NO_MULTIBYTE_SUPPORT)
# undef HANDLE_MULTIBYTE
#endif
/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T)
# define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0)
# define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0)
# define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0)
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
# define mbrlen(s, n, ps) (mbrlen) (s, n, 0)
# define mbstate_t int
#endif
/* Make sure MB_LEN_MAX is at least 16 (some systems define
MB_LEN_MAX as 1) */
#ifdef HANDLE_MULTIBYTE
# include <limits.h>
# if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16)
# undef MB_LEN_MAX
# endif
# if !defined (MB_LEN_MAX)
# define MB_LEN_MAX 16
# endif
#endif
/************************************************/
/* end of multibyte capability checks for I18N */
/************************************************/
/******************************************************************/
/* Placeholder for builders to #undef any unwanted features from */
/* config-top.h or created by configure (such as the default mail */
/* file for mail checking). */
/******************************************************************/
/* If you don't want bash to provide a default mail file to check. */
/* #undef DEFAULT_MAIL_DIRECTORY */
+2 -2
View File
@@ -1,6 +1,6 @@
/* config.h -- Configuration file for bash. */
/* 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.
@@ -935,7 +935,7 @@
#undef HAVE_DCGETTEXT
/* Define if your system has a working `malloc' function. */
#define HAVE_MALLOC
#undef HAVE_MALLOC
/* Define if you have the `mempcpy' function. */
#undef HAVE_MEMPCPY
+974
View File
@@ -0,0 +1,974 @@
/* config.h -- Configuration file for bash. */
/* Copyright (C) 1987-2003 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _CONFIG_H_
#define _CONFIG_H_
/* Configuration feature settings controllable by autoconf. */
/* Define JOB_CONTROL if your operating system supports
BSD-like job control. */
#undef JOB_CONTROL
/* Define ALIAS if you want the alias features. */
#undef ALIAS
/* Define PUSHD_AND_POPD if you want those commands to be compiled in.
(Also the `dirs' commands.) */
#undef PUSHD_AND_POPD
/* Define BRACE_EXPANSION if you want curly brace expansion a la Csh:
foo{a,b} -> fooa foob. Even if this is compiled in (the default) you
can turn it off at shell startup with `-nobraceexpansion', or during
shell execution with `set +o braceexpand'. */
#undef BRACE_EXPANSION
/* Define READLINE to get the nifty/glitzy editing features.
This is on by default. You can turn it off interactively
with the -nolineediting flag. */
#undef READLINE
/* Define BANG_HISTORY if you want to have Csh style "!" history expansion.
This is unrelated to READLINE. */
#undef BANG_HISTORY
/* Define HISTORY if you want to have access to previously typed commands.
If both HISTORY and READLINE are defined, you can get at the commands
with line editing commands, and you can directly manipulate the history
from the command line.
If only HISTORY is defined, the `fc' and `history' builtins are
available. */
#undef HISTORY
/* Define this if you want completion that puts all alternatives into
a brace expansion shell expression. */
#if defined (BRACE_EXPANSION) && defined (READLINE)
# define BRACE_COMPLETION
#endif /* BRACE_EXPANSION */
/* Define DEFAULT_ECHO_TO_XPG if you want the echo builtin to interpret
the backslash-escape characters by default, like the XPG Single Unix
Specification V2 for echo.
This requires that V9_ECHO be defined. */
#undef DEFAULT_ECHO_TO_XPG
/* Define HELP_BUILTIN if you want the `help' shell builtin and the long
documentation strings compiled into the shell. */
#undef HELP_BUILTIN
/* Define RESTRICTED_SHELL if you want the generated shell to have the
ability to be a restricted one. The shell thus generated can become
restricted by being run with the name "rbash", or by setting the -r
flag. */
#undef RESTRICTED_SHELL
/* Define DISABLED_BUILTINS if you want "builtin foo" to always run the
shell builtin "foo", even if it has been disabled with "enable -n foo". */
#undef DISABLED_BUILTINS
/* Define PROCESS_SUBSTITUTION if you want the K*rn shell-like process
substitution features "<(file)". */
/* Right now, you cannot do this on machines without fully operational
FIFO support. This currently include NeXT and Alliant. */
#undef PROCESS_SUBSTITUTION
/* Define PROMPT_STRING_DECODE if you want the backslash-escaped special
characters in PS1 and PS2 expanded. Variable expansion will still be
performed. */
#undef PROMPT_STRING_DECODE
/* Define SELECT_COMMAND if you want the Korn-shell style `select' command:
select word in word_list; do command_list; done */
#undef SELECT_COMMAND
/* Define COMMAND_TIMING of you want the ksh-style `time' reserved word and
the ability to time pipelines, functions, and builtins. */
#undef COMMAND_TIMING
/* Define ARRAY_VARS if you want ksh-style one-dimensional array variables. */
#undef ARRAY_VARS
/* Define DPAREN_ARITHMETIC if you want the ksh-style ((...)) arithmetic
evaluation command. */
#undef DPAREN_ARITHMETIC
/* Define EXTENDED_GLOB if you want the ksh-style [*+@?!](patlist) extended
pattern matching. */
#undef EXTENDED_GLOB
/* Define COND_COMMAND if you want the ksh-style [[...]] conditional
command. */
#undef COND_COMMAND
/* Define COND_REGEXP if you want extended regular expression matching and the
=~ binary operator in the [[...]] conditional command. */
#define COND_REGEXP
/* Define ARITH_FOR_COMMAND if you want the ksh93-style
for (( init; test; step )) do list; done
arithmetic for command. */
#undef ARITH_FOR_COMMAND
/* Define NETWORK_REDIRECTIONS if you want /dev/(tcp|udp)/host/port to open
socket connections when used in redirections */
#undef NETWORK_REDIRECTIONS
/* Define PROGRAMMABLE_COMPLETION for the programmable completion features
and the complete builtin. */
#undef PROGRAMMABLE_COMPLETION
/* Define NO_MULTIBYTE_SUPPORT to not compile in support for multibyte
characters, even if the OS supports them. */
#undef NO_MULTIBYTE_SUPPORT
/* Define DEBUGGER if you want to compile in some features used only by the
bash debugger. */
#undef DEBUGGER
/* Define MEMSCRAMBLE if you want the bash malloc and free to scramble
memory contents on malloc() and free(). */
#undef MEMSCRAMBLE
/* Define AFS if you are using Transarc's AFS. */
#undef AFS
#undef ENABLE_NLS
/* End of configuration settings controllable by autoconf. */
/* Other settable options appear in config-top.h. */
#include "config-top.h"
/* Beginning of autoconf additions. */
/* Characteristics of the C compiler */
#undef const
#undef inline
/* Define if cpp supports the ANSI-C stringizing `#' operator */
#undef HAVE_STRINGIZE
/* Define if the compiler supports `long double' variables. */
#undef HAVE_LONG_DOUBLE
#undef PROTOTYPES
#undef __CHAR_UNSIGNED__
/* Define if the compiler supports `long long' variables. */
#undef HAVE_LONG_LONG
#undef HAVE_UNSIGNED_LONG_LONG
/* The number of bytes in a int. */
#undef SIZEOF_INT
/* The number of bytes in a long. */
#undef SIZEOF_LONG
/* The number of bytes in a pointer to char. */
#undef SIZEOF_CHAR_P
/* The number of bytes in a double (hopefully 8). */
#undef SIZEOF_DOUBLE
/* The number of bytes in a `long long', if we have one. */
#undef SIZEOF_LONG_LONG
/* System paths */
#define DEFAULT_MAIL_DIRECTORY "/usr/spool/mail"
/* Characteristics of the system's header files and libraries that affect
the compilation environment. */
/* Define if the system does not provide POSIX.1 features except
with this defined. */
#undef _POSIX_1_SOURCE
/* Define if you need to in order for stat and other things to work. */
#undef _POSIX_SOURCE
/* Define to use GNU libc extensions */
#undef _GNU_SOURCE
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Memory management functions. */
/* Define if using the bash version of malloc in lib/malloc/malloc.c */
#undef USING_BASH_MALLOC
#undef DISABLE_MALLOC_WRAPPERS
/* Define if using alloca.c. */
#undef C_ALLOCA
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
#undef CRAY_STACKSEG_END
/* Define if you have alloca, as a function or macro. */
#undef HAVE_ALLOCA
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
#undef HAVE_ALLOCA_H
/* SYSTEM TYPES */
/* Define to `long' if <sys/types.h> doesn't define. */
#undef off_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef mode_t
/* Define to `int' if <signal.h> doesn't define. */
#undef sigset_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef pid_t
/* Define to `short' if <sys/types.h> doesn't define. */
#undef bits16_t
/* Define to `unsigned short' if <sys/types.h> doesn't define. */
#undef u_bits16_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef bits32_t
/* Define to `unsigned int' if <sys/types.h> doesn't define. */
#undef u_bits32_t
/* Define to `double' if <sys/types.h> doesn't define. */
#undef bits64_t
/* Define to `unsigned int' if <sys/types.h> doesn't define. */
#undef u_int
/* Define to `unsigned long' if <sys/types.h> doesn't define. */
#undef u_long
/* Define to `int' if <sys/types.h> doesn't define. */
#undef ptrdiff_t
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef ssize_t
/* Define to `long' if <stdint.h> doesn't define. */
#undef intmax_t
/* Define to `unsigned long' if <stdint.h> doesn't define. */
#undef uintmax_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
/* Define to `long' if <sys/types.h> doesn't define. */
#undef clock_t
/* Define to `long' if <sys/types.h> doesn't define. */
#undef time_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t
/* Define to `unsigned int' if <sys/socket.h> doesn't define. */
#undef socklen_t
/* Define if you have quad_t in <sys/types.h>. */
#undef HAVE_QUAD_T
#undef RLIMTYPE
/* Define to the type of elements in the array set by `getgroups'.
Usually this is either `int' or `gid_t'. */
#undef GETGROUPS_T
/* Characteristics of the machine archictecture. */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
#undef STACK_DIRECTION
/* Define if the machine architecture is big-endian. */
#undef WORDS_BIGENDIAN
/* Check for the presence of certain non-function symbols in the system
libraries. */
/* Define if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
#undef HAVE_DECL_SYS_SIGLIST
#undef SYS_SIGLIST_DECLARED
/* Define if `_sys_siglist' is declared by <signal.h> or <unistd.h>. */
#undef UNDER_SYS_SIGLIST_DECLARED
#undef HAVE_SYS_SIGLIST
#undef HAVE_UNDER_SYS_SIGLIST
#undef HAVE_SYS_ERRLIST
#undef HAVE_TZNAME
/* Characteristics of some of the system structures. */
#undef STRUCT_DIRENT_HAS_D_INO
#undef STRUCT_DIRENT_HAS_D_FILENO
#undef TIOCSTAT_IN_SYS_IOCTL
#undef FIONREAD_IN_SYS_IOCTL
#undef GWINSZ_IN_SYS_IOCTL
#undef STRUCT_WINSIZE_IN_SYS_IOCTL
#undef TM_IN_SYS_TIME
#undef STRUCT_WINSIZE_IN_TERMIOS
#undef SPEED_T_IN_SYS_TYPES
#undef TERMIOS_LDISC
#undef TERMIO_LDISC
#undef HAVE_STRUCT_STAT_ST_BLOCKS
#undef HAVE_STRUCT_TM_TM_ZONE
#undef HAVE_TM_ZONE
#undef HAVE_TIMEVAL
#undef HAVE_STRUCT_TIMEZONE
/* Characteristics of definitions in the system header files. */
#undef HAVE_GETPW_DECLS
#undef HAVE_RESOURCE
#undef HAVE_LIBC_FNM_EXTMATCH
#undef HAVE_DECL_CONFSTR
#undef HAVE_DECL_PRINTF
#undef HAVE_DECL_SBRK
#undef HAVE_DECL_STRCPY
#undef HAVE_DECL_STRSIGNAL
#undef HAVE_DECL_STRTOLD
#undef STRTOLD_BROKEN
#undef HAVE_MBSTATE_T
/* These are checked with BASH_CHECK_DECL */
#undef HAVE_DECL_STRTOIMAX
#undef HAVE_DECL_STRTOL
#undef HAVE_DECL_STRTOLL
#undef HAVE_DECL_STRTOUL
#undef HAVE_DECL_STRTOULL
#undef HAVE_DECL_STRTOUMAX
/* Characteristics of system calls and C library functions. */
/* Define if the `getpgrp' function takes no argument. */
#undef GETPGRP_VOID
#undef NAMED_PIPES_MISSING
#undef OPENDIR_NOT_ROBUST
#undef PGRP_PIPE
/* Define if the setvbuf function takes the buffering type as its second
argument and the buffer pointer as the third, as on System V
before release 3. */
#undef SETVBUF_REVERSED
#undef STAT_MACROS_BROKEN
#undef ULIMIT_MAXFDS
#undef CAN_REDEFINE_GETENV
#undef HAVE_STD_PUTENV
#undef HAVE_STD_UNSETENV
#undef HAVE_PRINTF_A_FORMAT
#undef CTYPE_NON_ASCII
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
/* Characteristics of properties exported by the kernel. */
/* Define if the kernel can exec files beginning with #! */
#undef HAVE_HASH_BANG_EXEC
/* Define if you have the /dev/fd devices to map open files into the file system. */
#undef HAVE_DEV_FD
/* Defined to /dev/fd or /proc/self/fd (linux). */
#undef DEV_FD_PREFIX
/* Define if you have the /dev/stdin device. */
#undef HAVE_DEV_STDIN
/* Type and behavior of signal handling functions. */
/* Define as the return type of signal handlers (int or void). */
#undef RETSIGTYPE
/* Define if return type of signal handlers is void */
#undef VOID_SIGHANDLER
#undef MUST_REINSTALL_SIGHANDLERS
#undef HAVE_BSD_SIGNALS
#undef HAVE_POSIX_SIGNALS
#undef HAVE_USG_SIGHOLD
#undef UNUSABLE_RT_SIGNALS
/* Presence of system and C library functions. */
/* Define if you have the asprintf function. */
#undef HAVE_ASPRINTF
/* Define if you have the bcopy function. */
#undef HAVE_BCOPY
/* Define if you have the bzero function. */
#undef HAVE_BZERO
/* Define if you have the confstr function. */
#undef HAVE_CONFSTR
/* Define if you have the dlclose function. */
#undef HAVE_DLCLOSE
/* Define if you have the dlopen function. */
#undef HAVE_DLOPEN
/* Define if you have the dlsym function. */
#undef HAVE_DLSYM
/* Define if you don't have vprintf but do have _doprnt. */
#undef HAVE_DOPRNT
/* Define if you have the dup2 function. */
#undef HAVE_DUP2
/* Define if you have the getaddrinfo function. */
#undef HAVE_GETADDRINFO
/* Define if you have the getcwd function. */
#undef HAVE_GETCWD
/* Define if you have the getdtablesize function. */
#undef HAVE_GETDTABLESIZE
/* Define if you have the getgroups function. */
#undef HAVE_GETGROUPS
/* Define if you have the gethostbyname function. */
#undef HAVE_GETHOSTBYNAME
/* Define if you have the gethostname function. */
#undef HAVE_GETHOSTNAME
/* Define if you have the getpagesize function. */
#undef HAVE_GETPAGESIZE
/* Define if you have the getpeername function. */
#undef HAVE_GETPEERNAME
/* Define if you have the getrlimit function. */
#undef HAVE_GETRLIMIT
/* Define if you have the getrusage function. */
#undef HAVE_GETRUSAGE
/* Define if you have the getservbyname function. */
#undef HAVE_GETSERVBYNAME
/* Define if you have the getservent function. */
#undef HAVE_GETSERVENT
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
/* Define if you have the getwd function. */
#undef HAVE_GETWD
/* Define if you have the inet_aton function. */
#undef HAVE_INET_ATON
/* Define if you have the isascii function. */
#undef HAVE_ISASCII
/* Define if you have the isblank function. */
#undef HAVE_ISBLANK
/* Define if you have the isgraph function. */
#undef HAVE_ISGRAPH
/* Define if you have the isint function in libc */
#undef HAVE_ISINF_IN_LIBC
/* Define if you have the isprint function. */
#undef HAVE_ISPRINT
/* Define if you have the isspace function. */
#undef HAVE_ISSPACE
/* Define if you have the isxdigit function. */
#undef HAVE_ISXDIGIT
/* Define if you have the killpg function. */
#undef HAVE_KILLPG
/* Define if you have the lstat function. */
#undef HAVE_LSTAT
/* Define if you have the mbrlen function. */
#undef HAVE_MBRLEN
/* Define if you have the mbrtowc function. */
#undef HAVE_MBRTOWC
/* Define if you have the mbsrtowcs function. */
#undef HAVE_MBSRTOWCS
/* Define if you have the memmove function. */
#undef HAVE_MEMMOVE
/* Define if you have the memset function. */
#undef HAVE_MEMSET
/* Define if you have the mkfifo function. */
#undef HAVE_MKFIFO
/* Define if you have the pathconf function. */
#undef HAVE_PATHCONF
/* Define if you have the putenv function. */
#undef HAVE_PUTENV
/* Define if you have the readlink function. */
#undef HAVE_READLINK
/* Define if you have the regcomp function. */
#undef HAVE_REGCOMP
/* Define if you have the regexec function. */
#undef HAVE_REGEXEC
/* Define if you have the rename function. */
#undef HAVE_RENAME
/* Define if you have the sbrk function. */
#undef HAVE_SBRK
/* Define if you have the select function. */
#undef HAVE_SELECT
/* Define if you have the setdtablesize function. */
#undef HAVE_SETDTABLESIZE
/* Define if you have the setenv function. */
#undef HAVE_SETENV
/* Define if you have the setlinebuf function. */
#undef HAVE_SETLINEBUF
/* Define if you have the setlocale function. */
#undef HAVE_SETLOCALE
/* Define if you have the setostype function. */
#undef HAVE_SETOSTYPE
/* Define if you have the setvbuf function. */
#undef HAVE_SETVBUF
/* Define if you have the siginterrupt function. */
#undef HAVE_SIGINTERRUPT
/* Define if you have the POSIX.1-style sigsetjmp function. */
#undef HAVE_POSIX_SIGSETJMP
/* Define if you have the snprintf function. */
#undef HAVE_SNPRINTF
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strchr function. */
#undef HAVE_STRCHR
/* Define if you have the strcoll function. */
#undef HAVE_STRCOLL
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
/* Define if you have the strftime function. */
#undef HAVE_STRFTIME
/* Define if you have the strpbrk function. */
#undef HAVE_STRPBRK
/* Define if you have the strstr function. */
#undef HAVE_STRSTR
/* Define if you have the strtod function. */
#undef HAVE_STRTOD
/* Define if you have the strtoimax function. */
#undef HAVE_STRTOIMAX
/* Define if you have the strtol function. */
#undef HAVE_STRTOL
/* Define if you have the strtoll function. */
#undef HAVE_STRTOLL
/* Define if you have the strtoul function. */
#undef HAVE_STRTOUL
/* Define if you have the strtoull function. */
#undef HAVE_STRTOULL
/* Define if you have the strtoumax function. */
#undef HAVE_STRTOUMAX
/* Define if you have the strsignal function or macro. */
#undef HAVE_STRSIGNAL
/* Define if you have the sysconf function. */
#undef HAVE_SYSCONF
/* Define if you have the tcgetattr function. */
#undef HAVE_TCGETATTR
/* Define if you have the tcgetpgrp function. */
#undef HAVE_TCGETPGRP
/* Define if you have the times function. */
#undef HAVE_TIMES
/* Define if you have the ttyname function. */
#undef HAVE_TTYNAME
/* Define if you have the tzset function. */
#undef HAVE_TZSET
/* Define if you have the ulimit function. */
#undef HAVE_ULIMIT
/* Define if you have the uname function. */
#undef HAVE_UNAME
/* Define if you have the unsetenv function. */
#undef HAVE_UNSETENV
/* Define if you have the vasprintf function. */
#undef HAVE_VASPRINTF
/* Define if you have the vprintf function. */
#undef HAVE_VPRINTF
/* Define if you have the vsnprintf function. */
#undef HAVE_VSNPRINTF
/* Define if you have the waitpid function. */
#undef HAVE_WAITPID
/* Define if you have the wait3 function. */
#undef HAVE_WAIT3
/* Define if you have the wcsdup function. */
#undef HAVE_WCSDUP
/* Define if you have the wctomb function. */
#undef HAVE_WCTOMB
/* Define if you have the wcwidth function. */
#undef HAVE_WCWIDTH
/* Presence of certain system include files. */
/* Define if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Define if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
/* Define if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define if you have the <grp.h> header file. */
#undef HAVE_GRP_H
/* Define if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define if you have the <ndir.h> header file. */
#undef HAVE_NDIR_H
/* Define if you have the <netdh.h> header file. */
#undef HAVE_NETDB_H
/* Define if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define if you have the <regex.h> header file. */
#undef HAVE_REGEX_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define if you have the <sys/dir.h> header file. */
#undef HAVE_SYS_DIR_H
/* Define if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
/* Define if you have the <sys/ndir.h> header file. */
#undef HAVE_SYS_NDIR_H
/* Define if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define if you have the <sys/pte.h> header file. */
#undef HAVE_SYS_PTE_H
/* Define if you have the <sys/ptem.h> header file. */
#undef HAVE_SYS_PTEM_H
/* Define if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define if you have the <sys/stream.h> header file. */
#undef HAVE_SYS_STREAM_H
/* Define if you have <sys/time.h> */
#undef HAVE_SYS_TIME_H
#undef TIME_WITH_SYS_TIME
/* Define if you have <sys/times.h> */
#undef HAVE_SYS_TIMES_H
/* Define if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define if you have the <termcap.h> header file. */
#undef HAVE_TERMCAP_H
/* Define if you have the <termio.h> header file. */
#undef HAVE_TERMIO_H
/* Define if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the <varargs.h> header file. */
#undef HAVE_VARARGS_H
/* Define if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Define if you have the <varargs.h> header file. */
#undef HAVE_WCTYPE_H
/* Presence of certain system libraries. */
#undef HAVE_LIBDL
#undef HAVE_LIBSUN
#undef HAVE_LIBSOCKET
/* Define if on MINIX. */
#undef _MINIX
/* Are we running SVR5 (UnixWare 7)? */
#undef SVR5
/* Are we running SVR4.2? */
#undef SVR4_2
/* Are we running some version of SVR4? */
#undef SVR4
/* Define if job control is unusable or unsupported. */
#undef JOB_CONTROL_MISSING
/* Do we need to define _KERNEL to get the RLIMIT_* defines from
<sys/resource.h>? */
#undef RLIMIT_NEEDS_KERNEL
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files on AIX-style hosts. */
#undef _LARGE_FILES
/* Do strcoll(3) and strcmp(3) give different results in the default locale? */
#undef STRCOLL_BROKEN
#undef DUP2_BROKEN
#undef GETCWD_BROKEN
/* Additional defines for configuring lib/intl, maintained by autoscan/autoheader */
/* Define if you have the <argz.h> header file. */
#undef HAVE_ARGZ_H
/* Define if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define if you have the <stdio_ext.h> header file. */
#undef HAVE_STDIO_EXT_H
/* Define if you have the `dcgettext' function. */
#undef HAVE_DCGETTEXT
/* Define if your system has a working `malloc' function. */
#undef HAVE_MALLOC
/* Define if you have the `mempcpy' function. */
#undef HAVE_MEMPCPY
/* Define if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define if you have the `munmap' function. */
#undef HAVE_MUNMAP
/* Define if you have the `nl_langinfo' function. */
#undef HAVE_NL_LANGINFO
/* Define if you have the `stpcpy' function. */
#undef HAVE_STPCPY
/* Define if you have the `strcspn' function. */
#undef HAVE_STRCSPN
/* Define if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define if you have the `__argz_count' function. */
#undef HAVE___ARGZ_COUNT
/* Define if you have the `__argz_next' function. */
#undef HAVE___ARGZ_NEXT
/* Define if you have the `__argz_stringify' function. */
#undef HAVE___ARGZ_STRINGIFY
/* End additions for lib/intl */
#include "config-bot.h"
#endif /* _CONFIG_H_ */
+45 -14
View File
@@ -808,6 +808,7 @@ exp0 ()
register intmax_t val = 0, v2;
char *vincdec;
int stok;
EXPR_CONTEXT ec;
/* XXX - might need additional logic here to decide whether or not
pre-increment or pre-decrement is legal at this point. */
@@ -853,17 +854,36 @@ exp0 ()
else if ((curtok == NUM) || (curtok == STR))
{
val = tokval;
if (curtok == STR && (*tp == '+' || *tp == '-') && tp[1] == *tp &&
(tp[2] == '\0' || (ISALNUM ((unsigned char)tp[2]) == 0)))
if (curtok == STR)
{
SAVETOK (&ec);
tokstr = (char *)NULL; /* keep it from being freed */
noeval = 1;
readtok ();
stok = curtok;
/* post-increment or post-decrement */
v2 = val + ((*tp == '+') ? 1 : -1);
vincdec = itos (v2);
if (noeval == 0)
expr_bind_variable (tokstr, vincdec);
free (vincdec);
tp += 2;
curtok = NUM; /* make sure x++=7 is flagged as an error */
if (stok == POSTINC || stok == POSTDEC)
{
/* restore certain portions of EC */
tokstr = ec.tokstr;
noeval = ec.noeval;
lasttok = STR; /* ec.curtok */
v2 = val + ((stok == POSTINC) ? 1 : -1);
vincdec = itos (v2);
if (noeval == 0)
expr_bind_variable (tokstr, vincdec);
free (vincdec);
curtok = NUM; /* make sure x++=7 is flagged as an error */
}
else
{
if (stok == STR) /* free new tokstr before old one is restored */
FREE (tokstr);
RESTORETOK (&ec);
}
}
readtok ();
@@ -936,7 +956,7 @@ expr_streval (tok, e)
static void
readtok ()
{
register char *cp;
register char *cp, *xp;
register unsigned char c, c1;
register int e;
@@ -995,6 +1015,7 @@ readtok ()
tokstr = (char *)NULL; /* keep it from being freed */
tp = savecp = cp;
noeval = 1;
curtok = STR;
readtok ();
peektok = curtok;
if (peektok == STR) /* free new tokstr before old one is restored */
@@ -1064,10 +1085,20 @@ readtok ()
c = LOR;
else if ((c == '*') && (c1 == '*'))
c = POWER;
else if ((c == '-') && (c1 == '-') && legal_variable_starter ((unsigned char)*cp))
c = PREDEC;
else if ((c == '+') && (c1 == '+') && legal_variable_starter ((unsigned char)*cp))
c = PREINC;
else if ((c == '-' || c == '+') && c1 == c && curtok == STR)
c = (c == '-') ? POSTDEC : POSTINC;
else if ((c == '-' || c == '+') && c1 == c)
{
/* Quickly scan forward to see if this is followed by optional
whitespace and an identifier. */
xp = cp;
while (xp && *xp && cr_whitespace (*xp))
xp++;
if (legal_variable_starter ((unsigned char)*xp))
c = (c == '-') ? PREDEC : PREINC;
else
cp--; /* not preinc or predec, so unget the character */
}
else if (c1 == EQ && member (c, "*/%+-&^|"))
{
assigntok = c; /* a OP= b */
+1243
View File
File diff suppressed because it is too large Load Diff
+1268
View File
File diff suppressed because it is too large Load Diff
+6 -2
View File
@@ -506,7 +506,7 @@ rl_redisplay ()
}
}
pmtlen = strlen (prompt_this_line);
prompt_physical_chars = pmtlen = strlen (prompt_this_line);
temp = pmtlen + out + 2;
if (temp >= line_size)
{
@@ -1841,6 +1841,7 @@ static char *saved_local_prefix;
static int saved_last_invisible;
static int saved_visible_length;
static int saved_invis_chars_first_line;
static int saved_physical_chars;
void
rl_save_prompt ()
@@ -1850,10 +1851,11 @@ rl_save_prompt ()
saved_last_invisible = prompt_last_invisible;
saved_visible_length = prompt_visible_length;
saved_invis_chars_first_line = prompt_invis_chars_first_line;
saved_physical_chars = prompt_physical_chars;
local_prompt = local_prompt_prefix = (char *)0;
prompt_last_invisible = prompt_visible_length = 0;
prompt_invis_chars_first_line = 0;
prompt_invis_chars_first_line = prompt_physical_chars = 0;
}
void
@@ -1867,6 +1869,7 @@ rl_restore_prompt ()
prompt_last_invisible = saved_last_invisible;
prompt_visible_length = saved_visible_length;
prompt_invis_chars_first_line = saved_invis_chars_first_line;
prompt_physical_chars = saved_physical_chars;
}
char *
@@ -1899,6 +1902,7 @@ _rl_make_prompt_for_search (pchar)
prompt_last_invisible = saved_last_invisible;
prompt_visible_length = saved_visible_length + 1;
}
return pmt;
}
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -1,6 +1,6 @@
/* histexpand.c -- history expansion. */
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
/* Copyright (C) 1989-2004 Free Software Foundation, Inc.
This file contains the GNU History Library (the Library), a set of
routines for managing the text of previously typed lines.
@@ -1220,7 +1220,9 @@ history_expand (hstring, output)
if (only_printing)
{
#if 0
add_history (result);
#endif
return (2);
}
File diff suppressed because it is too large Load Diff
+4 -2
View File
@@ -1,6 +1,6 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2002 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.
@@ -253,7 +253,9 @@ rl_maybe_unsave_line ()
{
if (_rl_saved_line_for_history)
{
rl_replace_line (_rl_saved_line_for_history->line, 1);
/* Can't call with `1' because rl_undo_list might point to an undo
list from a history entry, as in rl_replace_from_history() below. */
rl_replace_line (_rl_saved_line_for_history->line, 0);
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
+500
View File
@@ -0,0 +1,500 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_LOCALE_H)
# include <locale.h>
#endif
#include <stdio.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
static int rl_digit_loop PARAMS((void));
static void _rl_history_set_point PARAMS((void));
/* Forward declarations used in this file */
void _rl_free_history_entry PARAMS((HIST_ENTRY *));
/* If non-zero, rl_get_previous_history and rl_get_next_history attempt
to preserve the value of rl_point from line to line. */
int _rl_history_preserve_point = 0;
/* Saved target point for when _rl_history_preserve_point is set. Special
value of -1 means that point is at the end of the line. */
int _rl_history_saved_point = -1;
/* **************************************************************** */
/* */
/* Numeric Arguments */
/* */
/* **************************************************************** */
/* Handle C-u style numeric args, as well as M--, and M-digits. */
static int
rl_digit_loop ()
{
int key, c, sawminus, sawdigits;
rl_save_prompt ();
RL_SETSTATE(RL_STATE_NUMERICARG);
sawminus = sawdigits = 0;
while (1)
{
if (rl_numeric_arg > 1000000)
{
sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
rl_ding ();
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return 1;
}
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
RL_SETSTATE(RL_STATE_MOREINPUT);
key = c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (c < 0)
{
_rl_abort_internal ();
return -1;
}
/* If we see a key bound to `universal-argument' after seeing digits,
it ends the argument but is otherwise ignored. */
if (_rl_keymap[c].type == ISFUNC &&
_rl_keymap[c].function == rl_universal_argument)
{
if (sawdigits == 0)
{
rl_numeric_arg *= 4;
continue;
}
else
{
RL_SETSTATE(RL_STATE_MOREINPUT);
key = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
c = UNMETA (c);
if (_rl_digit_p (c))
{
rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0';
sawdigits = rl_explicit_arg = 1;
}
else if (c == '-' && rl_explicit_arg == 0)
{
rl_numeric_arg = sawminus = 1;
rl_arg_sign = -1;
}
else
{
/* Make M-- command equivalent to M--1 command. */
if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
rl_explicit_arg = 1;
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
/*NOTREACHED*/
}
/* Add the current digit to the argument in progress. */
int
rl_digit_argument (ignore, key)
int ignore, key;
{
rl_execute_next (key);
return (rl_digit_loop ());
}
/* What to do when you abort reading an argument. */
int
rl_discard_argument ()
{
rl_ding ();
rl_clear_message ();
_rl_init_argument ();
return 0;
}
/* Create a default argument. */
int
_rl_init_argument ()
{
rl_numeric_arg = rl_arg_sign = 1;
rl_explicit_arg = 0;
return 0;
}
/* C-u, universal argument. Multiply the current argument by 4.
Read a key. If the key has nothing to do with arguments, then
dispatch on it. If the key is the abort character then abort. */
int
rl_universal_argument (count, key)
int count, key;
{
rl_numeric_arg *= 4;
return (rl_digit_loop ());
}
/* **************************************************************** */
/* */
/* History Utilities */
/* */
/* **************************************************************** */
/* We already have a history library, and that is what we use to control
the history features of readline. This is our local interface to
the history mechanism. */
/* While we are editing the history, this is the saved
version of the original line. */
HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
/* Set the history pointer back to the last entry in the history. */
void
_rl_start_using_history ()
{
using_history ();
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Free the contents (and containing structure) of a HIST_ENTRY. */
void
_rl_free_history_entry (entry)
HIST_ENTRY *entry;
{
if (entry == 0)
return;
if (entry->line)
free (entry->line);
free (entry);
}
/* Perhaps put back the current line if it has changed. */
int
rl_maybe_replace_line ()
{
HIST_ENTRY *temp;
temp = current_history ();
/* If the current line has changed, save the changes. */
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
{
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
free (temp->line);
free (temp);
}
return 0;
}
/* Restore the _rl_saved_line_for_history if there is one. */
int
rl_maybe_unsave_line ()
{
if (_rl_saved_line_for_history)
{
/* Can't call with `1' because rl_undo_list might point to an undo
list from a history entry, as in rl_replace_from_history() below. */
rl_replace_line (_rl_saved_line_for_history->line, 0);
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
rl_point = rl_end; /* rl_replace_line sets rl_end */
}
else
rl_ding ();
return 0;
}
/* Save the current line in _rl_saved_line_for_history. */
int
rl_maybe_save_line ()
{
if (_rl_saved_line_for_history == 0)
{
_rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
_rl_saved_line_for_history->line = savestring (rl_line_buffer);
_rl_saved_line_for_history->data = (char *)rl_undo_list;
}
return 0;
}
int
_rl_free_saved_history_line ()
{
if (_rl_saved_line_for_history)
{
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
return 0;
}
static void
_rl_history_set_point ()
{
rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1)
? _rl_history_saved_point
: rl_end;
if (rl_point > rl_end)
rl_point = rl_end;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode && _rl_keymap != vi_insertion_keymap)
rl_point = 0;
#endif /* VI_MODE */
if (rl_editing_mode == emacs_mode)
rl_mark = (rl_point == rl_end ? 0 : rl_end);
}
void
rl_replace_from_history (entry, flags)
HIST_ENTRY *entry;
int flags; /* currently unused */
{
/* Can't call with `1' because rl_undo_list might point to an undo list
from a history entry, just like we're setting up here. */
rl_replace_line (entry->line, 0);
rl_undo_list = (UNDO_LIST *)entry->data;
rl_point = rl_end;
rl_mark = 0;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
{
rl_point = 0;
rl_mark = rl_end;
}
#endif
}
/* **************************************************************** */
/* */
/* History Commands */
/* */
/* **************************************************************** */
/* Meta-< goes to the start of the history. */
int
rl_beginning_of_history (count, key)
int count, key;
{
return (rl_get_previous_history (1 + where_history (), key));
}
/* Meta-> goes to the end of the history. (The current line). */
int
rl_end_of_history (count, key)
int count, key;
{
rl_maybe_replace_line ();
using_history ();
rl_maybe_unsave_line ();
return 0;
}
/* Move down to the next history line. */
int
rl_get_next_history (count, key)
int count, key;
{
HIST_ENTRY *temp;
if (count < 0)
return (rl_get_previous_history (-count, key));
if (count == 0)
return 0;
rl_maybe_replace_line ();
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = next_history ();
if (!temp)
break;
--count;
}
if (temp == 0)
rl_maybe_unsave_line ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* Get the previous item out of our interactive history, making it the current
line. If there is no previous history, just ding. */
int
rl_get_previous_history (count, key)
int count, key;
{
HIST_ENTRY *old_temp, *temp;
if (count < 0)
return (rl_get_next_history (-count, key));
if (count == 0)
return 0;
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
/* If we don't have a line saved, then save this one. */
rl_maybe_save_line ();
/* If the current line has changed, save the changes. */
rl_maybe_replace_line ();
temp = old_temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = previous_history ();
if (temp == 0)
break;
old_temp = temp;
--count;
}
/* If there was a large argument, and we moved back to the start of the
history, that is not an error. So use the last value found. */
if (!temp && old_temp)
temp = old_temp;
if (temp == 0)
rl_ding ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* **************************************************************** */
/* */
/* Editing Modes */
/* */
/* **************************************************************** */
/* How to toggle back and forth between editing modes. */
int
rl_vi_editing_mode (count, key)
int count, key;
{
#if defined (VI_MODE)
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
rl_editing_mode = vi_mode;
rl_vi_insertion_mode (1, key);
#endif /* VI_MODE */
return 0;
}
int
rl_emacs_editing_mode (count, key)
int count, key;
{
rl_editing_mode = emacs_mode;
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
_rl_keymap = emacs_standard_keymap;
return 0;
}
/* Function for the rest of the library to use to set insert/overwrite mode. */
void
_rl_set_insert_mode (im, force)
int im, force;
{
#ifdef CURSOR_MODE
_rl_set_cursor (im, force);
#endif
rl_insert_mode = im;
}
/* Toggle overwrite mode. A positive explicit argument selects overwrite
mode. A negative or zero explicit argument selects insert mode. */
int
rl_overwrite_mode (count, key)
int count, key;
{
if (rl_explicit_arg == 0)
_rl_set_insert_mode (rl_insert_mode ^ 1, 0);
else if (count > 0)
_rl_set_insert_mode (RL_IM_OVERWRITE, 0);
else
_rl_set_insert_mode (RL_IM_INSERT, 0);
return 0;
}
+50 -13
View File
@@ -259,7 +259,7 @@ static intmax_t parameter_brace_expand_length __P((char *));
static char *skiparith __P((char *, int));
static int verify_substring_values __P((char *, char *, int, intmax_t *, intmax_t *));
static int get_var_and_type __P((char *, char *, SHELL_VAR **, char **));
static int get_var_and_type __P((char *, char *, int, SHELL_VAR **, char **));
static char *mb_substring __P((char *, int, int));
static char *parameter_brace_substring __P((char *, char *, char *, int));
@@ -3530,7 +3530,7 @@ parameter_brace_remove_pattern (varname, value, patstr, rtype, quoted)
this_command_name = varname;
vtype = get_var_and_type (varname, value, &v, &val);
vtype = get_var_and_type (varname, value, quoted, &v, &val);
if (vtype == -1)
return ((char *)NULL);
@@ -4446,7 +4446,12 @@ parameter_brace_expand_word (name, var_is_special, quoted)
if (legal_number (name, &arg_index))
{
tt = get_dollar_var_value (arg_index);
temp = tt ? quote_escapes (tt) : (char *)NULL;
if (tt)
temp = (*tt && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
? quote_string (tt)
: quote_escapes (tt);
else
temp = (char *)NULL;
FREE (tt);
}
else if (var_is_special) /* ${@} */
@@ -4465,7 +4470,9 @@ parameter_brace_expand_word (name, var_is_special, quoted)
{
temp = array_value (name, quoted, &atype);
if (atype == 0 && temp)
temp = quote_escapes (temp);
temp = (*temp && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
? quote_string (temp)
: quote_escapes (temp);
}
#endif
else if (var = find_variable (name))
@@ -4479,7 +4486,9 @@ parameter_brace_expand_word (name, var_is_special, quoted)
#endif
if (temp)
temp = quote_escapes (temp);
temp = (*temp && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
? quote_string (temp)
: quote_escapes (temp);
}
else
temp = (char *)NULL;
@@ -4501,6 +4510,15 @@ parameter_brace_expand_indir (name, var_is_special, quoted, quoted_dollar_atp, c
char *temp, *t;
t = parameter_brace_expand_word (name, var_is_special, quoted);
/* Have to dequote here if necessary */
if (t)
{
temp = (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
? dequote_string (t)
: dequote_escapes (t);
free (t);
t = temp;
}
chk_atstar (t, quoted, quoted_dollar_atp, contains_dollar_at);
if (t == 0)
return (t);
@@ -4895,8 +4913,9 @@ verify_substring_values (value, substr, vtype, e1p, e2p)
characters in the value are quoted with CTLESC and takes appropriate
steps. For convenience, *VALP is set to the dequoted VALUE. */
static int
get_var_and_type (varname, value, varp, valp)
get_var_and_type (varname, value, quoted, varp, valp)
char *varname, *value;
int quoted;
SHELL_VAR **varp;
char **valp;
{
@@ -4943,7 +4962,21 @@ get_var_and_type (varname, value, varp, valp)
}
else
#endif
#if 1
{
if (value && vtype == VT_VARIABLE)
{
if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
*valp = dequote_string (value);
else
*valp = dequote_escapes (value);
}
else
*valp = value;
}
#else
*valp = (value && vtype == VT_VARIABLE) ? dequote_escapes (value) : value;
#endif
return vtype;
}
@@ -5002,7 +5035,7 @@ parameter_brace_substring (varname, value, substr, quoted)
this_command_name = varname;
vtype = get_var_and_type (varname, value, &v, &val);
vtype = get_var_and_type (varname, value, quoted, &v, &val);
if (vtype == -1)
return ((char *)NULL);
@@ -5201,7 +5234,7 @@ parameter_brace_patsub (varname, value, patsub, quoted)
this_command_name = varname;
vtype = get_var_and_type (varname, value, &v, &val);
vtype = get_var_and_type (varname, value, quoted, &v, &val);
if (vtype == -1)
return ((char *)NULL);
@@ -5738,7 +5771,7 @@ param_expand (string, sindex, quoted, expanded_something,
}
#if 1
if (temp1)
temp = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
temp = (*temp1 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
? quote_string (temp1)
: quote_escapes (temp1);
else
@@ -5982,7 +6015,7 @@ comsub:
{
temp = array_reference (array_cell (var), 0);
if (temp)
temp = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
temp = (*temp && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
? quote_string (temp)
: quote_escapes (temp);
else if (unbound_vars_is_error)
@@ -5990,10 +6023,14 @@ comsub:
}
else
#endif
{
temp = value_cell (var);
temp = (*temp && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
? quote_string (temp)
: quote_escapes (temp);
}
temp = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
? quote_string (value_cell (var))
: quote_escapes (value_cell (var));
free (temp1);
goto return0;
+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
+54 -4
View File
@@ -140,14 +140,64 @@ ok
-7
7
7
./arith1.sub: line 2: 4-- : syntax error: operand expected (error token is " ")
./arith1.sub: line 3: 4++ : syntax error: operand expected (error token is " ")
./arith1.sub: line 4: 4 -- : syntax error: operand expected (error token is " ")
./arith1.sub: line 5: 4 ++ : syntax error: operand expected (error token is " ")
1
2
1
2
6
3
7
4
0
3
7
2
-2
1
./arith1.sub: line 35: ((: ++ : syntax error: operand expected (error token is " ")
7
7
./arith1.sub: line 38: ((: -- : syntax error: operand expected (error token is " ")
7
7
7
7
1
2
1
2
1
0
5
1
6
2
3
1
4
0
./arith2.sub: line 33: ((: -- : syntax error: operand expected (error token is " ")
-7
-7
./arith2.sub: line 37: ((: ++ : syntax error: operand expected (error token is " ")
7
7
-7
-7
7
7
8 12
./arith.tests: line 265: ((: x=9 y=41 : syntax error in expression (error token is "y=41 ")
./arith.tests: line 269: a b: syntax error in expression (error token is "b")
./arith.tests: line 270: ((: a b: syntax error in expression (error token is "b")
./arith.tests: line 268: ((: x=9 y=41 : syntax error in expression (error token is "y=41 ")
./arith.tests: line 272: a b: syntax error in expression (error token is "b")
./arith.tests: line 273: ((: a b: syntax error in expression (error token is "b")
42
42
42
42
42
42
./arith.tests: line 281: b[c]d: syntax error in expression (error token is "d")
./arith.tests: line 284: b[c]d: syntax error in expression (error token is "d")
+3
View File
@@ -254,6 +254,9 @@ echo $(( -7 ))
echo $(( ++7 ))
echo $(( --7 ))
${THIS_SH} ./arith1.sub
${THIS_SH} ./arith2.sub
x=4
y=7
+281
View File
@@ -0,0 +1,281 @@
set +o posix
declare -i iv jv
iv=$(( 3 + 5 * 32 ))
echo $iv
iv=iv+3
echo $iv
iv=2
jv=iv
let "jv *= 2"
echo $jv
jv=$(( $jv << 2 ))
echo $jv
let jv="$jv / 2"
echo $jv
jv="jv >> 2"
echo $jv
iv=$((iv+ $jv))
echo $iv
echo $((iv -= jv))
echo $iv
echo $(( iv == jv ))
echo $(( iv != $jv ))
echo $(( iv < jv ))
echo $(( $iv > $jv ))
echo $(( iv <= $jv ))
echo $(( $iv >= jv ))
echo $jv
echo $(( ~$jv ))
echo $(( ~1 ))
echo $(( ! 0 ))
echo $(( jv % 2 ))
echo $(( $iv % 4 ))
echo $(( iv <<= 16 ))
echo $(( iv %= 33 ))
echo $(( 33 & 55 ))
echo $(( 33 | 17 ))
echo $(( iv && $jv ))
echo $(( $iv || jv ))
echo $(( iv && 0 ))
echo $(( iv & 0 ))
echo $(( iv && 1 ))
echo $(( iv & 1 ))
echo $(( $jv || 0 ))
echo $(( jv | 0 ))
echo $(( jv | 1 ))
echo $(( $jv || 1 ))
let 'iv *= jv'
echo $iv
echo $jv
let "jv += $iv"
echo $jv
echo $(( jv /= iv ))
echo $(( jv <<= 8 ))
echo $(( jv >>= 4 ))
echo $(( iv |= 4 ))
echo $(( iv &= 4 ))
echo $(( iv += (jv + 9)))
echo $(( (iv + 4) % 7 ))
# unary plus, minus
echo $(( +4 - 8 ))
echo $(( -4 + 8 ))
# conditional expressions
echo $(( 4<5 ? 1 : 32))
echo $(( 4>5 ? 1 : 32))
echo $(( 4>(2+3) ? 1 : 32))
echo $(( 4<(2+3) ? 1 : 32))
echo $(( (2+2)<(2+3) ? 1 : 32))
echo $(( (2+2)>(2+3) ? 1 : 32))
# check that the unevaluated part of the ternary operator does not do
# evaluation or assignment
x=i+=2
y=j+=2
declare -i i=1 j=1
echo $((1 ? 20 : (x+=2)))
echo $i,$x
echo $((0 ? (y+=2) : 30))
echo $j,$y
x=i+=2
y=j+=2
declare -i i=1 j=1
echo $((1 ? 20 : (x+=2)))
echo $i,$x
echo $((0 ? (y+=2) : 30))
echo $i,$y
# check precedence of assignment vs. conditional operator
# should be an error
declare -i x=2
y=$((1 ? 20 : x+=2))
# check precedence of assignment vs. conditional operator
declare -i x=2
echo $((0 ? x+=2 : 20))
# associativity of assignment-operator operator
declare -i i=1 j=2 k=3
echo $((i += j += k))
echo $i,$j,$k
# octal, hex
echo $(( 0x100 | 007 ))
echo $(( 0xff ))
echo $(( 16#ff ))
echo $(( 16#FF/2 ))
echo $(( 8#44 ))
echo $(( 8 ^ 32 ))
# other bases
echo $(( 16#a ))
echo $(( 32#a ))
echo $(( 56#a ))
echo $(( 64#a ))
echo $(( 16#A ))
echo $(( 32#A ))
echo $(( 56#A ))
echo $(( 64#A ))
echo $(( 64#@ ))
echo $(( 64#_ ))
# weird bases
echo $(( 3425#56 ))
# missing number after base
echo $(( 2# ))
# these should generate errors
echo $(( 7 = 43 ))
echo $(( 2#44 ))
echo $(( 44 / 0 ))
let 'jv += $iv'
echo $(( jv += \$iv ))
let 'rv = 7 + (43 * 6'
# more errors
declare -i i
i=0#4
i=2#110#11
((echo abc; echo def;); echo ghi)
if (((4+4) + (4 + 7))); then
echo ok
fi
(()) # make sure the null expression works OK
a=(0 2 4 6)
echo $(( a[1] + a[2] ))
echo $(( (a[1] + a[2]) == a[3] ))
(( (a[1] + a[2]) == a[3] )) ; echo $?
# test pushing and popping the expression stack
unset A
A="4 + "
echo $(( ( 4 + A ) + 4 ))
A="3 + 5"
echo $(( ( 4 + A ) + 4 ))
# badly-formed conditional expressions
echo $(( 4 ? : $A ))
echo $(( 1 ? 20 ))
echo $(( 4 ? 20 : ))
# precedence and short-circuit evaluation
B=9
echo $B
echo $(( 0 && B=42 ))
echo $B
echo $(( 1 || B=88 ))
echo $B
echo $(( 0 && (B=42) ))
echo $B
echo $(( (${$} - $$) && (B=42) ))
echo $B
echo $(( 1 || (B=88) ))
echo $B
# until command with (( )) command
x=7
echo $x
until (( x == 4 ))
do
echo $x
x=4
done
echo $x
# exponentiation
echo $(( 2**15 - 1))
echo $(( 2**(16-1)))
echo $(( 2**16*2 ))
echo $(( 2**31-1))
echo $(( 2**0 ))
# {pre,post}-{inc,dec}rement and associated errors
x=4
echo $x
echo $(( x++ ))
echo $x
echo $(( x-- ))
echo $x
echo $(( --x ))
echo $x
echo $(( ++x ))
echo $x
echo $(( ++7 ))
echo $(( 7-- ))
echo $(( --x=7 ))
echo $(( ++x=7 ))
echo $(( x++=7 ))
echo $(( x--=7 ))
echo $x
echo $(( +7 ))
echo $(( -7 ))
echo $(( ++7 ))
echo $(( --7 ))
x=4
y=7
(( x=8 , y=12 ))
echo $x $y
# should be an error
(( x=9 y=41 ))
# These are errors
unset b
echo $((a b))
((a b))
n=42
printf "%d\n" $n
printf "%i\n" $n
echo $(( 8#$(printf "%o\n" $n) ))
printf "%u\n" $n
echo $(( 16#$(printf "%x\n" $n) ))
echo $(( 16#$(printf "%X\n" $n) ))
# causes longjmp botches through bash-2.05b
a[b[c]d]=e
+38
View File
@@ -0,0 +1,38 @@
# test of redone post-increment and post-decrement code
echo $(( 4-- ))
echo $(( 4++ ))
echo $(( 4 -- ))
echo $(( 4 ++ ))
(( array[0]++ ))
echo ${array}
(( array[0] ++ ))
echo ${array}
(( a++ ))
echo $a
(( a ++ ))
echo $a
echo $(( a ++ + 4 ))
echo $a
echo $(( a+++4 ))
echo $a
echo $(( a---4 ))
echo $a
echo $(( a -- + 4 ))
echo $a
echo $(( a -- - 4 ))
echo $a
(( ++ + 7 ))
(( ++ ))
echo $(( +++7 ))
echo $(( ++ + 7 ))
(( -- ))
+45
View File
@@ -0,0 +1,45 @@
echo $(( --7 ))
echo $(( ++7 ))
echo $(( -- 7 ))
echo $(( ++ 7 ))
((++array[0] ))
echo $array
(( ++ array[0] ))
echo $array
(( ++a ))
echo $a
(( ++ a ))
echo $a
(( --a ))
echo $a
(( -- a ))
echo $a
echo $(( 4 + ++a ))
echo $a
echo $(( 4+++a ))
echo $a
echo $(( 4---a ))
echo $a
echo $(( 4 - -- a ))
echo $a
(( -- ))
echo $(( ---7 ))
echo $(( -- - 7 ))
(( ++ ))
echo $(( ++7 ))
echo $(( ++ + 7 ))
echo $(( ++-7 ))
echo $(( ++ - 7 ))
echo $(( +--7 ))
echo $(( -- + 7 ))
+4
View File
@@ -215,4 +215,8 @@ ${THIS_SH} ./dollar-star1.sub
# though bash-2.05b
${THIS_SH} ./dollar-at1.sub
# tests for expansion of other variables in double-quoted strings containing
# $@. Bugs through bash-2.05b
${THIS_SH} ./dollar-at2.sub
exit 0
+4
View File
@@ -211,4 +211,8 @@ esac
# expansions -- bugs through bash-2.05b
${THIS_SH} ./dollar-star1.sub
# tests for expansion of "$@" on rhs of things like ${param:+word}. Bugs
# though bash-2.05b
${THIS_SH} ./dollar-at1.sub
exit 0
+19
View File
@@ -0,0 +1,19 @@
t1()
{
xxx="echo $@"
recho "$xxx ; echo $@"
}
t2()
{
xxx="echo $@"
recho "${xxx} ; echo $@"
}
t1 1
t1 1 2
t2 1
t2 1 2
+6
View File
@@ -119,3 +119,9 @@ xa|xb|xc
3
3
3
argv[1] = <echo 1 ; echo 1>
argv[1] = <echo 1 2 ; echo 1>
argv[2] = <2>
argv[1] = <echo 1 ; echo 1>
argv[1] = <echo 1 2 ; echo 1>
argv[2] = <2>
+3 -3
View File
@@ -88,6 +88,7 @@ echo 'xwhix.h'
xwhix.h
echo 'xwhix.h'
xwhix.h
7 set -H
8 echo line 2 for history
9 echo a b c d e
10 echo line 2 for history
@@ -117,9 +118,8 @@ xwhix.h
34 echo bar.c bar.o bar.html bar.h
35 echo xbar.c xbar.o xbar.html xbar.h
36 echo xwhix.c xwhix.o xwhix.html xwhix.h
37 echo xwhix.c xwhix.o xwhix.html xwhix.h
38 echo 'xwhix'
39 echo 'xwhix.h'
37 echo 'xwhix'
38 echo 'xwhix.h'
!!
!!
echo '!!' \!\!
+129
View File
@@ -0,0 +1,129 @@
echo $BASH_VERSION
./histexp.tests: line 22: history: !!:z: history expansion failed
1 for i in one two three; do echo $i; done
2 /bin/sh -c 'echo this is $0'
3 ls
4 echo $BASH_VERSION
1 for i in one two three; do echo $i; done
2 /bin/sh -c 'echo this is $0'
3 ls
4 echo $BASH_VERSION
5 HISTFILE=/tmp/newhistory
6 echo line 2 for history
echo line 2 for history
echo line 2 for history
set -H
echo line 2 for history
line 2 for history
1 for i in one two three; do echo $i; done
2 /bin/sh -c 'echo this is $0'
3 ls
4 echo $BASH_VERSION
5 HISTFILE=/tmp/newhistory
6 echo line 2 for history
7 set -H
8 echo line 2 for history
a b c d e
echo a b c d e
a b c d e
echo line 2 for history
line 2 for history
echo line 8 for history
line 8 for history
/bin/sh -c 'echo this is $0'
this is /bin/sh
echo sh
sh
echo /bin
/bin
echo e
e
a b c d e
echo b c d e
b c d e
echo b c d
b c d
echo d e
d e
echo d e
d e
echo b c d
b c d
file.c
echo file
file
echo .c
.c
echo 'file'
file
bax.c
echo $file
bax
echo .c
.c
echo '$file'
$file
a b c d e
echo 'a' 'b' 'c' 'd' 'e'
a b c d e
echo 'a b c d e'
a b c d e
foo.c foo.o foo.html foo.h
echo bar.c foo.o foo.html foo.h
bar.c foo.o foo.html foo.h
echo bar.c bar.o bar.html bar.h
bar.c bar.o bar.html bar.h
echo xbar.c xbar.o xbar.html xbar.h
xbar.c xbar.o xbar.html xbar.h
echo xbar.c xbar.o xbar.html xbar.h
xbar.c xbar.o xbar.html xbar.h
echo xwhix.c xwhix.o xwhix.html xwhix.h
xwhix.c xwhix.o xwhix.html xwhix.h
echo xwhix.c xwhix.o xwhix.html xwhix.h
echo 'xwhix'
xwhix
echo 'xwhix.h'
xwhix.h
echo 'xwhix.h'
xwhix.h
echo 'xwhix.h'
xwhix.h
8 echo line 2 for history
9 echo a b c d e
10 echo line 2 for history
11 echo line 8 for history
12 /bin/sh -c 'echo this is $0'
13 echo sh
14 echo /bin
15 echo e
16 echo a b c d e
17 echo b c d e
18 echo b c d
19 echo d e
20 echo b c d
21 echo file.c
22 echo file
23 echo .c
24 echo 'file'
25 echo $file.c
26 echo $file
27 echo .c
28 echo '$file'
29 echo a b c d e
30 echo 'a' 'b' 'c' 'd' 'e'
31 echo 'a b c d e'
32 echo foo.c foo.o foo.html foo.h
33 echo bar.c foo.o foo.html foo.h
34 echo bar.c bar.o bar.html bar.h
35 echo xbar.c xbar.o xbar.html xbar.h
36 echo xwhix.c xwhix.o xwhix.html xwhix.h
37 echo xwhix.c xwhix.o xwhix.html xwhix.h
38 echo 'xwhix'
39 echo 'xwhix.h'
!!
!!
echo '!!' \!\!
!! !!
ok 1
ok 2
ok 3
+12
View File
@@ -49,3 +49,15 @@ while read -u 3 var
do
echo "$var"
done 3<$0
argv[1] = <>
argv[1] = <>
argv[1] = <:>
argv[1] = <:>
FOO
argv[1] = <>
argv[1] = <3>
argv[1] = <>
argv[2] = <>
argv[3] = <>
FOO
0 0 0
+3
View File
@@ -90,3 +90,6 @@ ${THIS_SH} ./read3.sub
# test read -u fd behavior
${THIS_SH} ./read4.sub
# test behavior when IFS is not the default -- bug through bash-2.05b
${THIS_SH} ./read5.sub
+92
View File
@@ -0,0 +1,92 @@
echo " a " | (read x; echo "$x.")
echo " a b " | ( read x y ; echo -"$x"-"$y"- )
echo " a b\ " | ( read x y ; echo -"$x"-"$y"- )
echo " a b " | ( read x ; echo -"$x"- )
echo " a b\ " | ( read x ; echo -"$x"- )
echo " a b\ " | ( read -r x y ; echo -"$x"-"$y"- )
echo " a b\ " | ( read -r x ; echo -"$x"- )
echo "\ a b\ " | ( read -r x y ; echo -"$x"-"$y"- )
echo "\ a b\ " | ( read -r x ; echo -"$x"- )
echo " \ a b\ " | ( read -r x y ; echo -"$x"-"$y"- )
echo " \ a b\ " | ( read -r x ; echo -"$x"- )
# make sure that CTLESC and CTLNUL are passed through correctly
echo $'\001' | ( read var ; recho "$var" )
echo $'\001' | ( read ; recho "$REPLY" )
echo $'\177' | ( read var ; recho "$var" )
echo $'\177' | ( read ; recho "$REPLY" )
# make sure a backslash-quoted \\n still disappears from the input when
# we're not reading in `raw' mode, and no stray CTLESC chars are left in
# the input stream
echo $'ab\\\ncd' | ( read ; recho "$REPLY" )
echo "A B " > /tmp/IN
unset x y z
read x y z < /tmp/IN
echo 1: "x[$x] y[$y] z[$z]"
echo 1a: ${z-z not set}
read x < /tmp/IN
echo 2: "x[$x]"
rm /tmp/IN
# this is where the bash `read' behavior with respect to $REPLY differs
# from ksh93
echo "A B " > /tmp/IN
read < /tmp/IN
echo "[$REPLY]"
rm /tmp/IN
echo " A B " > /tmp/IN
read < /tmp/IN
echo "[$REPLY]"
rm /tmp/IN
# make sure that read with more variables than words sets the extra
# variables to the empty string
bvar=bvar
cvar=cvar
echo aa > /tmp/IN
read avar bvar cvar < /tmp/IN
echo =="$avar"==
echo =="$bvar"==
echo =="$cvar"==
rm /tmp/IN
# test behavior of read with various settings of IFS
echo " foo" | { IFS= read line; recho "$line"; }
echo " foo" | { IFS= ; read line; recho "$line"; }
echo " foo" | { unset IFS ; read line; recho "$line"; }
echo " foo" | { IFS=$'\n' ; read line; recho "$line"; }
echo " foo" | { IFS=$' \n' ; read line; recho "$line"; }
echo " foo" | { IFS=$' \t\n' ; read line; recho "$line"; }
echo " foo" | { IFS=$':' ; read line; recho "$line"; }
# test read -d delim behavior
${THIS_SH} ./read1.sub
# test read -t timeout behavior
${THIS_SH} ./read2.sub
# test read -n nchars behavior
${THIS_SH} ./read3.sub
# test read -u fd behavior
${THIS_SH} ./read4.sub
+36
View File
@@ -0,0 +1,36 @@
IFS=: read x y z << EOF
:::
EOF
recho $x
recho "$x"
recho $y
recho "$y"
recho $z
recho "$z"
if [ -z "$x" ]; then
echo FOO
else
echo BAR
fi
IFS=: read -a A << EOF
:::
EOF
recho ${A[0]}
recho "${A[0]}"
recho ${#A[@]}
recho "${A[@]}"
if [ -z "${A[0]}" ]; then
echo FOO
else
echo BAR
fi
echo -n ${A[0]} | cat -vet
echo -n ${A[0]} | wc