]> git.nbdom.net Git - nb.git/commitdiff
bin/dbq-vi
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 28 Aug 2024 22:46:29 +0000 (00:46 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 28 Aug 2024 22:46:29 +0000 (00:46 +0200)
bin/dbq-vi [new file with mode: 0755]

diff --git a/bin/dbq-vi b/bin/dbq-vi
new file mode 100755 (executable)
index 0000000..1666b0e
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+tmp=/tmp/$USER-dbq-vi-$$
+
+main() {
+       #exec echo $tmp
+       dbq.php "$1/vi/$2.sh" > "$tmp" || return
+
+       perl -i -pe 's/(\w+=".*?") /$1\n/g; s/;\s*$// ' "$tmp"
+
+       md5=$(md5sum "$tmp")
+
+       vi "$tmp"
+       [ -s "$tmp" ] || return 
+       [ "$md5" == "$(md5sum "$tmp")" ] && return 
+       bash -f "$tmp" || return
+       #exec echo $md5
+
+       eval dbq.php $1/update/ $(cat "$tmp")
+
+}
+
+if [ $# == 0 -o "$1" == "-h" ]
+then
+       cat <<EOF
+Usage: dbq-vi /db/table id
+EOF
+       exit
+fi
+main $@
+
+rm -f "$tmp"