#!/bin/sh
# PCP QA Test No. 1272
# pmlogmv with grep -E and sh meta chars in file names
#
# Copyright (c) 2020 Ken McDonell.  All Rights Reserved.
#

seq=`basename $0`
if [ $# -eq 0 ]
then
    echo "QA output created by $seq"
else
    echo "QA output created by $seq $*"
fi

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp $tmp.*
}

status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

# real QA test starts here
mkdir $tmp

cd $tmp

_do_it()
{
    rm -f foo*
    pmlogcp $here/tmparch/foo foo
    pmlogcp $here/tmparch/foo fool
    echo
    echo "=== $2 foo -> foo$1 ==="
    if pmlogmv -V $2 foo "foo$1"
    then
	ls
	echo "--- $2 foo$1 -> foo ---"
	if pmlogmv -V $2 "foo$1" foo
	then
	    ls
	fi
    fi
}

_do_it '?'
_do_it '?' -f
_do_it '*'
_do_it '*' --force
_do_it '$'
_do_it '$' -f
_do_it '[bar]'
_do_it '[bar]' --force
_do_it '+'
_do_it '{bar}'
_do_it '.'
_do_it '^'
_do_it '<x>'
_do_it '<x>' --force
_do_it '|'
_do_it '|' --force
_do_it ';'
_do_it ';' --force
_do_it '&'
_do_it '&' --force
_do_it 'foo bar'
_do_it 'foo bar' --force

# success, all done
status=0
exit
