#!/bin/bash
pname=`basename "$0"`
dname=`dirname  "$0"`

case "$dname" in
/*)
    ;;
*)
    dname="$(pwd)/$dname"
    ;;
esac

verbose=0

nodef=
noded=
nodel=/tmp/nodes.$$.el
tmpwd=/tmp/nodes.$$.pwd.el
#trap "rm -f ${nodel} ${tmpwd}" exit


function usage {
    echo "${pname} usage:"
    echo ""
    echo "    ${pname} [-v|--verbose] node-file"
    echo ""
}

function docmd {
    if [ $verbose -ne 0 ] ; then
        echo "$@"
    fi
    $@
}

for arg ; do
    case "$arg" in
    -v|--verbose)
        verbose=1
        ;;
    -*)
        echo "${pname}: unknown option ${arg}."
        usage
        exit 1
        ;;
    *)
        if [ "$nodef" = "" ] ; then
            nodef=`basename "$arg"`
            noded=`dirname "$arg"`
        else
            echo "${pname}: too many arguments."
            usage
            exit 1
        fi
        ;;
    esac
done



docmd cd "$noded"
# removing excess backups:
find . -name \*~ -exec rm -f {} \;
# publication web...
docmd umask 022

#( echo "(setq nodes '(" ;\
#  sed -e 's/#.*//' -e '/^[ 	]*$/d' -e 's/^\(.*\)$/"\1"/' < "$nodef" ;\
#  echo "))" ) > "$nodel"

echo '(setq nodes-dir "'`pwd`'")' > "$tmpwd"
echo 'Starting emacs processing...'
docmd emacs --debug-init --batch -q -l "$tmpwd" -l "$nodef" -l "$dname"/html-update.el
docmd echo rm -f "$nodel" "$tmpwd"

exit 0
#### html-update                      -- 2003-05-22 08:30:24 -- pascal   ####
ViewGit