Alright, so this is my first bash program, and I'm really lost on this one. the summary test takes 0-2 args and returns 'same' or 'different' depending on the cmp exit status.
What I was to do is put all .outs into one variable and all .stds inside another. then I want to iterating the two variables for occurrences:
if I have a .out but not a .std by the same basename, I want to print 'missing file.std'
If I have all correspond file.out and file.std files contain the same contents I return 'all cases passed'
if cmp fails I count the number of times it fails (that is the number of times file.out and file.std are different)
If there is 1 argument $1 holds all .out and .std files
if there is 2 args $1 holds .out and $2 holds .std
otherwise we use current directory
The problem I'm having is my outputs are weird. my 0 arg outputs are like ./file different and my 1 arg outputs are file.out./* and my arg 2 says missing file.out/*.std Does anyone know what's going on?
T=*.out
S=*.std
if [[ $# = 1 ]]; then
T=$1
S=$1
fi
if [[ $# = 2 ]]; then
T=$1
S=$2
fi
N=0
fin=0
for i in $T/*; do
count=0
for j in $S/*; do
if [[ ${i%.out} = ${j%.std} ]]; then
if cmp -s $i $j; then
echo ${i%.out} same
else
let N=$N+1
echo ${i%.out} different
fi
else
let count=$count+1
if [[ $count=${#y} ]]; then
let fin=$count
F=${i%.out}.std
fi
fi
done
done
if [[ $fin = 0 ]]; then
if [[ N = 0 ]]; then
echo all tests succeeded
else
echo $N tests failed
fi
else
echo missing file: $F
fi