#!/bin/sh # Tue Aug 28 23:33:58 EDT 2007, v0.01 sdy # Tue Sep 25 20:30:29 EDT 2007 # This program was created before the application itself supported CLI and # (CLI) editing. This will not be in v2+ ... RM="/bin/rm" CAT="/bin/cat" SED="/bin/sed" DATE="/bin/date" SQLITE3="sqlite3" TMPDIR="/tmp" EPOCH=`$DATE "+%s"` TMPFILE="$TMPDIR/$$.$EPOCH" DATABASE="/tmp/s.db" TABLE="data" DEFAULT_EDITOR="emacs -nw" VALUE="$@" test "x$VALUE" = "x" && { echo "Usage: $0 key" exit 1 } test "x$EDITOR" = "x" && { test "x$VISUAL" != "x" && { EDITOR="$VISUAL" } || { EDITOR="$DEFAULT_EDITOR" } } $RM -f "$TMPFILE" $SQLITE3 "$DATABASE" "SELECT value FROM $TABLE WHERE key='$VALUE'" > $TMPFILE $EDITOR "$TMPFILE" $SED "s/'/''/g" <"$TMPFILE" >"$TMPFILE.2" # $SQLITE3 "$DATABASE" "UPDATE $TABLE SET value='`$CAT "$TMPFILE.2"`' WHERE key='$VALUE'" $SQLITE3 "$DATABASE" "DELETE FROM $TABLE WHERE key='$VALUE'" $SQLITE3 "$DATABASE" "INSERT INTO $TABLE values('$VALUE','`$CAT "$TMPFILE.2"`');" $RM -f "$TMPFILE" "$TMPFILE.2"