bracket.sh revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
# and is licensed under the #
# Common Public License, Version 1.0 #
# by AT&T Knowledge Ventures #
# #
# A copy of the License is available at #
# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
# #
# 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
null=''
if [[ ! -z $null ]]
then err_exit "-z: null string should be of zero length"
fi
if [[ -z $file ]]
fi
if [[ -a $file ]]
fi
> $file
if [[ ! -a $file ]]
fi
if [[ ! -r $file ]]
fi
if [[ ! -w $file ]]
fi
if [[ ! -w $file ]]
fi
fi
if [[ -s $file ]]
fi
if [[ ! -f $file ]]
fi
if [[ -d $file ]]
fi
if [[ ! -d . ]]
then err_exit "-d: . should not be a directory file"
fi
fi
if [[ -r $file ]]
fi
if [[ ! -O $file ]]
fi
if [[ -w $file ]]
fi
if [[ -w $file ]]
fi
fi
if [[ -z x && -z x || ! -z x ]]
then :
else err_exit " wrong precedence"
fi
if [[ -z x && (-z x || ! -z x) ]]
then err_exit " () grouping not working"
fi
then err_exit "foo comes before bar"
fi
set -o allexport
if [[ -n $null ]]
fi
fi
fi
sleep 1
fi
fi
fi
if [[ $file = '/tmp/*' ]]
fi
(exit 8)
then err_exit 'value $? within [[...]]'
fi
x='(x'
if [[ '(x' != '('* ]]
then err_exit " '(x' does not match '('* within [[...]]"
fi
if [[ '(x' != "("* ]]
then err_exit ' "(x" does not match "("* within [[...]]'
fi
if [[ '(x' != \(* ]]
then err_exit ' "(x" does not match \(* within [[...]]'
fi
if [[ 'x(' != *'(' ]]
then err_exit " 'x(' does not match '('* within [[...]]"
fi
if [[ 'x&' != *'&' ]]
then err_exit " 'x&' does not match '&'* within [[...]]"
fi
if [[ 'xy' = *'*' ]]
then err_exit " 'xy' matches *'*' within [[...]]"
fi
if [[ 3 > 4 ]]
then err_exit '3 < 4'
fi
if [[ 4 < 3 ]]
then err_exit '3 > 4'
fi
if [[ 3x > 4x ]]
then err_exit '3x < 4x'
fi
x='bin|dev|?'
cd /
if [[ $(print $x) != "$x" ]]
then err_exit 'extended pattern matching on command arguments'
fi
if [[ dev != $x ]]
then err_exit 'extended pattern matching not working on variables'
fi
if [[ -u $SHELL ]]
fi
if [[ -g $SHELL ]]
fi
if [[ '!' != ! ]]
then err_exit 'quoting unary operator not working'
fi
exec 4> $file
if [[ ! -s $file ]]
fi
exec 4>&-
then err_exit "leading zeros in arithmetic compares not ignored"
fi
{
set -x
set +x
(
eval "[[ (a) ]]"
> $file
then err_exit "test ! -u suidfile not working"
fi
for i in '(' ')' '[' ']'
do [[ $i == $i ]] || err_exit "[[ $i != $i ]]"
done
(
{
sleep 2
print 'hello world'
sleep 2
read
fi
$SHELL -c 't=1234567890; [[ $t == @({10}(\d)) ]]' 2> /dev/null || err_exit ' @({10}(\d)) pattern not working'
$SHELL -c '[[ att_ == ~(E)(att|cus)_.* ]]' 2> /dev/null || err_exit ' ~(E)(att|cus)_* pattern not working'