########################################################################
# #
# 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"
}
alias err_exit='err_exit $LINENO'
integer Errors=0
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
set -- $x
if (( $# != 2 ))
fi
x=$(print -r -- '1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890 \
1234567890123456789012345678901234567890123456789012345678901234567890')
if (( ${#x} != (15*73-3) ))
then err_exit "length of x, ${#x}, is incorrect should be $((15*73-3))"
fi
fi
fi
if [[ $# != 2 ]]
fi
unset q
if [[ "${q:+'}q${q:+'}" != q ]]
fi
q=1
if [[ "${q:+'}q${q:+'}" != "'q'" ]]
fi
x=$'x\' #y'
if [[ $x != "x' #y" ]]
fi
x=$q$'x\' #y'
if [[ $x != "1x' #y" ]]
fi
IFS=,
x='a,b\,c,d'
set -- $x
if [[ $2 != 'b\' ]]
then err_exit "field splitting of $x with IFS=$IFS not working"
fi
foo=bar
bar=$(print -r -- ${foo+\\n\ })
if [[ $bar != '\n ' ]]
fi
unset bar
bar=$(print -r -- ${foo+\\n\ $bar})
if [[ $bar != '\n ' ]]
fi
x='\\(..\\)|&\|\|\\&\\|'
if [[ $(print -r -- $x) != "$x" ]]
fi
x='\\('
if [[ $(print -r -- a${x}b) != a"${x}"b ]]
fi
x=
if [[ $(print -r -- $x'\\1') != '\\1' ]]
fi
set -- ''
set -- "$@"
if (( $# != 1 ))
fi
x=
if [[ $(print -r s"!\2${x}\1\a!") != 's!\2\1\a!' ]]
fi
fi
unset x
if [[ ${x:='//'} != '//' ]]
then err_exit '${x:='//'} != "//"'
fi
if [[ $(print -r "\"hi$\"") != '"hi$"' ]]
fi
unset x
if [[ "${x-a\}b}" != 'a}b' ]]
then err_exit '"${x-a\}b}" != "a}b"'
fi
if [[ "\}\]$x\*\{\[\\" != '\}\]\*\{\[\' ]]
then err_exit '"\}\]$x\*\{\[\\" != "\}\]\*\{\[\"'
fi
fi
[[ foo == $(
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
###########################################################
re='@(?*)/@(?*)/@(?*)'
string='\3'
[[ ${subject/${re}/${string}} != words ]] && err_exit 'string replacement with $string not working with string=\3'
[[ $(print -r "${subject/${re}/${string}}") != words ]] && err_exit 'string replacement with $string not working with string=\3 using print'
[[ ${subject/${re}/"${string}"} != '\3' ]] && err_exit 'string replacement with "$string" not working with string=\3'
[[ $(print -r "${subject/${re}/"${string}"}") != '\3' ]] && err_exit 'string replacement with "$string" not working with string=\3 using print'
string='\\3'
[[ ${subject/${re}/${string}} != '\3' ]] && err_exit 'string replacement with $string not working with string=\\3'
[[ ${subject/${re}/"${string}"} != '\\3' ]] && err_exit 'string replacement with "$string" not working with string=\\3'
string='\4'
[[ ${subject/${re}/${string}} != '\4' ]] && err_exit 'string replacement with $string not working with string=\4'
[[ ${subject/${re}/"${string}"} != '\4' ]] && err_exit 'string replacement with "$string" not working with string=\4'
string='&foo'
[[ ${subject/${re}/${string}} != '&foo' ]] && err_exit 'string replacement with $string not working with string=&foo'
[[ ${subject/${re}/"${string}"} != '&foo' ]] && err_exit 'string replacement with "$string" not working with string=&foo'
{
x=x
[[ $x == x ]] || err_exit 'assignment ${x:=`...`} failed'
$SHELL -c $'false && (( `wc -l /dev/null | nawk \'{print $1}\'` > 2 )) && true;:' 2> /dev/null || err_exit 'syntax error with ` in arithmetic expression'
[[ $($SHELL -c 'set -- ${1+"$@"}; print $#' cmd '') == 1 ]] || err_exit '${1+"$@"} with one empty argument fails'
[[ $($SHELL -c 'set -- ${1+"$@"}; print $#' cmd foo '') == 2 ]] || err_exit '${1+"$@"} with one non-empty and on empty argument fails'
[[ $($SHELL -c 'set -- ${1+"$@"}; print $#' cmd "" '') == 2 ]] || err_exit '${1+"$@"} with two empty arguments fails'
[[ $($SHELL -c 'set -- ${1+"$@"}; print $#' cmd "" '' '') == 3 ]] || err_exit '${1+"$@"} with three empty arguments fails'
[[ $($SHELL -c 'set -- "$@"; print $#' cmd '') == 1 ]] || err_exit '"$@" with one empty argument fails'
[[ $($SHELL -c 'set -- "${@:2}"; print $#' cmd '') == 0 ]] || err_exit '"$@" with one empty argument fails'
[[ $($SHELL -c 'set -- "$@"; print $#' cmd foo '') == 2 ]] || err_exit '"$@" with one non-empty and on empty argument fails'
[[ $($SHELL -c 'set -- "$@"; print $#' cmd "" '') == 2 ]] || err_exit '"$@" with two empty arguments fails'
[[ $($SHELL -c 'set -- "$@"; print $#' cmd "" '' '') == 3 ]] || err_exit '"$@" with three empty arguments fails'
set -- "${args[@]}"
[[ $# == 1 ]] || err_exit '"${args[@]}"} with one empty argument fails'
set -- ${1+"${args[@]}"}
[[ $# == 1 ]] || err_exit '${1+"${args[@]}"} with one empty argument fails'
set -- "${args[@]}"
[[ $# == 2 ]] || err_exit '"${args[@]}"} with one non-empty and one empty argument fails'
set -- ${1+"${args[@]}"}
[[ $# == 2 ]] || err_exit '${1+"${args[@]}"} with one non-empty and one empty argument fails'
unset ARGS
set --
set -- "${ARGS[@]}"