#! /bin/sh -vx
# $Id: bibtex8.test 67881 2023-08-11 11:46:28Z takuji $
# Copyright 2017-2023 Karl Berry <tex-live@tug.org>
# Copyright 2010 Peter Breitenlohner <tex-live@tug.org>
# Copyright 2023 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
# You may freely use, modify and/or distribute this file.

BinDir=${BinDir:-.}
ExeExt=${ExeExt:-}
_bibtex8=$BinDir/bibtex8$ExeExt

test -d tests || mkdir -p tests

rc=0

rm -f tests/xex*.* # different filenames than bibtexu.test


cp $srcdir/../web2c/tests/exampl.aux tests/xexampl.aux || rc=1

TEXMFCNF=$srcdir/../kpathsea \
  BSTINPUTS=$srcdir/../web2c/tests \
  BIBINPUTS=$srcdir/../web2c/tests \
  $_bibtex8 -7 -s -d all tests/xexampl || test $? = 1 || rc=2
diff $srcdir/tests/exampl.bbl tests/xexampl.bbl || rc=3


LC_ALL=C; export LC_ALL; LANGUAGE=C; export LANGUAGE
TEXMFCNF=$srcdir/../kpathsea
BSTINPUTS=$srcdir/{../web2c/tests,csf}
BIBINPUTS=$srcdir/../web2c/tests
export TEXMFCNF BSTINPUTS BIBINPUTS


cp $srcdir/../web2c/tests/exampl.aux tests/xex_пробный.aux || rc=4

$_bibtex8 -7 -s -d io tests/xex_пробный || test $? = 1 || rc=5
diff $srcdir/tests/exampl.bbl tests/xex_пробный.bbl || rc=6


cp $srcdir/../web2c/tests/exampl.aux tests/xex_试验.aux || rc=7

$_bibtex8 -s -d io tests/xex_试验 || test $? = 1 || rc=8
diff $srcdir/tests/exampl.bbl tests/xex_试验.bbl || rc=9


## not exist, cause fatal error
$_bibtex8 -d io tests/xex_δίκη || test $? = 1 && rc=10


exit $rc
