#!/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" all=false shell="ssh $(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" if ! $all; then date=$($s <<'EOF' select max(date) from c where state = 'moderated' or state = 'banned' or state = 'picked'; EOF ) fi # we may want to avoid rate limited posts here too. sql="select * from c;" if [[ $date ]]; then sql+=" where date > cast('$date' as real)" fi echo "executing: $sql" $s > /tmp/hcomments <<<"$sql"