Skip to content

Commit

Permalink
Fix #45, per PR #46
Browse files Browse the repository at this point in the history
  • Loading branch information
larkery committed May 29, 2019
1 parent b97cc0c commit 0a7a52a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* News
- 29/05/19 :: Thanks to Matthias Bilger (https://github.com/m42e/) a bug has been removed which would have broken the database if the vacuum command were used. Turns out, you can't use rowid as a foreign key unless you've given it a name. As a side-effect your database will need updating, in a non-backwards compatible way, so you'll need to update on all your installations at once if you share a history file.
Also, it's not impossible that this change will make a problem for someone somewhere, so be careful with this update.

Also thanks to Matthias, the exit status of long-running commands is handled better.
- 05/04/18 :: I've done a bit of work to make a replacement reverse-isearch function, which is in a usable state now.

If you want to use it, see the [[Reverse isearch]] section below which now covers it.
Expand Down
18 changes: 10 additions & 8 deletions sqlite-history.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ fi
typeset -g HISTDB_SESSION=""
typeset -g HISTDB_HOST=""
typeset -g HISTDB_INSTALLED_IN="${(%):-%N}"
typeset -g HISTDB_AWAITING_EXIT=0

sql_escape () {
sed -e "s/'/''/g" <<< "$@" | tr -d '\000'
Expand Down Expand Up @@ -59,12 +58,16 @@ fi
histdb-update-outcome () {
local retval=$?
local finished=$(date +%s)
if [[ $HISTDB_AWAITING_EXIT == 1 ]]; then
_histdb_init
_histdb_query "update history set exit_status = ${retval}, duration = ${finished} - start_time
where id = (select max(id) from history) and session = ${HISTDB_SESSION}"
HISTDB_AWAITING_EXIT=0
fi

_histdb_init
_histdb_query <<EOF
update history set
exit_status = ${retval},
duration = ${finished} - start_time
where id = (select max(id) from history) and
session = ${HISTDB_SESSION} and
exit_status is NULL;
EOF
}

zshaddhistory () {
Expand Down Expand Up @@ -99,7 +102,6 @@ where
places.host = ${HISTDB_HOST} and
places.dir = ${pwd}
;"
HISTDB_AWAITING_EXIT=1
fi
return 0
}
Expand Down

0 comments on commit 0a7a52a

Please sign in to comment.