mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Instead its content is moved to gnucash directly, making the gnucash directory more meaningful.
49 lines
1.2 KiB
Bash
Executable File
49 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# This script strips data elements from a gnucash data file that have
|
|
# been introduced in the trunk version of gnucash, but are not
|
|
# backwards-compatible to older versions of gnucash.
|
|
|
|
ORIGFILE=$1
|
|
ORIGTMPFILE="${ORIGFILE}.gunzip"
|
|
BKUPFILE="${ORIGFILE}.bkp.gz"
|
|
TMPFILE="${ORIGFILE}.tmp"
|
|
|
|
if [ -f ${ORIGFILE} ] ; then
|
|
|
|
# Detect compression
|
|
in_gzip_format=yes
|
|
gzip -ql ${ORIGFILE} > /dev/null 2> /dev/null || in_gzip_format=no
|
|
|
|
# Uncompress the file
|
|
if [ "$in_gzip_format" = "yes" ] ; then
|
|
gunzip -cd ${ORIGFILE} > ${ORIGTMPFILE}
|
|
else
|
|
cat ${ORIGFILE} > ${ORIGTMPFILE}
|
|
fi
|
|
|
|
# Remove the elements that are not backwards-compatible
|
|
grep -v '<sx:enabled>.</sx:enabled>' ${ORIGTMPFILE} > ${TMPFILE}
|
|
|
|
# Print result of element removal
|
|
echo "Removed the following elements:"
|
|
diff -u ${ORIGTMPFILE} ${TMPFILE}
|
|
echo "Keeping old data file as \"${BKUPFILE}\""
|
|
|
|
# Compress the result again
|
|
if [ "$in_gzip_format" = "yes" ] ; then
|
|
gzip -c ${ORIGTMPFILE} > ${BKUPFILE}
|
|
gzip -c ${TMPFILE} > ${ORIGFILE}
|
|
else
|
|
cat ${ORIGTMPFILE} > ${BKUPFILE}
|
|
cat ${TMPFILE} > ${ORIGFILE}
|
|
fi
|
|
|
|
# Remove temporary files
|
|
rm ${ORIGTMPFILE}
|
|
rm ${TMPFILE}
|
|
|
|
else
|
|
echo "$0: File $1 not found."
|
|
fi
|