#!/bin/sh # # "Compile" BASIC macro file to LibreOffice-compatible xba file # compile SRC DESTINATION compile() { # Escape XML &<>'" src=`sed "s/\&/\&/g; s//\>/g; s/'/\'/g; s/\"/\"/g" "$1"` xbafile="$2" name="`basename "$xbafile" \".xba\"`" XBA_TEMPLATE='\n\n\n%s\n' printf "$XBA_TEMPLATE" "$name" "$src" > "$xbafile" } if [ "$#" -ne 2 ]; then echo "Usage: $0 SOURCE DESTINATION" else compile "$1" "$2" fi