#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# testing GLOBSORT
LC_COLLATE=C
LC_CTYPE=C
LANG=C

: ${TMPDIR:=/tmp}

TDIR=$TMPDIR/glob-$$
{ mkdir $TDIR && cd $TDIR; } || exit 1

# try to impose some kind of testable ordering
echo 123 > mksyntax ; sleep 0.1
echo 123456 > mksignames ; sleep 0.1
echo 1234567879 > make_cmd.o ; sleep 0.1
echo 123456789012 > mailcheck.o ; sleep 0.1
echo 123456789012345 > mksignames.o ; sleep 0.1
echo 123456789012345678 > mksyntax.dSYM ; sleep 0.1

echo m*
GLOBSORT=nosort
#echo m*			# might have to take this one out
unset GLOBSORT
echo

GLOBSORT=
echo m*
GLOBSORT='-name'
echo m*
echo

GLOBSORT='+nonsense'
echo m*
GLOBSORT='-nonsense'
echo m*
echo

GLOBSORT='+atime'
echo m*
GLOBSORT='-atime'
echo m*
echo

GLOBSORT='+mtime'
echo m*
GLOBSORT='-mtime'
echo m*
echo

GLOBSORT=size
echo m*
GLOBSORT=-size
echo m*

# all zero-length files, so secondary sort on name
touch aa ab ac
GLOBSORT=size
echo a*
# secondary sorting preserves reverse ordering
GLOBSORT=-size
echo a*

cd $OLDPWD
rm -rf $TDIR
