#!/bin/bash -l # Copyright (C) 2016 Ian Kelling # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR cd "${BASH_SOURCE%/*}/proposed-comments" shell="ssh -oStrictHostKeyChecking=no $(chost iankelling.org)" while [[ $1 ]]; do case $1 in -a) all=true; shift ;; -l) shell= ; shift ;; # -l for local esac done s="$shell sqlite3 $PWD/comments.sqlite" grep -Eo '^[^|]+\|[^|]+' /tmp/hcomments | while IFS='|' read -r id state; do #echo "$id -- $state" # debug print if [[ $state == delete ]]; then $s <<<"delete from c where id = '$id';" else $s <<<"update c set state='$state' where id = '$id';" fi done $shell $PWD/../build.rb