#!@SH_PROG@
t=${0##*/}; TEST_NAME=${t:5}   # basename $0 with 'test-' stripped off

[ -z "$builddir" ] && export builddir=$PWD

. ${builddir}/check-common.sh

debugged_script="$top_srcdir/test/example/dbg-test2.sh"

(cd $srcdir && run_debugger $debugged_script 2>&1 >$TEST_FILE </dev/null)

# Different OS's handle ARGV differently, and "info args" may come out
# differently depending on that.
cat ${TEST_FILE} | @SED@ -e "s:1 = .*/dbg-test2.sh:1 = ./example/dbg-test2.sh:" \
| @SED@ -e 's:record the command history is .*:record the command history is: ' \
| @SED@ -e 's:step-:step+:' \
| @GREP@ -v '^set dollar0' > ${TEST_FILTERED_FILE}

if (( BASH_VERSINFO[0] == 5 )) ; then
    RIGHT_FILE="${top_srcdir}/test/data/${TEST_NAME}-output-50.right"
elif (( (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 1) )) ; then
    RIGHT_FILE="${top_srcdir}/test/data/${TEST_NAME}-output-41.right"
fi

check_output $TEST_FILTERED_FILE $RIGHT_FILE
rc=$?

((0 != rc)) && exit $rc
rm -f $TEST_FILE

# Return code tells testing mechanism whether passed or not.
exit 0
