forked from TheShadowblast123/VimbreWriter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.sh
More file actions
executable file
·24 lines (18 loc) · 742 Bytes
/
compile.sh
File metadata and controls
executable file
·24 lines (18 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
#
#
# "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; s/\"/\"/g" "$1"`
xbafile="$2"
name="`basename "$xbafile" \".xba\"`"
XBA_TEMPLATE='<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">\n<script:module xmlns:script="http://openoffice.org/2000/script" script:name="%s" script:language="StarBasic">\n%s\n</script:module>'
printf "$XBA_TEMPLATE" "$name" "$src" > "$xbafile"
}
if [ "$#" -ne 2 ]; then
echo "Usage: $0 SOURCE DESTINATION"
else
compile "$1" "$2"
fi