commit bash-20090512 snapshot

This commit is contained in:
Chet Ramey
2011-12-08 20:09:39 -05:00
parent 12ae1612a6
commit 94a5513e66
36 changed files with 6647 additions and 23 deletions
+41
View File
@@ -8072,3 +8072,44 @@ subst.c
consensus of the austin group, though it is not historical practice.
Message from Geoff Clare <20090505091501.GA10097@squonk.masqnet> of
5 May 2009 to austin-group list
5/20
----
lib/glob/glob.c
- tentative fix to glob_filename to compensate for glob_vector putting
null pathname at front of result vector when dflags&GX_NULLDIR.
Current fix manually removes empty string element from front of
result vector; a better fix would be to use a flag so glob_vector
doesn't add it at all. Augments patch from 4/28, which appears to
have broken some things. Fixes bug reported by Matt Zyzik
<matt.zyzik@nyu.edu>
5/22
----
lib/glob/glob.c
- better fix for glob_filename; supersedes patch of 5/20. Now the
code does not set GX_ADDCURDIR if directory_len == 0 and the
function has not been called recursively ((flags & GX_ALLDIRS) == 0).
Better fix for bug reported by Matt Zyzik <matt.zyzik@nyu.edu>
Makefile.in
- fix build race condition that occurs in some makes caused by
libreadline.a and libhistory.a containing some of the same files
(e.g., xmalloc.o) and conflicting when trying to build both at
the same time. Reported by Mike Frysinger <vapier@gentoo.org>
5/25
----
lib/readline/vi_mode.c
- fix _rl_vi_initialize_line so that the loop counter is not
unsigned (it doesn't matter, but it eliminates a compiler warning).
Bug reported by Dave Caroline <dave.thearchivist@gmail.com>
5/26
----
doc/{bash.1,bashref.texi}
- add text to the description of array variables making it clear
that an array variable is not considered set until a subscript
has been assigned a value
+34
View File
@@ -8054,6 +8054,7 @@ lib/readline/display.c
locale or not, or whether there are invisible chars in the prompt)
- in _rl_move_cursor_relative, go ahead and adjust dpos if
prompt_physical_chars >= _rl_screenwidth (previous check was just > )
Fixes bug reported by Andreas Schwab <schwab@linux-m68k.org>
4/28
----
@@ -8071,3 +8072,36 @@ subst.c
consensus of the austin group, though it is not historical practice.
Message from Geoff Clare <20090505091501.GA10097@squonk.masqnet> of
5 May 2009 to austin-group list
5/20
----
lib/glob/glob.c
- tentative fix to glob_filename to compensate for glob_vector putting
null pathname at front of result vector when dflags&GX_NULLDIR.
Current fix manually removes empty string element from front of
result vector; a better fix would be to use a flag so glob_vector
doesn't add it at all. Augments patch from 4/28, which appears to
have broken some things. Fixes bug reported by Matt Zyzik
<matt.zyzik@nyu.edu>
5/22
----
lib/glob/glob.c
- better fix for glob_filename; supersedes patch of 5/20. Now the
code does not set GX_ADDCURDIR if directory_len == 0 and the
function has not been called recursively ((flags & GX_ALLDIRS) == 0).
Better fix for bug reported by Matt Zyzik <matt.zyzik@nyu.edu>
Makefile.in
- fix build race condition that occurs in some makes caused by
libreadline.a and libhistory.a containing some of the same files
(e.g., xmalloc.o) and conflicting when trying to build both at
the same time. Reported by Mike Frysinger <vapier@gentoo.org>
5/25
----
lib/readline/vi_mode.c
- fix _rl_vi_initialize_line so that the loop counter is not
unsigned (it doesn't matter, but it eliminates a compiler warning).
Bug reported by Dave Caroline <dave.thearchivist@gmail.com>
+5 -1
View File
@@ -808,6 +808,7 @@ tests/dollar-star1.sub f
tests/dollar-star2.sub f
tests/dollar-star3.sub f
tests/dollar-star4.sub f
tests/dollar-star5.sub f
tests/dollar.right f
tests/dstack.tests f
tests/dstack.right f
@@ -850,9 +851,11 @@ tests/getopts4.sub f
tests/getopts5.sub f
tests/getopts6.sub f
tests/getopts7.sub f
tests/glob-test f
tests/glob.tests f
tests/glob1.sub f
tests/glob.right f
tests/globstar.tests f
tests/globstar.right f
tests/heredoc.tests f
tests/heredoc.right f
tests/heredoc1.sub f
@@ -981,6 +984,7 @@ tests/run-extglob3 f
tests/run-func f
tests/run-getopts f
tests/run-glob-test f
tests/run-globstar f
tests/run-heredoc f
tests/run-herestr f
tests/run-histexpand f
+6
View File
@@ -483,6 +483,8 @@ po/es.gmo f
po/es.po f
po/et.gmo f
po/et.po f
po/fi.gmo f
po/fi.po f
po/fr.gmo f
po/fr.po f
po/hu.gmo f
@@ -806,6 +808,7 @@ tests/dollar-star1.sub f
tests/dollar-star2.sub f
tests/dollar-star3.sub f
tests/dollar-star4.sub f
tests/dollar-star5.sub f
tests/dollar.right f
tests/dstack.tests f
tests/dstack.right f
@@ -851,6 +854,8 @@ tests/getopts7.sub f
tests/glob-test f
tests/glob1.sub f
tests/glob.right f
tests/globstar.tests f
tests/globstar.right f
tests/heredoc.tests f
tests/heredoc.right f
tests/heredoc1.sub f
@@ -979,6 +984,7 @@ tests/run-extglob3 f
tests/run-func f
tests/run-getopts f
tests/run-glob-test f
tests/run-globstar f
tests/run-heredoc f
tests/run-herestr f
tests/run-histexpand f
+1 -1
View File
@@ -595,7 +595,7 @@ $(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
@( { test "${RL_LIBDIR}" = "${libdir}" && exit 0; } || \
cd ${RL_LIBDIR} && $(MAKE) $(MFLAGS) libreadline.a) || exit 1
$(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE)
$(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE) $(READLINE_DEP)
@echo making $@ in ${HIST_LIBDIR}
@( { test "${HIST_LIBDIR}" = "${libdir}" && exit 0; } || \
cd ${HIST_LIBDIR} && $(MAKE) $(MFLAGS) libhistory.a) || exit 1
+1 -1
View File
@@ -213,7 +213,7 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/zgetline.c ${SH_LIBSRC}/mbscmp.c \
${SH_LIBSRC}/casemod.c ${SH_LIBSRC}/uconvert.c \
${SH_LIBSRC}/ufuncs.c ${SH_LIBSRC}/fdprintf.c \
${SH_LIBSRC}/input_avail.c
${SH_LIBSRC}/input_avail.c ${SH_LIBSRC}/mbscasecmp.c
SHLIB_LIB = -lsh
SHLIB_LIBNAME = libsh.a
+5 -2
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Wed Mar 4 15:55:47 EST 2009
.\" Last Change: Tue May 26 17:03:43 EDT 2009
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2009 March 4" "GNU Bash-4.0"
.TH BASH 1 "2009 May 26" "GNU Bash-4.0"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -2236,6 +2236,9 @@ ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
Referencing an array variable without a subscript is equivalent to
referencing the array with a subscript of 0.
.PP
An array variable is considered set if a subscript has been assigned a
value. The null string is a valid value.
.PP
The
.B unset
builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
+5 -2
View File
@@ -2236,12 +2236,15 @@ ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
Referencing an array variable without a subscript is equivalent to
referencing the array with a subscript of 0.
.PP
An array variable is considered set if a subscript has been assigned a
value. The null string is a valid value.
.PP
The
.B unset
builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
destroys the array element at index \fIsubscript\fP.
Care must be taken to avoid unwanted side effects caused by filename
generation.
Care must be taken to avoid unwanted side effects caused by pathname
expansion.
\fBunset\fP \fIname\fP, where \fIname\fP is an array, or
\fBunset\fP \fIname\fP[\fIsubscript\fP], where
\fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
+3
View File
@@ -6035,6 +6035,9 @@ If @var{subscript} is @samp{@@} or
Referencing an array variable without a subscript is equivalent to
referencing with a subscript of 0.
An array variable is considered set if a subscript has been assigned a
value. The null string is a valid value.
The @code{unset} builtin is used to destroy arrays.
@code{unset} @var{name}[@var{subscript}]
destroys the array element at index @var{subscript}.
+1 -1
View File
@@ -1461,7 +1461,7 @@ bash$ echo a@{d,c,b@}e
ade ace abe
@end example
A sequence expression takes the form @code{@{@var{x}..@var{y}[@var{incr}]@}},
A sequence expression takes the form @code{@{@var{x}..@var{y}[..@var{incr}]@}},
where @var{x} and @var{y} are either integers or single characters,
and @var{incr}, an optional increment, is an integer.
When integers are supplied, the expression expands to each number between
+3 -3
View File
@@ -2,9 +2,9 @@
Copyright (C) 1988-2009 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Wed Mar 4 15:56:07 EST 2009
@set LASTCHANGE Tue May 26 17:04:05 EDT 2009
@set EDITION 4.0
@set VERSION 4.0
@set UPDATED 4 March 2009
@set UPDATED-MONTH March 2009
@set UPDATED 26 May 2009
@set UPDATED-MONTH May 2009
+10
View File
@@ -0,0 +1,10 @@
@ignore
Copyright (C) 1988-2009 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Wed Mar 4 15:56:07 EST 2009
@set EDITION 4.0
@set VERSION 4.0
@set UPDATED 4 March 2009
@set UPDATED-MONTH March 2009
+22 -5
View File
@@ -665,9 +665,10 @@ glob_vector (pat, dir, flags)
(void) closedir (d);
}
/* compat: if GX_ALLDIRS, add the passed directory also, but don't add an
empty directory name. */
if (add_current && (flags & GX_NULLDIR) == 0)
/* compat: if GX_ADDCURDIR, add the passed directory also. Add an empty
directory name as a placeholder if GX_NULLDIR (in which case the passed
directory name is "."). */
if (add_current)
{
sdlen = strlen (dir);
nextname = (char *)malloc (sdlen + 1);
@@ -679,7 +680,10 @@ glob_vector (pat, dir, flags)
nextlink->name = nextname;
nextlink->next = lastlink;
lastlink = nextlink;
bcopy (dir, nextname, sdlen + 1);
if (flags & GX_NULLDIR)
nextname[0] = '\0';
else
bcopy (dir, nextname, sdlen + 1);
++count;
}
}
@@ -1007,11 +1011,24 @@ glob_filename (pathname, flags)
/* Just return what glob_vector () returns appended to the
directory name. */
/* If flags & GX_ALLDIRS, we're called recursively */
dflags = flags & ~GX_MARKDIRS;
if (directory_len == 0)
dflags |= GX_NULLDIR;
if ((flags & GX_GLOBSTAR) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
dflags |= GX_ALLDIRS|GX_ADDCURDIR;
{
dflags |= GX_ALLDIRS|GX_ADDCURDIR;
#if 0
/* If we want all directories (dflags & GX_ALLDIRS) and we're not
being called recursively as something like `echo **/*.o'
((flags & GX_ALLDIRS) == 0), we want to prevent glob_vector from
adding a null directory name to the front of the temp_results
array. We turn off ADDCURDIR if not called recursively and
dlen == 0 */
#endif
if (directory_len == 0 && (flags & GX_ALLDIRS) == 0)
dflags &= ~GX_ADDCURDIR;
}
temp_results = glob_vector (filename,
(directory_len == 0 ? "." : directory_name),
dflags);
+1073
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1089
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -131,9 +131,10 @@ static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *));
void
_rl_vi_initialize_line ()
{
register int i;
register int i, n;
for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++)
n = sizeof (vi_mark_chars) / sizeof (vi_mark_chars[0]);
for (i = 0; i < n; i++)
vi_mark_chars[i] = -1;
RL_UNSETSTATE(RL_STATE_VICMDONCE);
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
#define PATCHLEVEL 17
#define PATCHLEVEL 24
#endif /* _PATCHLEVEL_H_ */
+30
View File
@@ -0,0 +1,30 @@
/* patchlevel.h -- current bash patch level */
/* Copyright (C) 2001-2009 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 (_PATCHLEVEL_H_)
#define _PATCHLEVEL_H_
/* It's important that there be no other strings in this file that match the
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
#define PATCHLEVEL 17
#endif /* _PATCHLEVEL_H_ */
+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
+3
View File
@@ -232,4 +232,7 @@ ${THIS_SH} ./dollar-at3.sub
# test for set -u and expansions of $* when there are no positional parameters
${THIS_SH} ./dollar-star4.sub
# tests for expansions of $* when IFS is null
${THIS_SH} ./dollar-star5.sub
exit 0
+235
View File
@@ -0,0 +1,235 @@
# first, let's start with the basics
recho "$@"
recho "$*"
recho $@
recho $*
set a b
recho "$*"
# If IFS is null, the parameters are joined without separators
IFS=''
recho "$*"
# If IFS is unset, the parameters are separated by spaces
unset IFS
recho "${*}"
recho "$@"
recho $@
IFS='/'
set bob 'tom dick harry' joe
set $*
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set ${*}
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set $@
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set ${@}
recho $#
recho $1
recho $2
recho $3
# according to POSIX.2, unquoted $* should expand to multiple words if
# $IFS is null, just like unquoted $@
IFS=''
set bob 'tom dick harry' joe
set $*
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set $@
recho $#
recho $1
recho $2
recho $3
# if IFS is unset, the individual positional parameters are split on
# " \t\n" if $* or $@ are unquoted
unset IFS
set bob 'tom dick harry' joe
set $*
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set $@
recho $#
recho $1
recho $2
recho $3
# but not for "$@" or "$*"
set bob 'tom dick harry' joe
set "$*"
recho $#
recho $1
recho $2
recho $3
set bob 'tom dick harry' joe
set "$@"
recho $#
recho $1
recho $2
recho $3
# POSIX.2 says these should both expand the positional parameters
# to multiple words
set a b c d e
IFS=""
recho $@
recho "$@"
# this example is straight from the POSIX.2 rationale
set foo bar bam
recho "$@"
recho "$*"
unset IFS
recho "$@"
recho $@
recho "$*"
IFS=:
# special variables
set -- 1 2 3 4 5 6 7 8 9 10
bar=${*}
foo=$*
echo foo = "$foo"
echo bar = "$bar"
foo1=$@
bar1=${@}
echo foo1 = "$foo1"
echo bar1 = "$bar1"
foo2="$*"
bar2="${*}"
echo foo2 = "$foo2"
echo bar2 = "$bar2"
eval foo3='$*' bar3='${*}'
echo foo3 = "$foo3"
echo bar3 = "$bar3"
case $* in
*\:*) echo ok 1;;
*) echo bad 1;;
esac
case $@ in
*\:*) echo bad 2;;
*) echo ok 2;;
esac
case "$*" in
*\:*) echo ok 3;;
*) echo bad 3;;
esac
case "$@" in
*\:*) echo bad 4;;
*) echo ok 4;;
esac
IFS=$' \t\n'
bar=${*}
foo=$*
echo foo = "$foo"
echo bar = "$bar"
foo1=$@
bar1=${@}
echo foo1 = "$foo1"
echo bar1 = "$bar1"
foo2="$*"
bar2="${*}"
echo foo2 = "$foo2"
echo bar2 = "$bar2"
eval foo3='$*' bar3='${*}'
echo foo3 = "$foo3"
echo bar3 = "$bar3"
case $* in
*\ *) echo ok 1;;
*) echo bad 1;;
esac
case $@ in
*\ *) echo ok 2;;
*) echo bad 2;;
esac
case "$*" in
*\ *) echo ok 3;;
*) echo bad 3;;
esac
case "$@" in
*\ *) echo ok 4;;
*) echo bad 4;;
esac
# tests for special expansion of "$*" and "${array[*]}" when used with other
# 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
# tests for expansion of other variables in double-quoted strings containing
# $@. Bugs through bash-2.05b
${THIS_SH} ./dollar-at2.sub
# tests for various expansions of $* in different contexts -- word split,
# no splitting, etc. when $IFS is NUL
${THIS_SH} ./dollar-star2.sub
# tests for expansions of "${array[*]}" and "${array[@]}" when $IFS is not the
# default and the array contains null elements
${THIS_SH} ./dollar-star3.sub
# test for set -u and expansions of $@ when there are no positional parameters
${THIS_SH} ./dollar-at3.sub
# test for set -u and expansions of $* when there are no positional parameters
${THIS_SH} ./dollar-star4.sub
exit 0
+16
View File
@@ -0,0 +1,16 @@
set -- a b
IFS=
echo $*
echo "$*"
a=abcd
echo "${a#$*}"
case ab in
$*) echo ok 1;;
esac
case $* in
ab) echo ok 2 ;;
esac
+5
View File
@@ -155,3 +155,8 @@ bar
0
bar
./dollar-star4.sub: line 6: *: unbound variable
a b
ab
cd
ok 1
ok 2
+157
View File
@@ -0,0 +1,157 @@
argv[1] = <>
argv[1] = <a b>
argv[1] = <ab>
argv[1] = <a b>
argv[1] = <a>
argv[2] = <b>
argv[1] = <a>
argv[2] = <b>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom dick harry>
argv[1] = <joe>
argv[1] = <5>
argv[1] = <bob>
argv[1] = <tom>
argv[1] = <dick>
argv[1] = <5>
argv[1] = <bob>
argv[1] = <tom>
argv[1] = <dick>
argv[1] = <1>
argv[1] = <bob>
argv[2] = <tom>
argv[3] = <dick>
argv[4] = <harry>
argv[5] = <joe>
argv[1] = <3>
argv[1] = <bob>
argv[1] = <tom>
argv[2] = <dick>
argv[3] = <harry>
argv[1] = <joe>
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[1] = <a>
argv[2] = <b>
argv[3] = <c>
argv[4] = <d>
argv[5] = <e>
argv[1] = <foo>
argv[2] = <bar>
argv[3] = <bam>
argv[1] = <foobarbam>
argv[1] = <foo>
argv[2] = <bar>
argv[3] = <bam>
argv[1] = <foo>
argv[2] = <bar>
argv[3] = <bam>
argv[1] = <foo bar bam>
foo = 1:2:3:4:5:6:7:8:9:10
bar = 1:2:3:4:5:6:7:8:9:10
foo1 = 1 2 3 4 5 6 7 8 9 10
bar1 = 1 2 3 4 5 6 7 8 9 10
foo2 = 1:2:3:4:5:6:7:8:9:10
bar2 = 1:2:3:4:5:6:7:8:9:10
foo3 = 1:2:3:4:5:6:7:8:9:10
bar3 = 1:2:3:4:5:6:7:8:9:10
ok 1
ok 2
ok 3
ok 4
foo = 1 2 3 4 5 6 7 8 9 10
bar = 1 2 3 4 5 6 7 8 9 10
foo1 = 1 2 3 4 5 6 7 8 9 10
bar1 = 1 2 3 4 5 6 7 8 9 10
foo2 = 1 2 3 4 5 6 7 8 9 10
bar2 = 1 2 3 4 5 6 7 8 9 10
foo3 = 1 2 3 4 5 6 7 8 9 10
bar3 = 1 2 3 4 5 6 7 8 9 10
ok 1
ok 2
ok 3
ok 4
xa|xb|xc
xa|xb|xc
a|b|c
a|b|c
a b c
a b c
xa xb xc
xa xb xc
a|b
b|c
a b
b c
a|b|c
a|b|c
xa|xb|xc
xa|xb|xc
3
3
3
3
3
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>
argv[1] = <AB>
argv[1] = <AB>
argv[1] = <A BC D>
argv[1] = <A BC D>
argv[1] = <A BC D>
argv[1] = <A B>
argv[2] = <C D>
argv[1] = <A BC D>
argv[1] = <A BC D>
argv[1] = <fooq//barq/>
argv[1] = <fooq>
argv[2] = <>
argv[3] = <barq>
argv[4] = <>
argv[1] = <foo!//bar!/>
argv[1] = <foo!>
argv[2] = <>
argv[3] = <bar!>
argv[4] = <>
argv[1] = <ooq//arq/>
argv[1] = <ooq>
argv[2] = <>
argv[3] = <arq>
argv[4] = <>
0
bar
./dollar-at3.sub: line 6: $@: unbound variable
0
bar
./dollar-star4.sub: line 6: *: unbound variable
+2 -1
View File
@@ -193,7 +193,8 @@ esac
MYDIR=$PWD # save where we are
TESTDIR=/tmp/eglob-test-$$
: ${TMPDIR:=/var/tmp}
TESTDIR=$TMPDIR/eglob-test-$$
mkdir $TESTDIR
builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
rm -rf *
+370
View File
@@ -0,0 +1,370 @@
# test the ksh-like extended globbing features: [!@*?+](patlist)
shopt -s extglob
expect()
{
echo expect "$@"
}
case "/dev/udp/129.22.8.102/45" in
/dev/@(tcp|udp)/*/*) echo ok 1;;
*) echo bad 1;;
esac
# valid numbers
case 12 in
0|[1-9]*([0-9])) echo ok 2;;
*) echo bad 2;;
esac
case 12abc in
0|[1-9]*([0-9])) echo bad 3;;
*) echo ok 3;;
esac
case 1 in
0|[1-9]*([0-9])) echo ok 4;;
*) echo bad 4;;
esac
# octal numbers
case 07 in
+([0-7])) echo ok 5;;
*) echo bad 5;;
esac
case 0377 in
+([0-7])) echo ok 6;;
*) echo bad 6;;
esac
case 09 in
+([0-7])) echo bad 7;;
*) echo ok 7;;
esac
# stuff from korn's book
case paragraph in
para@(chute|graph)) echo ok 8;;
*) echo bad 8;;
esac
case paramour in
para@(chute|graph)) echo bad 9;;
*) echo ok 9;;
esac
case para991 in
para?([345]|99)1) echo ok 10;;
*) echo bad 10;;
esac
case para381 in
para?([345]|99)1) echo bad 11;;
*) echo ok 11;;
esac
case paragraph in
para*([0-9])) echo bad 12;;
*) echo ok 12;;
esac
case para in
para*([0-9])) echo ok 13;;
*) echo bad 13;;
esac
case para13829383746592 in
para*([0-9])) echo ok 14;;
*) echo bad 14;;
esac
case paragraph in
para*([0-9])) echo bad 15;;
*) echo ok 15;;
esac
case para in
para+([0-9])) echo bad 16;;
*) echo ok 16;;
esac
case para987346523 in
para+([0-9])) echo ok 17;;
*) echo bad 17;;
esac
case paragraph in
para!(*.[0-9])) echo ok 18;;
*) echo bad 18;;
esac
case para.38 in
para!(*.[0-9])) echo ok 19;;
*) echo bad 19;;
esac
case para.graph in
para!(*.[0-9])) echo ok 20;;
*) echo bad 20;;
esac
case para39 in
para!(*.[0-9])) echo ok 21;;
*) echo bad 21;;
esac
# tests derived from those in rosenblatt's korn shell book
case "" in
*(0|1|3|5|7|9)) echo ok 22;;
*) echo bad 22;
esac
case 137577991 in
*(0|1|3|5|7|9)) echo ok 23;;
*) echo bad 23;
esac
case 2468 in
*(0|1|3|5|7|9)) echo bad 24;;
*) echo ok 24;
esac
case file.c in
*.c?(c)) echo ok 25;;
*) echo bad 25;;
esac
case file.C in
*.c?(c)) echo bad 26;;
*) echo ok 26;;
esac
case file.cc in
*.c?(c)) echo ok 27;;
*) echo bad 27;;
esac
case file.ccc in
*.c?(c)) echo bad 28;;
*) echo ok 28;;
esac
case parse.y in
!(*.c|*.h|Makefile.in|config*|README)) echo ok 29;;
*) echo bad 29;;
esac
case shell.c in
!(*.c|*.h|Makefile.in|config*|README)) echo bad 30;;
*) echo ok 30;;
esac
case Makefile in
!(*.c|*.h|Makefile.in|config*|README)) echo ok 31;;
*) echo bad 31;;
esac
case "VMS.FILE;1" in
*\;[1-9]*([0-9])) echo ok 32;;
*) echo bad 32;;
esac
case "VMS.FILE;0" in
*\;[1-9]*([0-9])) echo bad 33;;
*) echo ok 33;;
esac
case "VMS.FILE;" in
*\;[1-9]*([0-9])) echo bad 34;;
*) echo ok 34;;
esac
case "VMS.FILE;139" in
*\;[1-9]*([0-9])) echo ok 35;;
*) echo bad 35;;
esac
case "VMS.FILE;1N" in
*\;[1-9]*([0-9])) echo bad 36;;
*) echo ok 36;;
esac
# tests derived from the pd-ksh test suite
MYDIR=$PWD # save where we are
TESTDIR=/tmp/eglob-test-$$
mkdir $TESTDIR
builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
rm -rf *
touch abcx abcz bbc
expect '!([*)*'
echo !([*)*
expect '+(a|b[)*'
echo +(a|b[)*
expect '[a*(]*z'
echo [a*(]*)z
rm -f abcx abcz bbc
touch abc
expect '+()c'
echo +()c
expect '+()x'
echo +()x
expect abc
echo +(*)c
expect '+(*)x'
echo +(*)x
# extended globbing should not be performed on the output of substitutions
x='@(*)'
expect '@(*)'
echo $x
expect 'no-file+(a|b)stuff'
echo no-file+(a|b)stuff
expect 'no-file+(a*(c)|b)stuff'
echo no-file+(a*(c)|b)stuff
touch abd acd
expect 'abd acd'
echo a+(b|c)d
expect 'acd'
echo a!(@(b|B))d
expect 'abd'
echo a[b*(foo|bar)]d
# simple kleene star tests
expect no
case foo in *(a|b[)) echo yes;; *) echo no;; esac
expect yes
case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
# this doesn't work right yet; it is an incorrectly formed pattern
expect yes
case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
# check extended globbing in pattern removal -- these don't work right yet
x=abcdef
expect '1: bcdef'
echo 1: ${x#+(a|abc)}
expect '2: def'
echo 2: ${x##+(a|abc)}
expect '3: abcde'
echo 3: ${x%+(def|f)}
expect '4: abc'
echo 4: ${x%%+(f|def)}
# these work ok
expect '5: ef'
echo 5: ${x#*(a|b)cd}
expect '6: ef'
echo 6: "${x#*(a|b)cd}"
expect '7: abcdef'
echo 7: ${x#"*(a|b)cd"}
# More tests derived from a bug report concerning extended glob patterns
# following a *
builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
rm -rf *
touch ab abcdef abef abcfef
expect 'ab abef'
echo ab*(e|f)
expect 'abcfef abef'
echo ab?*(e|f)
expect abcdef
echo ab*d+(e|f)
expect 'ab abcdef abcfef abef'
echo ab**(e|f)
expect 'abcdef abcfef abef'
echo ab*+(e|f)
case 'abcfefg' in
ab**(e|f)) echo ok 37;;
*) echo bad 37;;
esac
case 'abcfefg' in
ab**(e|f)g) echo ok 38;;
*a) echo bad 38;;
esac
case ab in
ab*+(e|f)) echo bad 39;;
*) echo ok 39;;
esac
case abef in
ab***ef) echo ok 40;;
*) echo bad 40;;
esac
case abef in
ab**) echo ok 41;;
*) echo bad 41;;
esac
# bug in all versions up to and including bash-2.05b
case "123abc" in
*?(a)bc) echo ok 42;;
*) echo bad 42;;
esac
# clean up and do the next one
builtin cd /
rm -rf $TESTDIR
mkdir $TESTDIR
builtin cd $TESTDIR
LC_COLLATE=C # have to set this; it affects the sorting
touch a.b a,b a:b a-b a\;b a\ b a_b
echo a[^[:alnum:]]b
echo a[-.,:\;\ _]b
echo a@([^[:alnum:]])b
echo a@([-.,:; _])b
echo a@([.])b
echo a@([^.])b
echo a@([^x])b
echo a+([^[:alnum:]])b
echo a@(.|[^[:alnum:]])b
builtin cd /
rm -rf $TESTDIR
x=abcdef
recho "${x#*(a|b)cd}"
TEST='a , b'
shopt -s globstar
echo ${TEST//*([[:space:]]),*([[:space:]])/,}
shopt -u globstar
# this is for the benefit of pure coverage, so it writes the pcv file
# in the right place
builtin cd "$MYDIR"
${THIS_SH} ./extglob1.sub
exit 0
+1 -1
View File
@@ -13,7 +13,7 @@ argv[2] = <abc>
argv[3] = <abd>
argv[4] = <abe>
tmp/l1 tmp/l2 tmp/*4 tmp/l3
./glob-test: line 44: no match: tmp/*4
./glob.tests: line 44: no match: tmp/*4
argv[1] = <bdir/>
argv[1] = <*>
argv[1] = <a*>
+388
View File
@@ -0,0 +1,388 @@
export LC_COLLATE=C
#
# test the shell globbing
#
expect()
{
echo expect "$@"
}
# First, a test that bash-2.01.1 fails
${THIS_SH} ./glob1.sub
MYDIR=$PWD # save where we are
TESTDIR=/tmp/glob-test
mkdir $TESTDIR
builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
rm -rf *
touch a b c d abc abd abe bb bcd ca cb dd de Beware
mkdir bdir
# see if `regular' globbing works right
expect '<a> <abc> <abd> <abe> <X*>'
recho a* X*
expect '<a> <abc> <abd> <abe>'
recho \a*
# see if null glob expansion works
shopt -s nullglob
expect '<a> <abc> <abd> <abe>'
recho a* X*
shopt -u nullglob
# see if the failglob option works
mkdir tmp
touch tmp/l1 tmp/l2 tmp/l3
builtin echo tmp/l[12] tmp/*4 tmp/*3
shopt -s failglob
builtin echo tmp/l[12] tmp/*4 tmp/*3
rm -r tmp
shopt -u failglob
# see if the code that expands directories only works
expect '<bdir/>'
recho b*/
# Test quoted and unquoted globbing characters
expect '<*>'
recho \*
expect '<a*>'
recho 'a*'
expect '<a*>'
recho a\*
expect '<c> <ca> <cb> <a*> <*q*>'
recho c* a\* *q*
expect '<**>'
recho "*"*
expect '<**>'
recho \**
expect '<\.\./*/>'
recho "\.\./*/"
expect '<s/\..*//>'
recho 's/\..*//'
# Pattern from Larry Wall's Configure that caused bash to blow up
expect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'
recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"
# Make sure character classes work properly
expect '<abc> <abd> <abe> <bb> <cb>'
recho [a-c]b*
expect '<abd> <abe> <bb> <bcd> <bdir> <ca> <cb> <dd> <de>'
recho [a-y]*[^c]
expect '<abd> <abe>'
recho a*[^c]
touch a-b aXb
expect '<a-b> <aXb>'
recho a[X-]b
touch .x .y
expect '<Beware> <d> <dd> <de>'
recho [^a-c]*
# Make sure that filenames with embedded globbing characters are handled
# properly
mkdir a\*b
> a\*b/ooo
expect '<a*b/ooo>'
recho a\*b/*
expect '<a*b/ooo>'
recho a\*?/*
expect '<no match>'
cmd='echo !7'
case "$cmd" in
*\\!*) echo match ;;
*) echo no match ;;
esac
expect '<not there>'
file='r.*'
case $file in
*.\*) echo not there ;;
*) echo there ;;
esac
# examples from the Posix.2 spec (d11.2, p. 243)
expect '<abc>'
recho a[b]c
expect '<abc>'
recho a["b"]c
expect '<abc>'
recho a[\b]c
expect '<abc>'
recho a?c
expect '<match 1>'
case abc in
a"b"c) echo 'match 1' ;;
*) echo 'BAD match 1' ;;
esac
expect '<match 2>'
case abc in
a*c) echo 'match 2' ;;
*) echo 'BAD match 2' ;;
esac
expect '<ok 1>'
case abc in
"a?c") echo 'bad 1' ;;
*) echo 'ok 1' ;;
esac
expect '<ok 2>'
case abc in
a\*c) echo 'bad 2' ;;
*) echo 'ok 2' ;;
esac
expect '<ok 3>'
case abc in
a\[b]c) echo 'bad 3' ;;
*) echo 'ok 3' ;;
esac
expect '<ok 4>'
case "$nosuchvar" in
"") echo 'ok 4' ;;
*) echo 'bad 4' ;;
esac
# This is very odd, but sh and ksh seem to agree
expect '<ok 5>'
case abc in
a["\b"]c) echo 'ok 5' ;;
*) echo 'bad 5' ;;
esac
mkdir man
mkdir man/man1
touch man/man1/bash.1
expect '<man/man1/bash.1>'
recho */man*/bash.*
expect '<man/man1/bash.1>'
recho $(echo */man*/bash.*)
expect '<man/man1/bash.1>'
recho "$(echo */man*/bash.*)"
# tests with multiple `*'s
case abc in
a***c) echo ok 1;;
esac
case abc in
a*****?c) echo ok 2;;
esac
case abc in
?*****??) echo ok 3;;
esac
case abc in
*****??) echo ok 4;;
esac
case abc in
*****??c) echo ok 5;;
esac
case abc in
?*****?c) echo ok 6;;
esac
case abc in
?***?****c) echo ok 7;;
esac
case abc in
?***?****?) echo ok 8;;
esac
case abc in
?***?****) echo ok 9;;
esac
case abc in
*******c) echo ok 10;;
esac
case abc in
*******?) echo ok 11;;
esac
case abcdecdhjk in
a*cd**?**??k) echo ok 20;;
esac
case abcdecdhjk in
a**?**cd**?**??k) echo ok 21;;
esac
case abcdecdhjk in
a**?**cd**?**??k***) echo ok 22;;
esac
case abcdecdhjk in
a**?**cd**?**??***k) echo ok 23;;
esac
case abcdecdhjk in
a**?**cd**?**??***k**) echo ok 24;;
esac
case abcdecdhjk in
a****c**?**??*****) echo ok 25;;
esac
case '-' in
[-abc]) echo ok 26 ;;
esac
case '-' in
[abc-]) echo ok 27 ;;
esac
case '\' in
\\) echo ok 28 ;;
esac
case '\' in
[\\]) echo ok 29 ;;
esac
case '\' in
'\') echo ok 30 ;;
esac
case '[' in
[[]) echo ok 31 ;;
esac
# a `[' without a closing `]' is just another character to match, in the
# bash implementation
case '[' in
[) echo ok 32 ;;
esac
case '[abc' in
[*) echo 'ok 33';;
esac
# a right bracket shall lose its special meaning and represent itself in
# a bracket expression if it occurs first in the list. -- POSIX.2 2.8.3.2
case ']' in
[]]) echo ok 34 ;;
esac
case '-' in
[]-]) echo ok 35 ;;
esac
# a backslash should just escape the next character in this context
case p in
[a-\z]) echo ok 36 ;;
esac
# this was a bug in all versions up to bash-2.04-release
case "/tmp" in
[/\\]*) echo ok 37 ;;
esac
# none of these should output anything
case abc in
??**********?****?) echo bad 1;;
esac
case abc in
??**********?****c) echo bad 2;;
esac
case abc in
?************c****?****) echo bad 3;;
esac
case abc in
*c*?**) echo bad 4;;
esac
case abc in
a*****c*?**) echo bad 5;;
esac
case abc in
a********???*******) echo bad 6;;
esac
case 'a' in
[]) echo bad 7 ;;
esac
case '[' in
[abc) echo bad 8;;
esac
# let's start testing the case-insensitive globbing code
recho b*
shopt -s nocaseglob
recho b*
recho [b]*
shopt -u nocaseglob
# make sure set -f works right
set -f
recho *
set +f
# test out the GLOBIGNORE code
GLOBIGNORE='.*:*c:*e:?'
recho *
GLOBIGNORE='.*:*b:*d:?'
recho *
# see if GLOBIGNORE can substitute for `set -f'
GLOBIGNORE='.*:*'
recho *
unset GLOBIGNORE
expect '<man/man1/bash.1>'
recho */man*/bash.*
# make sure null values for GLOBIGNORE have no effect
GLOBIGNORE=
expect '<man/man1/bash.1>'
recho */man*/bash.*
# this is for the benefit of pure coverage, so it writes the pcv file
# in the right place, and for gprof
builtin cd $MYDIR
rm -rf $TESTDIR
exit 0
+152
View File
@@ -0,0 +1,152 @@
lib/glob/glob.o
lib/glob/smatch.o
lib/glob/strmatch.o
lib/readline/bind.o
lib/readline/callback.o
lib/readline/compat.o
lib/readline/complete.o
lib/readline/display.o
lib/sh/casemod.o
lib/sh/clktck.o
lib/sh/clock.o
lib/sh/eaccess.o
lib/sh/fdprintf.o
lib/sh/fmtullong.o
lib/sh/fmtulong.o
lib/sh/fmtumax.o
lib/sh/fpurge.o
lib/sh/getenv.o
lib/sh/input_avail.o
lib/sh/itos.o
lib/:
glob
readline
sh
lib/glob:
glob.o
smatch.o
strmatch.o
lib/readline:
bind.o
callback.o
compat.o
complete.o
display.o
lib/sh:
casemod.o
clktck.o
clock.o
eaccess.o
fdprintf.o
fmtullong.o
fmtulong.o
fmtumax.o
fpurge.o
getenv.o
input_avail.o
itos.o
lib/glob/glob.o
lib/glob/smatch.o
lib/glob/strmatch.o
lib/readline/bind.o
lib/readline/callback.o
lib/readline/compat.o
lib/readline/complete.o
lib/readline/display.o
lib/sh/casemod.o
lib/sh/clktck.o
lib/sh/clock.o
lib/sh/eaccess.o
lib/sh/fdprintf.o
lib/sh/fmtullong.o
lib/sh/fmtulong.o
lib/sh/fmtumax.o
lib/sh/fpurge.o
lib/sh/getenv.o
lib/sh/input_avail.o
lib/sh/itos.o
alias.o builtins/history.o builtins/jobs.o builtins/kill.o builtins/let.o builtins/mapfile.o lib/glob/glob.o lib/glob/smatch.o lib/glob/strmatch.o lib/readline/bind.o lib/readline/callback.o lib/readline/compat.o lib/readline/complete.o lib/readline/display.o lib/sh/casemod.o lib/sh/clktck.o lib/sh/clock.o lib/sh/eaccess.o lib/sh/fdprintf.o lib/sh/fmtullong.o lib/sh/fmtulong.o lib/sh/fmtumax.o lib/sh/fpurge.o lib/sh/getenv.o lib/sh/input_avail.o lib/sh/itos.o pcomplib.o print_cmd.o redir.o shell.o sig.o stringlib.o subst.o syntax.o test.o trap.o unwind_prot.o variables.o version.o xmalloc.o y.tab.o
alias.o
builtins/history.o
builtins/jobs.o
builtins/kill.o
builtins/let.o
builtins/mapfile.o
lib/glob/glob.o
lib/glob/smatch.o
lib/glob/strmatch.o
lib/readline/bind.o
lib/readline/callback.o
lib/readline/compat.o
lib/readline/complete.o
lib/readline/display.o
lib/sh/casemod.o
lib/sh/clktck.o
lib/sh/clock.o
lib/sh/eaccess.o
lib/sh/fdprintf.o
lib/sh/fmtullong.o
lib/sh/fmtulong.o
lib/sh/fmtumax.o
lib/sh/fpurge.o
lib/sh/getenv.o
lib/sh/input_avail.o
lib/sh/itos.o
pcomplib.o
print_cmd.o
redir.o
shell.o
sig.o
stringlib.o
subst.o
syntax.o
test.o
trap.o
unwind_prot.o
variables.o
version.o
xmalloc.o
y.tab.o
builtins:
history.o
jobs.o
kill.o
let.o
mapfile.o
lib:
glob
readline
sh
lib/glob:
glob.o
smatch.o
strmatch.o
lib/readline:
bind.o
callback.o
compat.o
complete.o
display.o
lib/sh:
casemod.o
clktck.o
clock.o
eaccess.o
fdprintf.o
fmtullong.o
fmtulong.o
fmtumax.o
fpurge.o
getenv.o
input_avail.o
itos.o
alias.o builtins builtins/history.o builtins/jobs.o builtins/kill.o builtins/let.o builtins/mapfile.o lib lib/glob lib/glob/glob.o lib/glob/smatch.o lib/glob/strmatch.o lib/readline lib/readline/bind.o lib/readline/callback.o lib/readline/compat.o lib/readline/complete.o lib/readline/display.o lib/sh lib/sh/casemod.o lib/sh/clktck.o lib/sh/clock.o lib/sh/eaccess.o lib/sh/fdprintf.o lib/sh/fmtullong.o lib/sh/fmtulong.o lib/sh/fmtumax.o lib/sh/fpurge.o lib/sh/getenv.o lib/sh/input_avail.o lib/sh/itos.o pcomplib.o print_cmd.o redir.o shell.o sig.o stringlib.o subst.o syntax.o test.o trap.o unwind_prot.o variables.o version.o xmalloc.o y.tab.o
+39
View File
@@ -0,0 +1,39 @@
: ${TMPDIR:=/var/tmp}
dir=$PWD
shopt -s globstar
export LANG=C LC_ALL=C LC_COLLATE=C
GDIR=$TMPDIR/globstar-$$
mkdir $GDIR || exit 1
cd $GDIR || exit 1
mkdir lib builtins
mkdir lib/glob lib/readline lib/sh
touch builtins/history.o builtins/jobs.o builtins/kill.o builtins/let.o builtins/mapfile.o
touch lib/glob/glob.o lib/glob/smatch.o lib/glob/strmatch.o
touch lib/readline/bind.o lib/readline/callback.o lib/readline/compat.o lib/readline/complete.o lib/readline/display.o
touch lib/sh/casemod.o lib/sh/clktck.o lib/sh/clock.o lib/sh/eaccess.o
touch lib/sh/fdprintf.o lib/sh/fmtullong.o lib/sh/fmtulong.o lib/sh/fmtumax.o
touch lib/sh/fpurge.o lib/sh/getenv.o lib/sh/input_avail.o lib/sh/itos.o
touch alias.o
touch pcomplib.o print_cmd.o redir.o shell.o sig.o stringlib.o subst.o syntax.o
touch test.o trap.o unwind_prot.o variables.o version.o xmalloc.o y.tab.o
ls lib/**
ls lib/**/*.o
echo **/*.o
ls **
echo **
cd $dir
rm -rf $GDIR
+1 -1
View File
@@ -1,4 +1,4 @@
PATH=$PATH:`pwd`
export PATH
${THIS_SH} ./glob-test 2>&1 | grep -v '^expect' > /tmp/xx
${THIS_SH} ./glob.tests 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx glob.right && rm -f /tmp/xx
+4
View File
@@ -0,0 +1,4 @@
PATH=$PATH:`pwd`
export PATH
${THIS_SH} ./glob-test 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx glob.right && rm -f /tmp/xx
+4
View File
@@ -0,0 +1,4 @@
PATH=$PATH:`pwd`
export PATH
${THIS_SH} ./globstar.tests > /tmp/xx 2>&1
diff /tmp/xx globstar.right && rm -f /tmp/xx
+4
View File
@@ -0,0 +1,4 @@
PATH=$PATH:`pwd`
export PATH
${THIS_SH} ./globstar.test > /tmp/xx 2>&1
diff /tmp/xx globstar.right && rm -f /tmp/xx