########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2011 AT&T Intellectual Property #
# and is licensed under the #
# Eclipse Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# David Korn <dgk@research.att.com> #
# #
########################################################################
function err_exit
{
print -u2 -n "\t"
let Errors+=1
}
alias err_exit='err_exit $LINENO'
integer Errors=0
set -o noglob
if [[ 'hi there' != "hi there" ]]
then err_exit "single quotes not the same as double quotes"
fi
x='hi there'
if [[ $x != 'hi there' ]]
then err_exit "$x not the same as 'hi there'"
fi
if [[ $x != "hi there" ]]
then err_exit "$x not the same as \"hi there \""
fi
if [[ \a\b\c\*\|\"\ \\ != 'abc*|" \' ]]
then err_exit " \\ differs from '' "
fi
then err_exit " \"\" differs from '' "
fi
fi
if [[ $(print -r - "abc*|\" \\") != 'abc*|" \' ]]
then err_exit "\$(print -r - '') differs from ''"
fi
fi
if [[ "$(print -r - "abc*|\" \\")" != 'abc*|" \' ]]
then err_exit "\"\$(print -r - "")\" differs from ''"
fi
fi
fi
fi
unset x
if [[ ${x-$(print -r - "abc*|\" \\")} != 'abc*|" \' ]]
then err_exit "\${x-\$(print -r - '')} differs from ''"
fi
if [[ ${x-$(print -r - "a}c*|\" \\")} != 'a}c*|" \' ]]
then err_exit "\${x-\$(print -r - '}')} differs from ''"
fi
x=$((echo foo)|(cat))
if [[ $x != foo ]]
then err_exit "((cmd)|(cmd)) failed"
fi
x=$(print -r -- "\"$HOME\"")
then err_exit "nested double quotes failed"
fi
unset z
: ${z="a{b}c"}
if [[ $z != 'a{b}c' ]]
fi
unset z
: "${z="a{b}c"}"
if [[ $z != 'a{b}c' ]]
fi
if [[ $(print -r -- "a\*b") != 'a\*b' ]]
fi
unset x
if [[ $(print -r -- "a\*b$x") != 'a\*b' ]]
fi
x=hello
set -- ${x+foo bar bam}
if (( $# !=3 ))
fi
set -- ${x+foo "bar bam"}
if (( $# !=2 ))
fi
if (( $# !=2 ))
fi
set -- ${x+foo $x bam}
if (( $# !=3 ))
fi
set -- ${x+foo "$x" bam}
if (( $# !=3 ))
fi
set -- ${x+"foo $x bam"}
if (( $# !=1 ))
fi
set -- "${x+foo $x bam}"
if (( $# !=1 ))
fi
set -- ${x+foo "$x "bam}
if (( $# !=2 ))
fi
x="ab$'cd"
if [[ $x != 'ab$'"'cd" ]]
fi
x=`print 'ab$'`
if [[ $x != 'ab$' ]]
then err_exit '$'"' inside `` quotes not working"
fi
unset a
x=$(print -r -- "'\
\
")
if [[ $x != "'" ]]
fi
x=$(print -r -- "'\
$a\
")
if [[ $x != "'" ]]
fi
x='\*'
if [[ $(print -r -- $x) != '\*' ]]
then err_exit 'x="\\*";$x != \*'
fi
if [[ $(print -r -- "\}" ) != '\}' ]]
then err_exit '(print -r -- "\}"' not working
fi
if [[ $(print -r -- "\{" ) != '\{' ]]
then err_exit 'print -r -- "\{"' not working
fi
# The following caused a syntax error on earlier versions
foo=foo x=-
if [[ `eval print \\${foo$x}` != foo* ]]
fi
if [[ "`eval print \\${foo$x}`" != foo* ]]
fi
if ( [[ $() != '' ]] )
fi
x=a:b:c
set -- $( IFS=:; print $x)
if (( $# != 3))
fi
y=$(
# ( this line is a bug fix
print hi
)
!
x=
for j in glob noglob
do eval [[ '$('print -r -- \'$i\'\$x')' != "'$i'" ]] && err_exit "quoting of $i\$x with $j enabled failed"
eval [[ '$('print -r -- \'$i\'\${x%*}')' != "'$i'" ]] && err_exit "quoting of $i\${x%*} with $j enabled failed"
if [[ $j == noglob ]]
then eval [[ '$('print -r -- \'$i\'\${x:-*}')' != "'$i''*'" ]] && err_exit "quoting of $i\${x:-*} with $j enabled failed"
fi
done
set -f
done
foo=foo
[[ "$" == '$' ]] || err_exit '"$" != $'
foo='$ '
foo='# '
[[ a+a =~ a\+a ]] || err_exit 'RE a\+a not matching a+a'
exp='ac'