commit bash-20110218 snapshot

This commit is contained in:
Chet Ramey
2011-12-29 13:04:06 -05:00
parent e192f34170
commit 9c2db99939
43 changed files with 26837 additions and 82 deletions
+54 -1
View File
@@ -11022,6 +11022,12 @@ lib/glob/gmisc.c
- fix wmatchlen and umatchlen to initialize all state variables. Fix
from Andreas Schwab <schwab@linux-m68k.org>
jobs.c
- change wait_for to call restore_sigint_handler right after exiting
the wait loop, instead of right before function returns. Reduces
the window for a SIGINT to be lost because a child does not exit
due to SIGINT
2/7
---
configure.in
@@ -11050,7 +11056,7 @@ print_cmd.c
lib/glob/gmisc.c
- fix wmatchlen and umatchlen to avoid going past the end of the
string on an incomplete bracket expression that ends with a
NUL. Fixes bug reported by Clark Wang <dearvoid@gmail.com>
NUL. Partial fix for bug reported by Clark Wang <dearvoid@gmail.com>
2/16
----
@@ -11089,3 +11095,50 @@ doc/{bash.1,bashref.texi}
operators to [[ states that only the quoted portion of the pattern
is matched as a string
2/18
----
lib/glob/gmisc.c
- better fix for umatchlen/wmatchlen: keep track of the number of
characters in a bracket expression as the value to increase
matchlen by if the bracket expression is not well-formed. Fixes
bug reported by Clark Wang <dearvoid@gmail.com>
subst.c
- change expand_string_for_rhs so that it sets the W_NOSPLIT2 flag
in the word flags. We will not perform word splitting or quote
removal on the result, so we do not want to add quoted nulls if
we see "" or ''. Fixes bug reported by Mike Frysinger
<vapier@gentoo.org>
2/19
----
variables.c
- new function, int chkexport(name), checks whether variable NAME is
exported and remakes the export environment if necessary. Returns
1 if NAME is exported and 0 if not
- call chkexport(name) to get tzset to look at the right variable in
the environment when modifying TZ in sv_tz. Don't call tzset if
chkexport doesn't indicate that the variable is exported
variables.h
- new extern declaration for chkexport
{parse.y,builtins/printf.def}
- call sv_tz before calling localtime() when formatting time strings
in prompt strings or using printf. Fixes bug reported by
Dennis Williamson <dennistwilliamson@gmail.com>
execute_cmd.c
- modify fix of 2/9 to add casts when those variables are passed to
functions; some compilers throw errors instead of warnings. Report
and fix from Joachim Schmitz <jojo@schmitz-digital.de>
support/shobj-conf
- add a stanza for nsk on the Tandem from Joachim Schmitz
<jojo@schmitz-digital.de>
{shell,lib/readline/shell}.c
- Tandem systems should use getpwnam (getlogin()); for some reason
they don't do well with using getuid(). Fix from Joachim Schmitz
<jojo@schmitz-digital.de>
+55 -1
View File
@@ -11022,6 +11022,12 @@ lib/glob/gmisc.c
- fix wmatchlen and umatchlen to initialize all state variables. Fix
from Andreas Schwab <schwab@linux-m68k.org>
jobs.c
- change wait_for to call restore_sigint_handler right after exiting
the wait loop, instead of right before function returns. Reduces
the window for a SIGINT to be lost because a child does not exit
due to SIGINT
2/7
---
configure.in
@@ -11050,7 +11056,7 @@ print_cmd.c
lib/glob/gmisc.c
- fix wmatchlen and umatchlen to avoid going past the end of the
string on an incomplete bracket expression that ends with a
NUL. Fixes bug reported by Clark Wang <dearvoid@gmail.com>
NUL. Partial fix for bug reported by Clark Wang <dearvoid@gmail.com>
2/16
----
@@ -11083,3 +11089,51 @@ lib/readline/callback.c
- make sure _rl_internal_char_cleanup is called after the
vi-motion callbacks (rl_vi_domove_callback) in rl_callback_read_char.
Companion to above fix
doc/{bash.1,bashref.texi}
- make sure that the text describing the rhs of the == and =~
operators to [[ states that only the quoted portion of the pattern
is matched as a string
2/18
----
lib/glob/gmisc.c
- better fix for umatchlen/wmatchlen: keep track of the number of
characters in a bracket expression as the value to increase
matchlen by if the bracket expression is not well-formed. Fixes
bug reported by Clark Wang <dearvoid@gmail.com>
subst.c
- change expand_string_for_rhs so that it sets the W_NOSPLIT2 flag
in the word flags. We will not perform word splitting or quote
removal on the result, so we do not want to add quoted nulls if
we see "" or ''. Fixes bug reported by Mike Frysinger
<vapier@gentoo.org>
2/19
----
variables.c
- new function, int chkexport(name), checks whether variable NAME is
exported and remakes the export environment if necessary. Returns
1 if NAME is exported and 0 if not
- call chkexport(name) to get tzset to look at the right variable in
the environment when modifying TZ in sv_tz. Don't call tzset if
chkexport doesn't indicate that the variable is exported
variables.h
- new extern declaration for chkexport
{parse.y,builtins/printf.def}
- call sv_tz before calling localtime() when formatting time strings
in prompt strings or using printf. Fixes bug reported by
Dennis Williamson <dennistwilliamson@gmail.com>
execute_cmd.c
- modify fix of 2/9 to add casts when those variables are passed to
functions; some compilers throw errors instead of warnings. Report
and fix from Joachim Schmitz <jojo@schmitz-digital.de>
support/shobj-conf
- add a stanza for nsk on the Tandem from Joachim Schmitz
<jojo@schmitz-digital.de>
+2
View File
@@ -857,6 +857,7 @@ tests/exp1.sub f
tests/exp2.sub f
tests/exp3.sub f
tests/exp4.sub f
tests/exp5.sub f
tests/extglob.tests f
tests/extglob.right f
tests/extglob1.sub f
@@ -995,6 +996,7 @@ tests/redir8.sub f
tests/redir9.sub f
tests/rhs-exp.tests f
tests/rhs-exp.right f
tests/rhs-exp1.sub f
tests/rsh.tests f
tests/rsh.right f
tests/run-all f
+1174
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -465,6 +465,9 @@ printf_builtin (list)
secs = shell_start_time; /* roughly $SECONDS */
else
secs = arg;
#if defined (HAVE_TZSET)
sv_tz ("TZ"); /* XXX -- just make sure */
#endif
tm = localtime (&secs);
n = strftime (timebuf, sizeof (timebuf), timefmt, tm);
free (timefmt);
+1239
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1,4 +1,4 @@
This is TeX, Version 3.141592 (Web2C 7.5.4) (format=tex 2008.12.11) 28 JAN 2011 22:07
This is TeX, Version 3.141592 (Web2C 7.5.4) (format=tex 2008.12.11) 13 FEB 2011 12:17
**/Users/chet/src/bash/src/doc/bashref.texi
(/Users/chet/src/bash/src/doc/bashref.texi (./texinfo.tex
Loading texinfo [version 2009-01-18.17]:
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -109,7 +109,7 @@ mkdir_builtin (list)
umask (original_umask);
nmode = (S_IRWXU | S_IRWXG | S_IRWXO) & ~original_umask;
parent_mode = nmode | (S_IWRITE|S_IEXEC); /* u+wx */
parent_mode = nmode | (S_IWUSR|S_IXUSR); /* u+wx */
/* Adjust new mode based on mode argument */
nmode &= omode;
+237
View File
@@ -0,0 +1,237 @@
/* mkdir - make directories */
/* See Makefile for compilation details. */
/*
Copyright (C) 1999-2009 Free Software Foundation, Inc.
This file is part of GNU Bash.
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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "bashtypes.h"
#include "posixstat.h"
#include <errno.h>
#include <stdio.h>
#include "bashansi.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
#include "common.h"
#if !defined (errno)
extern int errno;
#endif
#define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
extern int parse_symbolic_mode ();
static int make_path ();
static int original_umask;
int
mkdir_builtin (list)
WORD_LIST *list;
{
int opt, pflag, omode, rval, octal, nmode, parent_mode, um;
char *mode;
WORD_LIST *l;
reset_internal_getopt ();
pflag = 0;
mode = (char *)NULL;
while ((opt = internal_getopt(list, "m:p")) != -1)
switch (opt)
{
case 'p':
pflag = 1;
break;
case 'm':
mode = list_optarg;
break;
default:
builtin_usage();
return (EX_USAGE);
}
list = loptend;
if (list == 0)
{
builtin_usage ();
return (EX_USAGE);
}
if (mode == NULL)
omode = S_IRWXU | S_IRWXG | S_IRWXO; /* a=rwx */
else if (ISOCTAL (*mode)) /* octal number */
{
omode = read_octal (mode);
if (omode < 0)
{
builtin_error ("invalid file mode: %s", mode);
return (EXECUTION_FAILURE);
}
octal = 1;
}
else if (mode)
{
/* initial bits are a=rwx; the mode argument modifies them */
omode = parse_symbolic_mode (mode, S_IRWXU | S_IRWXG | S_IRWXO);
if (omode < 0)
{
builtin_error ("invalid file mode: %s", mode);
return (EXECUTION_FAILURE);
}
octal = 0;
}
/* Make the new mode */
original_umask = umask (0);
umask (original_umask);
nmode = (S_IRWXU | S_IRWXG | S_IRWXO) & ~original_umask;
parent_mode = nmode | (S_IWRITE|S_IEXEC); /* u+wx */
/* Adjust new mode based on mode argument */
nmode &= omode;
for (rval = EXECUTION_SUCCESS, l = list; l; l = l->next)
{
if (pflag && make_path (l->word->word, nmode, parent_mode))
{
rval = EXECUTION_FAILURE;
continue;
}
else if (pflag == 0 && mkdir (l->word->word, nmode) < 0)
{
builtin_error ("cannot create directory `%s': %s", l->word->word, strerror (errno));
rval = EXECUTION_FAILURE;
}
}
return rval;
}
/* Make all the directories leading up to PATH, then create PATH. Note that
this changes the process's umask; make sure that all paths leading to a
return reset it to ORIGINAL_UMASK */
static int
make_path (path, nmode, parent_mode)
char *path;
int nmode, parent_mode;
{
int oumask;
struct stat sb;
char *p, *npath;
if (stat (path, &sb) == 0)
{
if (S_ISDIR (sb.st_mode) == 0)
{
builtin_error ("`%s': file exists but is not a directory", path);
return 1;
}
if (chmod (path, nmode))
{
builtin_error ("%s: %s", path, strerror (errno));
return 1;
}
return 0;
}
oumask = umask (0);
npath = savestring (path); /* So we can write to it. */
/* Check whether or not we need to do anything with intermediate dirs. */
/* Skip leading slashes. */
p = npath;
while (*p == '/')
p++;
while (p = strchr (p, '/'))
{
*p = '\0';
if (stat (npath, &sb) != 0)
{
if (mkdir (npath, parent_mode))
{
builtin_error ("cannot create directory `%s': %s", npath, strerror (errno));
umask (original_umask);
free (npath);
return 1;
}
}
else if (S_ISDIR (sb.st_mode) == 0)
{
builtin_error ("`%s': file exists but is not a directory", npath);
umask (original_umask);
free (npath);
return 1;
}
*p++ = '/'; /* restore slash */
while (*p == '/')
p++;
}
/* Create the final directory component. */
if (stat (npath, &sb) && mkdir (npath, nmode))
{
builtin_error ("cannot create directory `%s': %s", npath, strerror (errno));
umask (original_umask);
free (npath);
return 1;
}
umask (original_umask);
free (npath);
return 0;
}
char *mkdir_doc[] = {
"Create directories.",
"",
"Make directories. Create the directories named as arguments, in",
"the order specified, using mode rwxrwxrwx as modified by the current",
"umask (see `help umask'). The -m option causes the file permission",
"bits of the final directory to be MODE. The MODE argument may be",
"an octal number or a symbolic mode like that used by chmod(1). If",
"a symbolic mode is used, the operations are interpreted relative to",
"an initial mode of \"a=rwx\". The -p option causes any required",
"intermediate directories in PATH to be created. The directories",
"are created with permssion bits of rwxrwxrwx as modified by the current",
"umask, plus write and search permissions for the owner. mkdir",
"returns 0 if the directories are created successfully, and non-zero",
"if an error occurs.",
(char *)NULL
};
struct builtin mkdir_struct = {
"mkdir",
mkdir_builtin,
BUILTIN_ENABLED,
mkdir_doc,
"mkdir [-p] [-m mode] directory [directory ...]",
0
};
+6 -6
View File
@@ -1504,7 +1504,7 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
else if (function_value)
return_code = return_catch_value;
else
return_code = execute_command_internal (tcom, asynchronous, NO_PIPE, NO_PIPE, fds_to_close);
return_code = execute_command_internal ((COMMAND *)tcom, asynchronous, NO_PIPE, NO_PIPE, fds_to_close);
/* If we are asked to, invert the return value. */
if (invert)
@@ -4238,11 +4238,11 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
/* This is quite similar to the code in shell.c and elsewhere. */
shell_fn = find_function_def (this_shell_function->name);
sfile = shell_fn ? shell_fn->source_file : "";
array_push (funcname_a, this_shell_function->name);
array_push ((ARRAY *)funcname_a, this_shell_function->name);
array_push (bash_source_a, sfile);
array_push ((ARRAY *)bash_source_a, sfile);
t = itos (executing_line_number ());
array_push (bash_lineno_a, t);
array_push ((ARRAY *)bash_lineno_a, t);
free (t);
#endif
@@ -4317,8 +4317,8 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
#if defined (ARRAY_VARS)
/* These two variables cannot be unset, and cannot be affected by the
function. */
array_pop (bash_source_a);
array_pop (bash_lineno_a);
array_pop ((ARRAY *)bash_source_a);
array_pop ((ARRAY *)bash_lineno_a);
/* FUNCNAME can be unset, and so can potentially be changed by the
function. */
+5187
View File
File diff suppressed because it is too large Load Diff
+3 -4
View File
@@ -2524,6 +2524,9 @@ if (job == NO_JOB)
give_terminal_to (shell_pgrp, 0);
}
/* Restore the original SIGINT signal handler before we return. */
restore_sigint_handler ();
/* If the command did not exit cleanly, or the job is just
being stopped, then reset the tty state back to what it
was before this command. Reset the tty state and notify
@@ -2589,7 +2592,6 @@ if (job == NO_JOB)
if (WIFSIGNALED (s) && WTERMSIG (s) == SIGINT && signal_is_trapped (SIGINT) == 0)
{
UNBLOCK_CHILD (oset);
restore_sigint_handler ();
old_sigint_handler = set_signal_handler (SIGINT, SIG_DFL);
if (old_sigint_handler == SIG_IGN)
restore_sigint_handler ();
@@ -2615,9 +2617,6 @@ wait_for_return:
UNBLOCK_CHILD (oset);
/* Restore the original SIGINT signal handler before we return. */
restore_sigint_handler ();
return (termination_state);
}
+4276
View File
File diff suppressed because it is too large Load Diff
+64 -22
View File
@@ -77,8 +77,8 @@ wmatchlen (wpat, wmax)
wchar_t *wpat;
size_t wmax;
{
wchar_t wc, *wbrack;
int matlen, t, in_cclass, in_collsym, in_equiv;
wchar_t wc;
int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
if (*wpat == 0)
return (0);
@@ -118,59 +118,80 @@ wmatchlen (wpat, wmax)
break;
case L'[':
/* scan for ending `]', skipping over embedded [:...:] */
wbrack = wpat;
bracklen = 1;
wc = *wpat++;
do
{
if (wc == 0)
{
matlen += wpat - wbrack - 1; /* incremented below */
wpat--; /* back up to NUL */
break;
wpat--; /* back up to NUL */
matlen += bracklen;
goto bad_bracket;
}
else if (wc == L'\\')
{
wc = *wpat++;
if (*wpat == 0)
break;
/* *wpat == backslash-escaped character */
bracklen++;
/* If the backslash or backslash-escape ends the string,
bail. The ++wpat skips over the backslash escape */
if (*wpat == 0 || *++wpat == 0)
{
matlen += bracklen;
goto bad_bracket;
}
}
else if (wc == L'[' && *wpat == L':') /* character class */
{
wpat++;
bracklen++;
in_cclass = 1;
}
else if (in_cclass && wc == L':' && *wpat == L']')
{
wpat++;
bracklen++;
in_cclass = 0;
}
else if (wc == L'[' && *wpat == L'.') /* collating symbol */
{
wpat++;
bracklen++;
if (*wpat == L']') /* right bracket can appear as collating symbol */
wpat++;
{
wpat++;
bracklen++;
}
in_collsym = 1;
}
else if (in_collsym && wc == L'.' && *wpat == L']')
{
wpat++;
bracklen++;
in_collsym = 0;
}
else if (wc == L'[' && *wpat == L'=') /* equivalence class */
{
wpat++;
bracklen++;
if (*wpat == L']') /* right bracket can appear as equivalence class */
wpat++;
{
wpat++;
bracklen++;
}
in_equiv = 1;
}
else if (in_equiv && wc == L'=' && *wpat == L']')
{
wpat++;
bracklen++;
in_equiv = 0;
}
else
bracklen++;
}
while ((wc = *wpat++) != L']');
matlen++; /* bracket expression can only match one char */
bad_bracket:
break;
}
}
@@ -214,8 +235,8 @@ umatchlen (pat, max)
char *pat;
size_t max;
{
char c, *brack;
int matlen, t, in_cclass, in_collsym, in_equiv;
char c;
int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
if (*pat == 0)
return (0);
@@ -255,59 +276,80 @@ umatchlen (pat, max)
break;
case '[':
/* scan for ending `]', skipping over embedded [:...:] */
brack = pat;
bracklen = 1;
c = *pat++;
do
{
if (c == 0)
{
matlen += pat - brack - 1; /* incremented below */
pat--; /* back up to NUL */
break;
pat--; /* back up to NUL */
matlen += bracklen;
goto bad_bracket;
}
else if (c == '\\')
{
c = *pat++;
if (*pat == 0)
break;
/* *pat == backslash-escaped character */
bracklen++;
/* If the backslash or backslash-escape ends the string,
bail. The ++pat skips over the backslash escape */
if (*pat == 0 || *++pat == 0)
{
matlen += bracklen;
goto bad_bracket;
}
}
else if (c == '[' && *pat == ':') /* character class */
{
pat++;
bracklen++;
in_cclass = 1;
}
else if (in_cclass && c == ':' && *pat == ']')
{
pat++;
bracklen++;
in_cclass = 0;
}
else if (c == '[' && *pat == '.') /* collating symbol */
{
pat++;
bracklen++;
if (*pat == ']') /* right bracket can appear as collating symbol */
pat++;
{
pat++;
bracklen++;
}
in_collsym = 1;
}
else if (in_collsym && c == '.' && *pat == ']')
{
pat++;
bracklen++;
in_collsym = 0;
}
else if (c == '[' && *pat == '=') /* equivalence class */
{
pat++;
bracklen++;
if (*pat == ']') /* right bracket can appear as equivalence class */
pat++;
{
pat++;
bracklen++;
}
in_equiv = 1;
}
else if (in_equiv && c == '=' && *pat == ']')
{
pat++;
bracklen++;
in_equiv = 0;
}
else
bracklen++;
}
while ((c = *pat++) != ']');
matlen++; /* bracket expression can only match one char */
bad_bracket:
break;
}
}
+48 -19
View File
@@ -77,8 +77,8 @@ wmatchlen (wpat, wmax)
wchar_t *wpat;
size_t wmax;
{
wchar_t wc, *wbrack;
int matlen, t, in_cclass, in_collsym, in_equiv;
wchar_t wc;
int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
if (*wpat == 0)
return (0);
@@ -118,20 +118,27 @@ wmatchlen (wpat, wmax)
break;
case L'[':
/* scan for ending `]', skipping over embedded [:...:] */
wbrack = wpat;
bracklen = 1;
wc = *wpat++;
do
{
if (wc == 0)
{
matlen += wpat - wbrack - 1; /* incremented below */
break;
wpat--; /* back up to NUL */
matlen += bracklen;
goto bad_bracket;
}
else if (wc == L'\\')
{
wc = *wpat++;
if (*wpat == 0)
break;
/* *wpat == backslash-escaped character */
bracklen++;
/* If the backslash or backslash-escape ends the string,
bail. The ++wpat skips over the backslash escape */
if (*wpat == 0 || *++wpat == 0)
{
matlen += bracklen;
goto bad_bracket;
}
}
else if (wc == L'[' && *wpat == L':') /* character class */
{
@@ -170,6 +177,7 @@ wmatchlen (wpat, wmax)
}
while ((wc = *wpat++) != L']');
matlen++; /* bracket expression can only match one char */
bad_bracket:
break;
}
}
@@ -213,8 +221,8 @@ umatchlen (pat, max)
char *pat;
size_t max;
{
char c, *brack;
int matlen, t, in_cclass, in_collsym, in_equiv;
char c;
int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
if (*pat == 0)
return (0);
@@ -254,59 +262,80 @@ umatchlen (pat, max)
break;
case '[':
/* scan for ending `]', skipping over embedded [:...:] */
brack = pat;
bracklen = 1;
c = *pat++;
do
{
if (c == 0)
{
matlen += pat - brack - 1; /* incremented below */
pat--; /* back up to NUL */
break;
pat--; /* back up to NUL */
matlen += bracklen;
goto bad_bracket;
}
else if (c == '\\')
{
c = *pat++;
if (*pat == 0)
break;
/* *pat == backslash-escaped character */
bracklen++;
/* If the backslash or backslash-escape ends the string,
bail. The ++pat skips over the backslash escape */
if (*pat == 0 || *++pat == 0)
{
matlen += bracklen;
goto bad_bracket;
}
}
else if (c == '[' && *pat == ':') /* character class */
{
pat++;
bracklen++;
in_cclass = 1;
}
else if (in_cclass && c == ':' && *pat == ']')
{
pat++;
bracklen++;
in_cclass = 0;
}
else if (c == '[' && *pat == '.') /* collating symbol */
{
pat++;
bracklen++;
if (*pat == ']') /* right bracket can appear as collating symbol */
pat++;
{
pat++;
bracklen++;
}
in_collsym = 1;
}
else if (in_collsym && c == '.' && *pat == ']')
{
pat++;
bracklen++;
in_collsym = 0;
}
else if (c == '[' && *pat == '=') /* equivalence class */
{
pat++;
bracklen++;
if (*pat == ']') /* right bracket can appear as equivalence class */
pat++;
{
pat++;
bracklen++;
}
in_equiv = 1;
}
else if (in_equiv && c == '=' && *pat == ']')
{
pat++;
bracklen++;
in_equiv = 0;
}
else
bracklen++;
}
while ((c = *pat++) != ']');
matlen++; /* bracket expression can only match one char */
bad_bracket:
break;
}
}
+4
View File
@@ -164,7 +164,11 @@ sh_get_home_dir ()
home_dir = (char *)NULL;
#if defined (HAVE_GETPWUID)
# if defined (__TANDEM)
entry = getpwnam (getlogin ());
# else
entry = getpwuid (getuid ());
# endif
if (entry)
home_dir = entry->pw_dir;
#endif
+208
View File
@@ -0,0 +1,208 @@
/* shell.c -- readline utility functions that are normally provided by
bash when readline is linked as part of the shell. */
/* Copyright (C) 1997-2009 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
Readline 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 3 of the License, or
(at your option) any later version.
Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
*/
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#if defined (HAVE_LIMITS_H)
# include <limits.h>
#endif
#if defined (HAVE_FCNTL_H)
#include <fcntl.h>
#endif
#if defined (HAVE_PWD_H)
#include <pwd.h>
#endif
#include <stdio.h>
#include "rlstdc.h"
#include "rlshell.h"
#include "xmalloc.h"
#if defined (HAVE_GETPWUID) && !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid PARAMS((uid_t));
#endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */
#ifndef NULL
# define NULL 0
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* Nonzero if the integer type T is signed. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* Bound on length of the string representing an integer value of type T.
Subtract one for the sign bit if T is signed;
302 / 1000 is log10 (2) rounded up;
add one for integer division truncation;
add one more for a minus sign if t is signed. */
#define INT_STRLEN_BOUND(t) \
((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \
+ 1 + TYPE_SIGNED (t))
/* All of these functions are resolved from bash if we are linking readline
as part of bash. */
/* Does shell-like quoting using single quotes. */
char *
sh_single_quote (string)
char *string;
{
register int c;
char *result, *r, *s;
result = (char *)xmalloc (3 + (4 * strlen (string)));
r = result;
*r++ = '\'';
for (s = string; s && (c = *s); s++)
{
*r++ = c;
if (c == '\'')
{
*r++ = '\\'; /* insert escaped single quote */
*r++ = '\'';
*r++ = '\''; /* start new quoted string */
}
}
*r++ = '\'';
*r = '\0';
return (result);
}
/* Set the environment variables LINES and COLUMNS to lines and cols,
respectively. */
void
sh_set_lines_and_columns (lines, cols)
int lines, cols;
{
char *b;
#if defined (HAVE_SETENV)
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
sprintf (b, "%d", lines);
setenv ("LINES", b, 1);
xfree (b);
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
sprintf (b, "%d", cols);
setenv ("COLUMNS", b, 1);
xfree (b);
#else /* !HAVE_SETENV */
# if defined (HAVE_PUTENV)
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
sprintf (b, "LINES=%d", lines);
putenv (b);
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
sprintf (b, "COLUMNS=%d", cols);
putenv (b);
# endif /* HAVE_PUTENV */
#endif /* !HAVE_SETENV */
}
char *
sh_get_env_value (varname)
const char *varname;
{
return ((char *)getenv (varname));
}
char *
sh_get_home_dir ()
{
char *home_dir;
struct passwd *entry;
home_dir = (char *)NULL;
#if defined (HAVE_GETPWUID)
entry = getpwuid (getuid ());
if (entry)
home_dir = entry->pw_dir;
#endif
return (home_dir);
}
#if !defined (O_NDELAY)
# if defined (FNDELAY)
# define O_NDELAY FNDELAY
# endif
#endif
int
sh_unset_nodelay_mode (fd)
int fd;
{
#if defined (HAVE_FCNTL)
int flags, bflags;
if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
return -1;
bflags = 0;
#ifdef O_NONBLOCK
bflags |= O_NONBLOCK;
#endif
#ifdef O_NDELAY
bflags |= O_NDELAY;
#endif
if (flags & bflags)
{
flags &= ~bflags;
return (fcntl (fd, F_SETFL, flags));
}
#endif
return 0;
}
+3
View File
@@ -5135,6 +5135,9 @@ decode_prompt_string (string)
case 'A':
/* Make the current time/date into a string. */
(void) time (&the_time);
#if defined (HAVE_TZSET)
sv_tz ("TZ"); /* XXX -- just make sure */
#endif
tm = localtime (&the_time);
if (c == 'd')
+6015
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -1638,7 +1638,11 @@ get_current_user_info ()
/* Don't fetch this more than once. */
if (current_user.user_name == 0)
{
#if defined (__TANDEM)
entry = getpwnam (getlogin ());
#else
entry = getpwuid (current_user.uid);
#endif
if (entry)
{
current_user.user_name = savestring (entry->pw_name);
+1856
View File
File diff suppressed because it is too large Load Diff
+4 -2
View File
@@ -3206,7 +3206,9 @@ call_expand_word_internal (w, q, i, c, e)
}
/* Perform parameter expansion, command substitution, and arithmetic
expansion on STRING, as if it were a word. Leave the result quoted. */
expansion on STRING, as if it were a word. Leave the result quoted.
Since this does not perform word splitting, it leaves quoted nulls
in the result. */
static WORD_LIST *
expand_string_internal (string, quoted)
char *string;
@@ -3373,7 +3375,7 @@ expand_string_for_rhs (string, quoted, dollar_at_p, has_dollar_at)
if (string == 0 || *string == '\0')
return (WORD_LIST *)NULL;
td.flags = 0;
td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */
td.word = string;
tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at);
return (tresult);
+9 -7
View File
@@ -1381,8 +1381,8 @@ extract_dollar_brace_string (string, sindex, quoted, flags)
/* The handling of dolbrace_state needs to agree with the code in parse.y:
parse_matched_pair(). The different initial value is to handle the
case where this function is called to parse the word in
${param op word}. */
dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : 0;
${param op word} (SX_WORD). */
dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM;
if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP))
dolbrace_state = DOLBRACE_QUOTE;
@@ -3206,7 +3206,9 @@ call_expand_word_internal (w, q, i, c, e)
}
/* Perform parameter expansion, command substitution, and arithmetic
expansion on STRING, as if it were a word. Leave the result quoted. */
expansion on STRING, as if it were a word. Leave the result quoted.
Since this does not perform word splitting, it leaves quoted nulls
in the result. */
static WORD_LIST *
expand_string_internal (string, quoted)
char *string;
@@ -3373,7 +3375,7 @@ expand_string_for_rhs (string, quoted, dollar_at_p, has_dollar_at)
if (string == 0 || *string == '\0')
return (WORD_LIST *)NULL;
td.flags = 0;
td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */
td.word = string;
tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at);
return (tresult);
@@ -7176,9 +7178,9 @@ parameter_brace_expand (string, indexp, quoted, pflags, quoted_dollar_atp, conta
/* Get the rest of the stuff inside the braces. */
if (c && c != RBRACE)
{
/* Extract the contents of the ${ ... } expansion according to the
Posix.2 rules. */
value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#') ? SX_POSIXEXP|SX_WORD : SX_WORD);
/* Extract the contents of the ${ ... } expansion
according to the Posix.2 rules. */
value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD);
if (string[sindex] == RBRACE)
sindex++;
else
+12 -14
View File
@@ -1379,10 +1379,12 @@ extract_dollar_brace_string (string, sindex, quoted, flags)
slen = strlen (string + *sindex) + *sindex;
/* The handling of dolbrace_state needs to agree with the code in parse.y:
parse_matched_pair() */
dolbrace_state = 0;
if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
dolbrace_state = (flags & SX_POSIXEXP) ? DOLBRACE_QUOTE : DOLBRACE_PARAM;
parse_matched_pair(). The different initial value is to handle the
case where this function is called to parse the word in
${param op word} (SX_WORD). */
dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM;
if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP))
dolbrace_state = DOLBRACE_QUOTE;
i = *sindex;
while (c = string[i])
@@ -3204,7 +3206,9 @@ call_expand_word_internal (w, q, i, c, e)
}
/* Perform parameter expansion, command substitution, and arithmetic
expansion on STRING, as if it were a word. Leave the result quoted. */
expansion on STRING, as if it were a word. Leave the result quoted.
Since this does not perform word splitting, it leaves quoted nulls
in the result. */
static WORD_LIST *
expand_string_internal (string, quoted)
char *string;
@@ -3371,7 +3375,7 @@ expand_string_for_rhs (string, quoted, dollar_at_p, has_dollar_at)
if (string == 0 || *string == '\0')
return (WORD_LIST *)NULL;
td.flags = 0;
td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */
td.word = string;
tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at);
return (tresult);
@@ -4188,7 +4192,7 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
mlen = wmatchlen (wpat, wstrlen);
/* itrace("wmatchlen (%ls) -> %d", wpat, mlen); */
itrace("wmatchlen (%ls) -> %d", wpat, mlen);
switch (mtype)
{
case MATCH_ANY:
@@ -4307,15 +4311,9 @@ match_pattern (string, pat, mtype, sp, ep)
if (MB_CUR_MAX > 1)
{
#if 0
slen = STRLEN (string);
mslen = MBSLEN (string);
plen = STRLEN (pat);
mplen = MBSLEN (pat);
if (slen == mslen && plen == mplen)
#else
if (mbsmbchar (string) == 0 && mbsmbchar (pat) == 0)
#endif
return (match_upattern (string, pat, mtype, sp, ep));
#endif
n = xdupmbstowcs (&wpat, NULL, pat);
if (n == (size_t)-1)
+14
View File
@@ -65,6 +65,20 @@ while [ $# -gt 0 ]; do
done
case "${host_os}-${SHOBJ_CC}-${host_vendor}" in
nsk-cc-tandem)
SHOBJ_CFLAGS=-Wglobalized
case $(uname -m) in
NSR*)
SHOBJ_CFLAGS="${SHOBJ_CFLAGS} -Wcall_shared" # default on TNS/E, needed on TNS/R
SHOBJ_LD=/usr/bin/ld # for TNS/R
;;
NSE*|NEO*)
SHOBJ_LD=/usr/bin/eld
;;
esac
SHOBJ_LDFLAGS='-shared -bglobalized -unres_symbols ignore'
;;
sunos4*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD=/usr/bin/ld
+579
View File
@@ -0,0 +1,579 @@
#! /bin/sh
#
# shobj-conf -- output a series of variable assignments to be substituted
# into a Makefile by configure which specify system-dependent
# information for creating shared objects that may be loaded
# into bash with `enable -f'
#
# usage: shobj-conf [-C compiler] -c host_cpu -o host_os -v host_vendor
#
# Chet Ramey
# chet@po.cwru.edu
# Copyright (C) 1996-2009 Free Software Foundation, Inc.
#
# This file is part of GNU Bash, the Bourne Again SHell.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# defaults
#
SHOBJ_STATUS=supported
SHLIB_STATUS=supported
SHOBJ_CC=cc
SHOBJ_CFLAGS=
SHOBJ_LD=
SHOBJ_LDFLAGS=
SHOBJ_XLDFLAGS=
SHOBJ_LIBS=
SHLIB_XLDFLAGS=
SHLIB_LIBS=
SHLIB_DOT='.'
SHLIB_LIBPREF='lib'
SHLIB_LIBSUFF='so'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF)'
SHLIB_DLLVERSION='$(SHLIB_MAJOR)'
PROGNAME=`basename $0`
USAGE="$PROGNAME [-C compiler] -c host_cpu -o host_os -v host_vendor"
while [ $# -gt 0 ]; do
case "$1" in
-C) shift; SHOBJ_CC="$1"; shift ;;
-c) shift; host_cpu="$1"; shift ;;
-o) shift; host_os="$1"; shift ;;
-v) shift; host_vendor="$1"; shift ;;
*) echo "$USAGE" >&2 ; exit 2;;
esac
done
case "${host_os}-${SHOBJ_CC}-${host_vendor}" in
sunos4*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD=/usr/bin/ld
SHOBJ_LDFLAGS='-assert pure-text'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
sunos4*)
SHOBJ_CFLAGS=-pic
SHOBJ_LD=/usr/bin/ld
SHOBJ_LDFLAGS='-assert pure-text'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
sunos5*-*gcc*|solaris2*-*gcc*)
SHOBJ_LD='${CC}'
ld_used=`gcc -print-prog-name=ld`
if ${ld_used} -V 2>&1 | grep GNU >/dev/null 2>&1; then
# This line works for the GNU ld
SHOBJ_LDFLAGS='-shared -Wl,-h,$@'
# http://sourceware.org/ml/binutils/2001-08/msg00361.html
SHOBJ_CFLAGS=-fPIC
else
# This line works for the Solaris linker in /usr/ccs/bin/ld
SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@'
SHOBJ_CFLAGS=-fpic
fi
# SHLIB_XLDFLAGS='-R $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sunos5*|solaris2*)
SHOBJ_CFLAGS='-K pic'
SHOBJ_LD=/usr/ccs/bin/ld
SHOBJ_LDFLAGS='-G -dy -z text -i -h $@'
# SHLIB_XLDFLAGS='-R $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
# All versions of Linux (including Gentoo/FreeBSD) or the semi-mythical GNU Hurd.
linux*-*|gnu*-*|k*bsd*-gnu-*|freebsd*-gentoo)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir) -Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
freebsd2*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-x -Bshareable'
SHLIB_XLDFLAGS='-R$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
# FreeBSD-3.x ELF
freebsd3*|freebsdaout*)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
else
SHOBJ_LDFLAGS='-shared'
SHLIB_XLDFLAGS='-R$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
fi
;;
# FreeBSD-4.x and later have only ELF
freebsd[4-9]*|freebsdelf*|dragonfly*)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
# Darwin/MacOS X
darwin[89]*|darwin10*)
SHOBJ_STATUS=supported
SHLIB_STATUS=supported
SHOBJ_CFLAGS='-fno-common'
SHOBJ_LD='MACOSX_DEPLOYMENT_TARGET=10.3 ${CC}'
SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)'
SHLIB_LIBSUFF='dylib'
SHOBJ_LDFLAGS='-dynamiclib -dynamic -undefined dynamic_lookup -arch_only `/usr/bin/arch`'
SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1
;;
darwin*|macosx*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=supported
SHOBJ_CFLAGS='-fno-common'
SHOBJ_LD='${CC}'
SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)'
SHLIB_LIBSUFF='dylib'
case "${host_os}" in
darwin[789]*|darwin10*) SHOBJ_LDFLAGS=''
SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
;;
*) SHOBJ_LDFLAGS='-dynamic'
SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
;;
esac
SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1
;;
openbsd*|netbsd*)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
SHLIB_XLDFLAGS='-R$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
bsdi2*)
SHOBJ_CC=shlicc2
SHOBJ_CFLAGS=
SHOBJ_LD=ld
SHOBJ_LDFLAGS=-r
SHOBJ_LIBS=-lc_s.2.1.0
# BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in
# the ass -- they require changing {/usr/lib,etc}/shlib.map on
# each system, and the library creation process is byzantine
SHLIB_STATUS=unsupported
;;
bsdi3*)
SHOBJ_CC=shlicc2
SHOBJ_CFLAGS=
SHOBJ_LD=ld
SHOBJ_LDFLAGS=-r
SHOBJ_LIBS=-lc_s.3.0.0
# BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in
# the ass -- they require changing {/usr/lib,etc}/shlib.map on
# each system, and the library creation process is byzantine
SHLIB_STATUS=unsupported
;;
bsdi4*)
# BSD/OS 4.x now supports ELF and SunOS-style dynamically-linked
# shared libraries. gcc 2.x is the standard compiler, and the
# `normal' gcc options should work as they do in Linux.
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
osf*-*gcc*)
# Fix to use gcc linker driver from bfischer@TechFak.Uni-Bielefeld.DE
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-rpath $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
osf*)
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-shared -soname $@ -expect_unresolved "*"'
SHLIB_XLDFLAGS='-rpath $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
aix4.[2-9]*-*gcc*|aix[5-9].*-*gcc*) # lightly tested by jik@cisco.com
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='ld'
SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
SHOBJ_XLDFLAGS='-G'
SHLIB_XLDFLAGS='-bM:SRE'
SHLIB_LIBS='-lcurses -lc'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
aix4.[2-9]*|aix[5-9].*)
SHOBJ_CFLAGS=-K
SHOBJ_LD='ld'
SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
SHOBJ_XLDFLAGS='-G'
SHLIB_XLDFLAGS='-bM:SRE'
SHLIB_LIBS='-lcurses -lc'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
#
# THE FOLLOWING ARE UNTESTED -- and some may not support the dlopen interface
#
irix[56]*-*gcc*)
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
irix[56]*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
# SHOBJ_LDFLAGS='-call_shared -hidden_symbol -no_unresolved -soname $@'
# Change from David Kaelbling <drk@sgi.com>. If you have problems,
# remove the `-no_unresolved'
SHOBJ_LDFLAGS='-shared -no_unresolved -soname $@'
SHLIB_XLDFLAGS='-rpath $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux9*-*gcc*)
# must use gcc; the bundled cc cannot compile PIC code
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s'
SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
SHLIB_LIBSUFF='sl'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux9*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
# If you are using the HP ANSI C compiler, you can uncomment and use
# this code (I have not tested it)
# SHOBJ_STATUS=supported
# SHLIB_STATUS=supported
#
# SHOBJ_CFLAGS='+z'
# SHOBJ_LD='ld'
# SHOBJ_LDFLAGS='-b +s'
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux10*-*gcc*)
# must use gcc; the bundled cc cannot compile PIC code
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
# if you have problems linking here, moving the `-Wl,+h,$@' from
# SHLIB_XLDFLAGS to SHOBJ_LDFLAGS has been reported to work
SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s'
SHLIB_XLDFLAGS='-Wl,+h,$@ -Wl,+b,$(libdir)'
SHLIB_LIBSUFF='sl'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux10*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
# If you are using the HP ANSI C compiler, you can uncomment and use
# this code (I have not tested it)
# SHOBJ_STATUS=supported
# SHLIB_STATUS=supported
#
# SHOBJ_CFLAGS='+z'
# SHOBJ_LD='ld'
# SHOBJ_LDFLAGS='-b +s +h $@'
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux11*-*gcc*)
# must use gcc; the bundled cc cannot compile PIC code
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
# SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,-B,symbolic -Wl,+s -Wl,+std -Wl,+h,$@'
SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s -Wl,+h,$@'
SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
SHLIB_LIBSUFF='sl'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux11*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
# If you are using the HP ANSI C compiler, you can uncomment and use
# this code (I have not tested it)
# SHOBJ_STATUS=supported
# SHLIB_STATUS=supported
#
# SHOBJ_CFLAGS='+z'
# SHOBJ_LD='ld'
# SHOBJ_LDFLAGS='-b +s +h $@'
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv4*-*gcc*)
SHOBJ_CFLAGS=-shared
SHOBJ_LDFLAGS='-shared -h $@'
SHOBJ_LD='${CC}'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv4*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-dy -z text -G -h $@'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sco3.2v5*-*gcc*)
SHOBJ_CFLAGS='-fpic' # DEFAULTS TO ELF
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sco3.2v5*)
SHOBJ_CFLAGS='-K pic -b elf'
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-G -b elf -dy -z text -h $@'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5uw7*-*gcc*)
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5uw7*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-G -dy -z text -h $@'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5UnixWare*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5UnixWare*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-G -dy -z text -h $@'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5OpenUNIX*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5OpenUNIX*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-G -dy -z text -h $@'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
dgux*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
dgux*)
SHOBJ_CFLAGS='-K pic'
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-G -dy -h $@'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
msdos*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
;;
cygwin*)
SHOBJ_LD='$(CC)'
SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
SHLIB_LIBPREF='cyg'
SHLIB_LIBSUFF='dll'
SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
SHLIB_LIBS='$(TERMCAP_LIB)'
SHLIB_DOT=
# For official cygwin releases, DLLVERSION will be defined in the
# environment of configure, and will be incremented any time the API
# changes in a non-backwards compatible manner. Otherwise, it is just
# SHLIB_MAJOR.
if [ -n "$DLLVERSION" ] ; then
SHLIB_DLLVERSION="$DLLVERSION"
fi
;;
mingw*)
SHOBJ_LD='$(CC)'
SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
SHLIB_LIBSUFF='dll'
SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
SHLIB_LIBS='$(TERMCAP_LIB)'
SHLIB_DOT=
# For official cygwin releases, DLLVERSION will be defined in the
# environment of configure, and will be incremented any time the API
# changes in a non-backwards compatible manner. Otherwise, it is just
# SHLIB_MAJOR.
if [ -n "$DLLVERSION" ] ; then
SHLIB_DLLVERSION="$DLLVERSION"
fi
;;
#
# Rely on correct gcc configuration for everything else
#
*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
;;
esac
echo SHOBJ_CC=\'"$SHOBJ_CC"\'
echo SHOBJ_CFLAGS=\'"$SHOBJ_CFLAGS"\'
echo SHOBJ_LD=\'"$SHOBJ_LD"\'
echo SHOBJ_LDFLAGS=\'"$SHOBJ_LDFLAGS"\'
echo SHOBJ_XLDFLAGS=\'"$SHOBJ_XLDFLAGS"\'
echo SHOBJ_LIBS=\'"$SHOBJ_LIBS"\'
echo SHLIB_XLDFLAGS=\'"$SHLIB_XLDFLAGS"\'
echo SHLIB_LIBS=\'"$SHLIB_LIBS"\'
echo SHLIB_DOT=\'"$SHLIB_DOT"\'
echo SHLIB_LIBPREF=\'"$SHLIB_LIBPREF"\'
echo SHLIB_LIBSUFF=\'"$SHLIB_LIBSUFF"\'
echo SHLIB_LIBVERSION=\'"$SHLIB_LIBVERSION"\'
echo SHLIB_DLLVERSION=\'"$SHLIB_DLLVERSION"\'
echo SHOBJ_STATUS=\'"$SHOBJ_STATUS"\'
echo SHLIB_STATUS=\'"$SHLIB_STATUS"\'
exit 0
+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
+9
View File
@@ -0,0 +1,9 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
export THIS_SH PATH
rm -f /tmp/xx
/bin/sh "$@"
+8
View File
@@ -170,3 +170,11 @@ a
val
val
no arg passed
hello
[0;31m\]
]
[hello
\[\e[0;31m\]
hello
eo
+2
View File
@@ -386,3 +386,5 @@ ${THIS_SH} ./exp2.sub
${THIS_SH} ./exp3.sub
${THIS_SH} ./exp4.sub
${THIS_SH} ./exp5.sub
+388
View File
@@ -0,0 +1,388 @@
#
# A suite of tests for bash word expansions
#
# This tests parameter and variable expansion, with an empahsis on
# proper quoting behavior.
#
# Chet Ramey
#
# If you comment out the body of this function, you can do a diff against
# `expansion-tests.right' to see if the shell is behaving correctly
#
expect()
{
echo expect "$@"
}
# Test the substitution quoting characters (CTLESC and CTLNUL) in different
# combinations
expect "<^A>"
recho `echo ''`
expect "<^A>"
recho `echo ""`
expect "<^B>"
recho `echo ''`
expect "<^B>"
recho `echo ""`
expect "<^A>"
recho `echo `
expect "<^B>"
recho `echo `
# Test null strings without variable expansion
expect "<abcdefgh>"
recho abcd""efgh
expect "<abcdefgh>"
recho abcd''efgh
expect "<abcdefgh>"
recho ""abcdefgh
expect "<abcdefgh>"
recho ''abcdefgh
expect "<abcd>"
recho abcd""
expect "<abcd>"
recho abcd''
# Test the quirky behavior of $@ in ""
expect nothing
recho "$@"
expect "< >"
recho " $@"
expect "<-->"
recho "-${@}-"
# Test null strings with variable expansion that fails
expect '<>'
recho $xxx""
expect '<>'
recho ""$xxx
expect '<>'
recho $xxx''
expect '<>'
recho ''$xxx
expect '<>'
recho $xxx""$yyy
expect '<>'
recho $xxx''$yyy
# Test null strings with variable expansion that succeeds
xxx=abc
yyy=def
expect '<abc>'
recho $xxx""
expect '<abc>'
recho ""$xxx
expect '<abc>'
recho $xxx''
expect '<abc>'
recho ''$xxx
expect '<abcdef>'
recho $xxx""$yyy
expect '<abcdef>'
recho $xxx''$yyy
unset xxx yyy
# Test the unquoted special quoting characters
expect "<^A>"
recho 
expect "<^B>"
recho 
expect "<^A>"
recho ""
expect "<^B>"
recho ""
expect "<^A>"
recho ''
expect "<^B>"
recho ''
# Test expansion of a variable that is unset
expect nothing
recho $xxx
expect '<>'
recho "$xxx"
expect nothing
recho "$xxx${@}"
# Test empty string expansion
expect '<>'
recho ""
expect '<>'
recho ''
# Test command substitution with (disabled) history substitution
expect '<Hello World!>'
# set +H
recho "`echo \"Hello world!\"`"
# Test some shell special characters
expect '<`>'
recho "\`"
expect '<">'
recho "\""
expect '<\^A>'
recho "\"
expect '<\$>'
recho "\\$"
expect '<\\>'
recho "\\\\"
# This should give argv[1] = a argv[2] = b
expect '<a> <b>'
FOO=`echo 'a b' | tr ' ' '\012'`
recho $FOO
# This should give argv[1] = ^A argv[2] = ^B
expect '<^A> <^B>'
FOO=`echo ' ' | tr ' ' '\012'`
recho $FOO
# Test quoted and unquoted globbing characters
expect '<**>'
recho "*"*
expect '<\.\./*/>'
recho "\.\./*/"
# Test patterns that come up when the shell quotes funny character
# combinations
expect '<^A^B^A^B>'
recho ''
expect '<^A^A>'
recho ''
expect '<^A^B>'
recho ''
expect '<^A^A^B>'
recho ''
# More tests of "$@"
set abc def ghi jkl
expect '< abc> <def> <ghi> <jkl >'
recho " $@ "
expect '< abc> <def> <ghi> <jkl >'
recho "${1+ $@ }"
set abc def ghi jkl
expect '<--abc> <def> <ghi> <jkl-->'
recho "--$@--"
set "a b" cd ef gh
expect '<a b> <cd> <ef> <gh>'
recho ${1+"$@"}
expect '<a b> <cd> <ef> <gh>'
recho ${foo:-"$@"}
expect '<a b> <cd> <ef> <gh>'
recho "${@}"
expect '< >'
recho " "
expect '< - >'
recho " - "
# Test combinations of different types of quoting in a fully-quoted string
# (so the WHOLLY_QUOTED tests fail and it doesn't get set)
expect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'
recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"
# Test the various Posix parameter expansions
expect '<foo bar>'
recho "${x:-$(echo "foo bar")}"
expect '<foo> <bar>'
recho ${x:-$(echo "foo bar")}
unset X
expect '<abc>'
recho ${X:=abc}
expect '<abc>'
recho $X
set a b c
expect '<posix>'
recho ${3:+posix}
POSIX=/usr/posix
expect '<10>'
recho ${#POSIX}
# remove shortest trailing match
x=file.c
expect '<file.o>'
recho ${x%.c}.o
# remove longest trailing match
x=posix/src/std
expect '<posix>'
recho ${x%%/*}
# remove shortest leading pattern
x=$HOME/src/cmd
expect '</src/cmd>'
recho ${x#$HOME}
# remove longest leading pattern
x=/one/two/three
expect '<three>'
recho ${x##*/}
# pattern removal of patterns that don't match
z=abcdef
expect '<abcdef>'
recho ${z#xyz}
expect '<abcdef>'
recho ${z##xyz}
expect '<abcdef>'
recho ${z%xyz}
expect '<abcdef>'
recho ${z%%xyz}
# Command substitution and the quirky differences between `` and $()
expect '<\$x>'
recho '\$x'
expect '<$x>'
recho `echo '\$x'`
expect '<\$x>'
recho $(echo '\$x')
# The difference between $* "$*" and "$@"
set "abc" "def ghi" "jkl"
expect '<abc> <def> <ghi> <jkl>'
recho $*
expect '<abc def ghi jkl>'
recho "$*"
OIFS="$IFS"
IFS=":$IFS"
# The special behavior of "$*", using the first character of $IFS as separator
expect '<abc:def ghi:jkl>'
recho "$*"
IFS="$OIFS"
expect '<abc> <def ghi> <jkl>'
recho "$@"
expect '<xxabc> <def ghi> <jklyy>'
recho "xx$@yy"
expect '<abc> <def ghi> <jklabc> <def ghi> <jkl>'
recho "$@$@"
foo=abc
bar=def
expect '<abcdef>'
recho "$foo""$bar"
unset foo
set $foo bar '' xyz "$foo" abc
expect '<bar> <> <xyz> <> <abc>'
recho "$@"
# More tests of quoting and deferred evaluation
foo=10 x=foo
y='$'$x
expect '<$foo>'
recho $y
eval y='$'$x
expect '<10>'
recho $y
# case statements
NL='
'
x='ab
cd'
expect '<newline expected>'
case "$x" in
*$NL*) recho "newline expected" ;;
esac
expect '<got it>'
case \? in
*"?"*) recho "got it" ;;
esac
expect '<got it>'
case \? in
*\?*) recho "got it" ;;
esac
set one two three four five
expect '<one> <three> <five>'
recho $1 $3 ${5} $8 ${9}
# length tests on positional parameters and some special parameters
expect '<5> <5>'
recho $# ${#}
expect '<3>'
recho ${#1}
expect '<1>'
recho ${##}
expect '<1>'
recho ${#?}
expect '<5>'
recho ${#@}
expect '<5>'
recho ${#*}
expect '<5>'
recho "${#@}"
expect '<5>'
recho "${#*}"
expect '<42>'
recho $((28 + 14))
expect '<26>'
recho $[ 13 * 2 ]
expect '<\>'
recho `echo \\\\`
expect '<~>'
recho '~'
expect nothing
recho $!
expect nothing
recho ${!}
# test word splitting of assignment statements not preceding a command
a="a b c d e"
declare b=$a
expect '<a> <b> <c> <d> <e>'
recho $b
a="a?b?c"
echo ${a//\\?/ }
echo ${a//\?/ }
${THIS_SH} ./exp1.sub
${THIS_SH} ./exp2.sub
${THIS_SH} ./exp3.sub
${THIS_SH} ./exp4.sub
+22
View File
@@ -0,0 +1,22 @@
# expansions involving patterns
var='[hello'
echo "${var//[/}"
red='\[\e[0;31m\]'
echo "${red//\\[\\e/}"
foo="${red//\\[\\e/}"
# foo == [0;31m\]
echo "${foo//[0;31m\\/}"
echo "${var//[]/}"
echo "${red//[]/}"
v=hello
foo='[:alpha:]'
echo ${v//[[:alpha:]]/}
echo ${v//[[:alpha]]/}
echo ${v//[[:alpha]/}
+20
View File
@@ -0,0 +1,20 @@
var='[hello'
echo "${var//[/}"
red='\[\e[0;31m\]'
echo "${red//\\[\\e/}"
foo="${red//\\[\\e/}"
# foo == [0;31m\]
echo "${foo//[0;31m\\/}"
echo "${var//[]/}"
echo "${red//[]/}"
v=hello
foo='[:alpha:]'
echo ${v//[[:alpha:]]/}
echo ${v//[[:alpha]]/}
echo ${v//[[:alpha]/}
+18
View File
@@ -72,3 +72,21 @@ a?b
ab
a/b
ab
argv[1] = <bc>
argv[1] = <bc>
argv[1] = <ab>
argv[1] = <ab>
argv[1] = <bc>
argv[1] = <bc>
argv[1] = <c>
argv[1] = <ab>
argv[1] = <ab>
argv[1] = <Oenophile>
argv[1] = <OEnOphIlE>
argv[1] = <>
argv[1] = <abc>
argv[1] = <''>
argv[1] = <>
good 1
good 2
good 3
+2
View File
@@ -47,3 +47,5 @@ var="a?b" ; echo "${var//\?/}"
var="a/b" ; echo "${var//\\//}"
var="a/b" ; echo "${var//\//}"
${THIS_SH} ./rhs-exp1.sub
+49
View File
@@ -0,0 +1,49 @@
selvecs='&m68kcoff_vec'
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'$selvecs\'}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="$selvecs"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\"$selvecs\"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\\$selvecs\\}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=$selvecs}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\$selvecs}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\$selvecs"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'"$null"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\\$selvecs"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\'$selvecs\'"}"
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'$selvecs\'}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="$selvecs"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\"$selvecs\"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\\$selvecs\\}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=$selvecs}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\$selvecs}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\$selvecs"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS='$selvecs'"$null"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\\$selvecs"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\'$selvecs\'"}
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\p"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\p}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\\"}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\\}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'}"
recho "TDEFAULTS = ${selvecs:+-DSELECT_VECS="\'"}"
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\p"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\p}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\\"}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\\}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS=\'}
recho TDEFAULTS = ${selvecs:+-DSELECT_VECS="\'"}
# more tests for bash-3.0 behavior
var="a*b" ; echo "${var//\\*/}"
var="a*b" ; echo "${var//\*/}"
var="a?b" ; echo "${var//\\?/}"
var="a?b" ; echo "${var//\?/}"
var="a/b" ; echo "${var//\\//}"
var="a/b" ; echo "${var//\//}"
+39
View File
@@ -0,0 +1,39 @@
# fixes for bugs in bash-4.2 regarding empty strings in expand_string_for_rhs
f=abc
recho ${f##""a}
recho ${f##"$v"a}
recho ${f%%""c}
recho ${f%%"$v"c}
recho ${f//""a}
recho ${f//"$v"a}
recho ${f/""a""b/}
recho ${f/""c/}
recho ${f/"$v"c/}
S2=oenophile
recho ${S2^"$v"[aeiou]}
recho ${S2^^"$v"[aeiou]}
recho ${foo:-""}
recho ${foo:-""abc}
recho "${foo:-''}"
recho "${foo:-}"
if [[ $var == "" ]]; then
echo good 1
fi
if [[ "$var"X == ""X ]]; then
echo good 2
fi
if [ "$var"X == ""X"" ]; then
echo good 3
fi
+20 -3
View File
@@ -3653,6 +3653,22 @@ n_shell_variables ()
return n;
}
int
chkexport (name)
char *name;
{
SHELL_VAR *v;
v = find_variable (name);
if (exported_p (v))
{
array_needs_making = 1;
maybe_make_export_env ();
return 1;
}
return 0;
}
void
maybe_make_export_env ()
{
@@ -4214,7 +4230,7 @@ static struct name_and_function special_vars[] = {
{ "TEXTDOMAIN", sv_locale },
{ "TEXTDOMAINDIR", sv_locale },
#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
#if defined (HAVE_TZSET)
{ "TZ", sv_tz },
#endif
@@ -4558,12 +4574,13 @@ sv_histtimefmt (name)
}
#endif /* HISTORY */
#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
#if defined (HAVE_TZSET)
void
sv_tz (name)
char *name;
{
tzset ();
if (chkexport (name))
tzset ();
}
#endif
+4809
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -313,6 +313,7 @@ extern void set_func_auto_export __P((const char *));
extern void sort_variables __P((SHELL_VAR **));
extern int chkexport __P((char *));
extern void maybe_make_export_env __P((void));
extern void update_export_env_inplace __P((char *, int, char *));
extern void put_command_name_into_env __P((char *));
+391
View File
@@ -0,0 +1,391 @@
/* variables.h -- data structures for shell variables. */
/* Copyright (C) 1987-2010 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined (_VARIABLES_H_)
#define _VARIABLES_H_
#include "stdc.h"
#include "array.h"
#include "assoc.h"
/* Shell variables and functions are stored in hash tables. */
#include "hashlib.h"
#include "conftypes.h"
/* A variable context. */
typedef struct var_context {
char *name; /* empty or NULL means global context */
int scope; /* 0 means global context */
int flags;
struct var_context *up; /* previous function calls */
struct var_context *down; /* down towards global context */
HASH_TABLE *table; /* variables at this scope */
} VAR_CONTEXT;
/* Flags for var_context->flags */
#define VC_HASLOCAL 0x01
#define VC_HASTMPVAR 0x02
#define VC_FUNCENV 0x04 /* also function if name != NULL */
#define VC_BLTNENV 0x08 /* builtin_env */
#define VC_TEMPENV 0x10 /* temporary_env */
#define VC_TEMPFLAGS (VC_FUNCENV|VC_BLTNENV|VC_TEMPENV)
/* Accessing macros */
#define vc_isfuncenv(vc) (((vc)->flags & VC_FUNCENV) != 0)
#define vc_isbltnenv(vc) (((vc)->flags & VC_BLTNENV) != 0)
#define vc_istempenv(vc) (((vc)->flags & (VC_TEMPFLAGS)) == VC_TEMPENV)
#define vc_istempscope(vc) (((vc)->flags & (VC_TEMPENV|VC_BLTNENV)) != 0)
#define vc_haslocals(vc) (((vc)->flags & VC_HASLOCAL) != 0)
#define vc_hastmpvars(vc) (((vc)->flags & VC_HASTMPVAR) != 0)
/* What a shell variable looks like. */
typedef struct variable *sh_var_value_func_t __P((struct variable *));
typedef struct variable *sh_var_assign_func_t __P((struct variable *, char *, arrayind_t, char *));
/* For the future */
union _value {
char *s; /* string value */
intmax_t i; /* int value */
COMMAND *f; /* function */
ARRAY *a; /* array */
HASH_TABLE *h; /* associative array */
double d; /* floating point number */
#if defined (HAVE_LONG_DOUBLE)
long double ld; /* long double */
#endif
struct variable *v; /* possible indirect variable use */
void *opaque; /* opaque data for future use */
};
typedef struct variable {
char *name; /* Symbol that the user types. */
char *value; /* Value that is returned. */
char *exportstr; /* String for the environment. */
sh_var_value_func_t *dynamic_value; /* Function called to return a `dynamic'
value for a variable, like $SECONDS
or $RANDOM. */
sh_var_assign_func_t *assign_func; /* Function called when this `special
variable' is assigned a value in
bind_variable. */
int attributes; /* export, readonly, array, invisible... */
int context; /* Which context this variable belongs to. */
} SHELL_VAR;
typedef struct _vlist {
SHELL_VAR **list;
int list_size; /* allocated size */
int list_len; /* current number of entries */
} VARLIST;
/* The various attributes that a given variable can have. */
/* First, the user-visible attributes */
#define att_exported 0x0000001 /* export to environment */
#define att_readonly 0x0000002 /* cannot change */
#define att_array 0x0000004 /* value is an array */
#define att_function 0x0000008 /* value is a function */
#define att_integer 0x0000010 /* internal representation is int */
#define att_local 0x0000020 /* variable is local to a function */
#define att_assoc 0x0000040 /* variable is an associative array */
#define att_trace 0x0000080 /* function is traced with DEBUG trap */
#define att_uppercase 0x0000100 /* word converted to uppercase on assignment */
#define att_lowercase 0x0000200 /* word converted to lowercase on assignment */
#define att_capcase 0x0000400 /* word capitalized on assignment */
#define user_attrs (att_exported|att_readonly|att_integer|att_local|att_trace|att_uppercase|att_lowercase|att_capcase)
#define attmask_user 0x0000fff
/* Internal attributes used for bookkeeping */
#define att_invisible 0x0001000 /* cannot see */
#define att_nounset 0x0002000 /* cannot unset */
#define att_noassign 0x0004000 /* assignment not allowed */
#define att_imported 0x0008000 /* came from environment */
#define att_special 0x0010000 /* requires special handling */
#define att_nofree 0x0020000 /* do not free value on unset */
#define attmask_int 0x00ff000
/* Internal attributes used for variable scoping. */
#define att_tempvar 0x0100000 /* variable came from the temp environment */
#define att_propagate 0x0200000 /* propagate to previous scope */
#define attmask_scope 0x0f00000
#define exported_p(var) ((((var)->attributes) & (att_exported)))
#define readonly_p(var) ((((var)->attributes) & (att_readonly)))
#define array_p(var) ((((var)->attributes) & (att_array)))
#define function_p(var) ((((var)->attributes) & (att_function)))
#define integer_p(var) ((((var)->attributes) & (att_integer)))
#define local_p(var) ((((var)->attributes) & (att_local)))
#define assoc_p(var) ((((var)->attributes) & (att_assoc)))
#define trace_p(var) ((((var)->attributes) & (att_trace)))
#define uppercase_p(var) ((((var)->attributes) & (att_uppercase)))
#define lowercase_p(var) ((((var)->attributes) & (att_lowercase)))
#define capcase_p(var) ((((var)->attributes) & (att_capcase)))
#define invisible_p(var) ((((var)->attributes) & (att_invisible)))
#define non_unsettable_p(var) ((((var)->attributes) & (att_nounset)))
#define noassign_p(var) ((((var)->attributes) & (att_noassign)))
#define imported_p(var) ((((var)->attributes) & (att_imported)))
#define specialvar_p(var) ((((var)->attributes) & (att_special)))
#define nofree_p(var) ((((var)->attributes) & (att_nofree)))
#define tempvar_p(var) ((((var)->attributes) & (att_tempvar)))
/* Acessing variable values: rvalues */
#define value_cell(var) ((var)->value)
#define function_cell(var) (COMMAND *)((var)->value)
#define array_cell(var) (ARRAY *)((var)->value)
#define assoc_cell(var) (HASH_TABLE *)((var)->value)
#define var_isnull(var) ((var)->value == 0)
#define var_isset(var) ((var)->value != 0)
/* Assigning variable values: lvalues */
#define var_setvalue(var, str) ((var)->value = (str))
#define var_setfunc(var, func) ((var)->value = (char *)(func))
#define var_setarray(var, arr) ((var)->value = (char *)(arr))
#define var_setassoc(var, arr) ((var)->value = (char *)(arr))
/* Make VAR be auto-exported. */
#define set_auto_export(var) \
do { (var)->attributes |= att_exported; array_needs_making = 1; } while (0)
#define SETVARATTR(var, attr, undo) \
((undo == 0) ? ((var)->attributes |= (attr)) \
: ((var)->attributes &= ~(attr)))
#define VSETATTR(var, attr) ((var)->attributes |= (attr))
#define VUNSETATTR(var, attr) ((var)->attributes &= ~(attr))
#define VGETFLAGS(var) ((var)->attributes)
#define VSETFLAGS(var, flags) ((var)->attributes = (flags))
#define VCLRFLAGS(var) ((var)->attributes = 0)
/* Macros to perform various operations on `exportstr' member of a SHELL_VAR. */
#define CLEAR_EXPORTSTR(var) (var)->exportstr = (char *)NULL
#define COPY_EXPORTSTR(var) ((var)->exportstr) ? savestring ((var)->exportstr) : (char *)NULL
#define SET_EXPORTSTR(var, value) (var)->exportstr = (value)
#define SAVE_EXPORTSTR(var, value) (var)->exportstr = (value) ? savestring (value) : (char *)NULL
#define FREE_EXPORTSTR(var) \
do { if ((var)->exportstr) free ((var)->exportstr); } while (0)
#define CACHE_IMPORTSTR(var, value) \
(var)->exportstr = savestring (value)
#define INVALIDATE_EXPORTSTR(var) \
do { \
if ((var)->exportstr) \
{ \
free ((var)->exportstr); \
(var)->exportstr = (char *)NULL; \
} \
} while (0)
/* Stuff for hacking variables. */
typedef int sh_var_map_func_t __P((SHELL_VAR *));
/* Where we keep the variables and functions */
extern VAR_CONTEXT *global_variables;
extern VAR_CONTEXT *shell_variables;
extern HASH_TABLE *shell_functions;
extern HASH_TABLE *temporary_env;
extern int variable_context;
extern char *dollar_vars[];
extern char **export_env;
extern void initialize_shell_variables __P((char **, int));
extern SHELL_VAR *set_if_not __P((char *, char *));
extern void sh_set_lines_and_columns __P((int, int));
extern void set_pwd __P((void));
extern void set_ppid __P((void));
extern void make_funcname_visible __P((int));
extern SHELL_VAR *var_lookup __P((const char *, VAR_CONTEXT *));
extern SHELL_VAR *find_function __P((const char *));
extern FUNCTION_DEF *find_function_def __P((const char *));
extern SHELL_VAR *find_variable __P((const char *));
extern SHELL_VAR *find_variable_internal __P((const char *, int));
extern SHELL_VAR *find_tempenv_variable __P((const char *));
extern SHELL_VAR *find_global_variable __P((const char *));
extern SHELL_VAR *copy_variable __P((SHELL_VAR *));
extern SHELL_VAR *make_local_variable __P((const char *));
extern SHELL_VAR *bind_variable __P((const char *, char *, int));
extern SHELL_VAR *bind_function __P((const char *, COMMAND *));
extern void bind_function_def __P((const char *, FUNCTION_DEF *));
extern SHELL_VAR **map_over __P((sh_var_map_func_t *, VAR_CONTEXT *));
SHELL_VAR **map_over_funcs __P((sh_var_map_func_t *));
extern SHELL_VAR **all_shell_variables __P((void));
extern SHELL_VAR **all_shell_functions __P((void));
extern SHELL_VAR **all_visible_variables __P((void));
extern SHELL_VAR **all_visible_functions __P((void));
extern SHELL_VAR **all_exported_variables __P((void));
extern SHELL_VAR **local_exported_variables __P((void));
extern SHELL_VAR **all_local_variables __P((void));
#if defined (ARRAY_VARS)
extern SHELL_VAR **all_array_variables __P((void));
#endif
extern char **all_variables_matching_prefix __P((const char *));
extern char **make_var_array __P((HASH_TABLE *));
extern char **add_or_supercede_exported_var __P((char *, int));
extern char *get_variable_value __P((SHELL_VAR *));
extern char *get_string_value __P((const char *));
extern char *sh_get_env_value __P((const char *));
extern char *make_variable_value __P((SHELL_VAR *, char *, int));
extern SHELL_VAR *bind_variable_value __P((SHELL_VAR *, char *, int));
extern SHELL_VAR *bind_int_variable __P((char *, char *));
extern SHELL_VAR *bind_var_to_int __P((char *, intmax_t));
extern int assign_in_env __P((WORD_DESC *, int));
extern int unbind_variable __P((const char *));
extern int unbind_func __P((const char *));
extern int unbind_function_def __P((const char *));
extern int makunbound __P((const char *, VAR_CONTEXT *));
extern int kill_local_variable __P((const char *));
extern void delete_all_variables __P((HASH_TABLE *));
extern void delete_all_contexts __P((VAR_CONTEXT *));
extern VAR_CONTEXT *new_var_context __P((char *, int));
extern void dispose_var_context __P((VAR_CONTEXT *));
extern VAR_CONTEXT *push_var_context __P((char *, int, HASH_TABLE *));
extern void pop_var_context __P((void));
extern VAR_CONTEXT *push_scope __P((int, HASH_TABLE *));
extern void pop_scope __P((int));
extern void push_context __P((char *, int, HASH_TABLE *));
extern void pop_context __P((void));
extern void push_dollar_vars __P((void));
extern void pop_dollar_vars __P((void));
extern void dispose_saved_dollar_vars __P((void));
extern void push_args __P((WORD_LIST *));
extern void pop_args __P((void));
extern void adjust_shell_level __P((int));
extern void non_unsettable __P((char *));
extern void dispose_variable __P((SHELL_VAR *));
extern void dispose_used_env_vars __P((void));
extern void dispose_function_env __P((void));
extern void dispose_builtin_env __P((void));
extern void merge_temporary_env __P((void));
extern void merge_builtin_env __P((void));
extern void kill_all_local_variables __P((void));
extern void set_var_read_only __P((char *));
extern void set_func_read_only __P((const char *));
extern void set_var_auto_export __P((char *));
extern void set_func_auto_export __P((const char *));
extern void sort_variables __P((SHELL_VAR **));
extern void chkexport __P((char *));
extern void maybe_make_export_env __P((void));
extern void update_export_env_inplace __P((char *, int, char *));
extern void put_command_name_into_env __P((char *));
extern void put_gnu_argv_flags_into_env __P((intmax_t, char *));
extern void print_var_list __P((SHELL_VAR **));
extern void print_func_list __P((SHELL_VAR **));
extern void print_assignment __P((SHELL_VAR *));
extern void print_var_value __P((SHELL_VAR *, int));
extern void print_var_function __P((SHELL_VAR *));
#if defined (ARRAY_VARS)
extern SHELL_VAR *make_new_array_variable __P((char *));
extern SHELL_VAR *make_local_array_variable __P((char *));
extern SHELL_VAR *make_new_assoc_variable __P((char *));
extern SHELL_VAR *make_local_assoc_variable __P((char *));
extern void set_pipestatus_array __P((int *, int));
extern ARRAY *save_pipestatus_array __P((void));
extern void restore_pipestatus_array __P((ARRAY *));
#endif
extern void set_pipestatus_from_exit __P((int));
/* The variable in NAME has just had its state changed. Check to see if it
is one of the special ones where something special happens. */
extern void stupidly_hack_special_variables __P((char *));
/* Reinitialize some special variables that have external effects upon unset
when the shell reinitializes itself. */
extern void reinit_special_variables __P((void));
extern int get_random_number __P((void));
/* The `special variable' functions that get called when a particular
variable is set. */
extern void sv_ifs __P((char *));
extern void sv_path __P((char *));
extern void sv_mail __P((char *));
extern void sv_funcnest __P((char *));
extern void sv_globignore __P((char *));
extern void sv_ignoreeof __P((char *));
extern void sv_strict_posix __P((char *));
extern void sv_optind __P((char *));
extern void sv_opterr __P((char *));
extern void sv_locale __P((char *));
extern void sv_xtracefd __P((char *));
#if defined (READLINE)
extern void sv_comp_wordbreaks __P((char *));
extern void sv_terminal __P((char *));
extern void sv_hostfile __P((char *));
extern void sv_winsize __P((char *));
#endif
#if defined (__CYGWIN__)
extern void sv_home __P((char *));
#endif
#if defined (HISTORY)
extern void sv_histsize __P((char *));
extern void sv_histignore __P((char *));
extern void sv_history_control __P((char *));
# if defined (BANG_HISTORY)
extern void sv_histchars __P((char *));
# endif
extern void sv_histtimefmt __P((char *));
#endif /* HISTORY */
#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
extern void sv_tz __P((char *));
#endif
#endif /* !_VARIABLES_H_ */