Cover V05, I10
Article
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5

oct96.tar


Listing 4: build

#! /bin/bash -
#  FILENAME: build
#  This script builds an html file putting standard headers and footers around
#  a raw html-formatted file. Two languages are supported (English and
#  national) for html file publication.
#  For variable definition see setvar file.
#
# Luca Salvadori  1996
#
# Setting global environment variables
. setvar
DEFFILE='*.htm'
#
# Parsing input arguments
#
# Help routine
case $1 in
-h|-H|--help)
echo "Usage: build [file [lang]]"
echo "Where file is the file(s) to build, lang is the
language to use."
exit;;
"")
echo -n "Enter file to build (default=*.htm): "
read FILE
FILE=${FILE:-${DEFFILE}}
;;
*)
FILE=$1
;;
esac
# Selecting languages
case $2 in
"")
echo -n "Enter language (default=$BASE_LANG): "
read LANG
LANG=${LANG:-$BASE_LANG}
;;
*)
LANG=$2
;;
esac
# Parsing languages
case $LANG in
$BASE_LANG|$OTHER_LANG)
;;
*)
echo "ERROR - Language \"$LANG\" is not supported"
exit 1
;;
esac
# here begins the real stuff
for file in ${FILE}
do
if [ ! -f ${file} ]
then
echo "ERROR - $file does not exist."
exit 1
fi
# Saving original file, just in case...
mv $file $file.$$
echo -n "Building $file... "
# Building final file by appending header, raw file and footer.
cat \
$BASEDIR/models/top_$LANG.htm \
$file.$$ \
$BASEDIR/models/bot_$LANG.htm \
>> $file
# Cleanup before exiting
rm $file.$$
echo "Done."
done
exit