diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-12-03 22:45:57 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-12-03 22:45:57 -0500 |
commit | 462a7a25f1e29aa254f660dc3e666b189c8d1326 (patch) | |
tree | a0bacba95e639163e730597556f563ceb36bb617 /tests | |
parent | 27a1808ccd842c15cfc86e96947dd9c4154444a1 (diff) | |
download | bash-462a7a25f1e29aa254f660dc3e666b189c8d1326.tar.gz |
commit bash-20060302 snapshot
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/RUN-ONE-TEST | 2 | ||||
-rw-r--r-- | tests/extglob.right | 9 | ||||
-rw-r--r-- | tests/extglob.tests | 4 | ||||
-rw-r--r-- | tests/extglob1.sub | 37 | ||||
-rw-r--r-- | tests/nquote.right | 3 | ||||
-rw-r--r-- | tests/nquote.tests | 7 | ||||
-rw-r--r-- | tests/quote.right | 19 | ||||
-rw-r--r-- | tests/quote.tests | 26 | ||||
-rw-r--r-- | tests/quote.tests~ | 101 |
9 files changed, 205 insertions, 3 deletions
diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 3efcf32d..72ec06a2 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -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 diff --git a/tests/extglob.right b/tests/extglob.right index f063b261..301e97b2 100644 --- a/tests/extglob.right +++ b/tests/extglob.right @@ -78,3 +78,12 @@ a b a,b a-b a.b a:b a;b a_b a b a,b a-b a.b a:b a;b a_b a b a,b a-b a.b a:b a;b a_b argv[1] = <ef> +a.c +a.c +a.c +a.c +a.c +a.c +ok 1 +ok 2 +ok 3 diff --git a/tests/extglob.tests b/tests/extglob.tests index 2d938500..51e33ee7 100644 --- a/tests/extglob.tests +++ b/tests/extglob.tests @@ -193,7 +193,7 @@ esac MYDIR=$PWD # save where we are -TESTDIR=/tmp/eglob-test +TESTDIR=/tmp/eglob-test-$$ mkdir $TESTDIR builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; } rm -rf * @@ -360,4 +360,6 @@ recho "${x#*(a|b)cd}" # in the right place builtin cd $MYDIR +${THIS_SH} ./extglob1.sub + exit 0 diff --git a/tests/extglob1.sub b/tests/extglob1.sub new file mode 100644 index 00000000..3beec9e8 --- /dev/null +++ b/tests/extglob1.sub @@ -0,0 +1,37 @@ +MYDIR=$PWD + +: ${TMPDIR:=/tmp} +GDIR=$TMPDIR/gtest-$$ + +shopt -s extglob + +mkdir $GDIR || exit 1 +cd $GDIR || exit 1 + +touch a.c + +echo +([[:alpha:].]) +echo +([[:alpha:].])+([[:alpha:].]) +echo *([[:alpha:].]) +echo *([[:alpha:].])*([[:alpha:].]) + +echo ?([[:alpha:].])?([[:alpha:].])?([[:alpha:].]) +echo @([[:alpha:].])@([[:alpha:].])@([[:alpha:].]) + +case . in +!([[:alpha:].]) ) echo bad 1;; +*) echo ok 1;; +esac + +case . in +?([[:alpha:].]) ) echo ok 2;; +*) echo bad 2;; +esac + +case . in +@([[:alpha:].]) ) echo ok 3;; +*) echo bad 3;; +esac + +cd $MYDIR +rm -rf $GDIR diff --git a/tests/nquote.right b/tests/nquote.right index a2263486..6d936d5e 100644 --- a/tests/nquote.right +++ b/tests/nquote.right @@ -30,5 +30,8 @@ argv[1] = <hello, $"world"> argv[1] = <hello, \$"world"> argv[1] = <hello, $"world"> argv[1] = <hello, $world> +1 +1 +;foo argv[1] = <^I> argv[1] = <'A^IB'> diff --git a/tests/nquote.tests b/tests/nquote.tests index c2201af3..62d90b99 100644 --- a/tests/nquote.tests +++ b/tests/nquote.tests @@ -102,7 +102,12 @@ recho $'hello, $\"world"' recho "hello, $"world"" # ansi quoting inside double-quoted command subst - bash-3.1 bug -function args +echo $(set -- $'a b'; echo $#) +echo "$(set -- $'a b'; echo $#)" + +echo "$(echo $';foo')" + +args () { for a in "$@";do echo "'$a'";done } diff --git a/tests/quote.right b/tests/quote.right index 2c3444ac..424d1a04 100644 --- a/tests/quote.right +++ b/tests/quote.right @@ -47,3 +47,22 @@ argv[1] = <sed> argv[2] = <-e> argv[3] = <s/[^I:]//g> argv[1] = <foo\^Jbar> argv[1] = <foobar> argv[1] = <foo\^Jbar> +b +a +b +c +argv[1] = <a\> +argv[2] = <b> +argv[1] = <$> +argv[2] = <bab> +argv[1] = <$foo> +argv[2] = <bab> +argv[1] = <$foo> +argv[2] = <bab> +argv[1] = <`> +argv[2] = <ab> +argv[1] = <\> +argv[2] = <ab> +${ +argv[1] = <(")> +argv[1] = <(")> diff --git a/tests/quote.tests b/tests/quote.tests index b2377d9e..46edea75 100644 --- a/tests/quote.tests +++ b/tests/quote.tests @@ -83,3 +83,29 @@ bar'` echo $(recho 'foo\ bar') + +a=`echo 'a b c' | sed 's/ /\\ +/g' | grep 'b'` +echo $a +a=`echo 'a b c' | sed 's/ /\\ +/g'` +echo "$a" + +recho `echo 'a\' b` + +recho `echo '\$' bab` +recho `echo '\$foo' bab` +recho `echo '$foo' bab` + +recho `echo '\`' ab` + +recho `echo '\\' ab` + +echo `echo '${'` + +recho `echo "(\\")"` +# produces no output +: `: "\\""` +# ultimate workaround +recho `echo "(\")"` + diff --git a/tests/quote.tests~ b/tests/quote.tests~ new file mode 100644 index 00000000..ef465ad0 --- /dev/null +++ b/tests/quote.tests~ @@ -0,0 +1,101 @@ +echo "Single Quote" +echo 'foo +bar' +echo 'foo +bar' +echo 'foo\ +bar' + +echo "Double Quote" +echo "foo +bar" +echo "foo +bar" +echo "foo\ +bar" + +echo "Backslash Single Quote" +echo `echo 'foo +bar'` +echo `echo 'foo +bar'` +echo `echo 'foo\ +bar'` + +echo "Backslash Double Quote" +echo `echo "foo +bar"` +echo `echo "foo +bar"` +echo `echo "foo\ +bar"` + +echo "Double Quote Backslash Single Quote" +echo "`echo 'foo +bar'`" +echo "`echo 'foo +bar'`" +echo "`echo 'foo\ +bar'`" + +echo "Dollar Paren Single Quote" +echo $(echo 'foo +bar') +echo $(echo 'foo +bar') +echo $(echo 'foo\ +bar') + +echo "Dollar Paren Double Quote" +echo $(echo "foo +bar") +echo $(echo "foo +bar") +echo $(echo "foo\ +bar") + +echo "Double Quote Dollar Paren Single Quote" +echo "$(echo 'foo +bar')" +echo "$(echo 'foo +bar')" +echo "$(echo 'foo\ +bar')" + +# old-style command substitution parsing compatibility tests -- post bash-3.1 +recho 'foo \\ +bar' + +recho 'foo \ +bar' + +echo `recho sed -e 's/[ :]/\\ +/g'` + +echo `recho sed -e 's/[ :]/\ +/g'` + +echo `recho 'foo\\ +bar'` + +echo `recho 'foo\ +bar'` + +echo $(recho 'foo\ +bar') + +a=`echo 'a b c' | sed 's/ /\\ +/g' | grep 'b'` +echo $a +a=`echo 'a b c' | sed 's/ /\\ +/g'` +echo "$a" + +recho `echo 'a\' b` + +recho `echo '\$' bab` +recho `echo '\$foo' bab` + +recho `echo '\`' ab` + +recho `echo '\\' ab` |