glob.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"
}
alias err_exit='err_exit $LINENO'
function test_glob
{
if [[ $1 == --* ]]
then del=${1#--}
shift
fi
if [[ $1 == ++* ]]
then add=${1#++}
shift
fi
shift 2
fi
fi
fi
for arg
sep=" "
done
then if [[ $del ]]
fi
if [[ $add ]]
fi
fi
fi
}
function test_case
{
eval "
case $subject in
$pattern) got='<match>' ;;
*) got='<nomatch>' ;;
esac
"
fi
}
integer errors=0
unset undefined
export LC_COLLATE=C
touch B b
set -- *
case $* in
b|B) ignorant=1 ;;
esac
case $* in
B) aware=1 ;;
esac
then
set --nullglob
set --nonullglob
fi
then
set --failglob
set --nofailglob
fi
test_glob $LINENO '</^root:/{s/^[!:]*:[!:]*:\([!:]*\).*$/\1/>' "/^root:/{s/^[!:]*:[!:]*:\([!:]*\).*"'$'"/\1/"
touch .x .y
then
fi
then
set --nocaseglob
set --nonocaseglob
fi
then
set -f
test_glob $LINENO '<*>' *
set +f
fi
then
set --noglob
test_glob $LINENO '<*>' *
set --glob
fi
FIGNORE='.*|*'
test_glob $LINENO '<*>' *
FIGNORE='.*|*c|*e|?'
FIGNORE='.*|*b|*d|?'
FIGNORE=
unset FIGNORE
GLOBIGNORE='.*:*'
set -- *
if [[ $1 == '*' ]]
then
GLOBIGNORE='.*:*c:*e:?'
test_glob $LINENO '<>' *
GLOBIGNORE='.*:*b:*d:?'
test_glob $LINENO '<>' *
unset GLOBIGNORE
test_glob $LINENO '<>' *
GLOBIGNORE=
fi
exit $errors