* Better Patch for Configfile handling
[opeanno-debian-packaging.git] / development / sqlite-dump-diff-util.sh
blob849f3ee5d87c0fb000f0f6f5702f47839767a67f
1 #!/bin/bash
3 # requirements: sqlite3 binary
4 # usage: sqlite-dump-diff-util.sh <file1> <file2> <command with [1] and [2] as place holders>
5 # kdesvn-example: sqlite-dump-diff-util.sh %1 %2 kompare -c [1] [2]
6 # what it does: check if one of first two arguments is sqlite file, if so - create a dump of both and replace [1] and [2] with the dump files - else replace [1] and [2] with the unchanged first two arguments - execute the command
8 f1="$1"
9 o1="$1"
11 f2="$2"
12 o2="$2"
14 shift
15 shift
16 args="$@"
18 if file -b "$f1" "$f2" | grep -i 'sqlite 3' >/dev/null; then
19 f1="`tempfile`"
20 sqlite3 "$o1" .dump > "$f1"
21 f2="`tempfile`"
22 sqlite3 "$o2" .dump > "$f2"
24 args="${args//'[1]'/$f1}"
25 args="${args//'[2]'/$f2}"
26 $args
27 [ "$o1" != "$f1" ] && rm "$f1"
28 [ "$o2" != "$f2" ] && rm "$f2"