#!/bin/sh query() { sqlite3 vote.sq3 "$@" } if [ -n "$1" -a -n "$2" ]; then # $1 と $2 ともに空でなければ query "REPLACE INTO ballotbox values('$1', '$2');" elif [ x"$1" = x"-s" ]; then # -s オプションは集計 query "SELECT cand,count(cand) cn FROM ballotbox \ GROUP BY cand ORDER BY cn DESC;" elif [ x"$1" = x"-l" ]; then # -l オプションは一覧出力 query "SELECT * from ballotbox ORDER BY voter;" else cat<<-EOF Usage: Add record: $0 "Voter" OneOfCandidates List all records: $0 -l Show summation of price: $0 -s EOF fi