#!/bin/bash

SPELLDIR=./
COURSE=$(basename $(pwd))
SPELL_CMD="aspell check --home-dir=$SPELLDIR"

if [ -L CHAPS ] ; then
    # branch for LFCW where there are modules directories; here CHAPS=MODULES
    for names in $(find CHAPS/"$COURSE"*  -name "*.tex")      
    do if [ -f $names ] && ! [ -L $names ] ; then 
	   echo $SPELL_CMD $names   
	   $SPELL_CMD  $names   
       fi
    done
else
    # branch for all stand alone courses with own git repos
    for names in $(find CHAPS  -name "*.tex")      
    do if [ -f $names ] && ! [ -L $names ] ; then 
	   echo $SPELL_CMD $names   
	   $SPELL_CMD  $names   
       fi
    done
fi




