Bail and warn if merged histfile is a file reduction
This commit is contained in:
parent
2424e2210f
commit
bbe841e8ec
|
@ -160,8 +160,13 @@ function sync-history {
|
||||||
fi
|
fi
|
||||||
echo "Merging history files..."
|
echo "Merging history files..."
|
||||||
fc -W # Write to history file
|
fc -W # Write to history file
|
||||||
merge-hist "$HOME/.histfile" "$HOME/.tmp/.histfile" > "$HOME/.tmp/$(whoami).histfile"
|
local merged_name="$HOME/.tmp/$(whoami).histfile"
|
||||||
mv "$HOME/.tmp/$(whoami).histfile" "$HOME/.histfile"
|
merge-hist "$HOME/.histfile" "$HOME/.tmp/.histfile" > "$merged_name"
|
||||||
|
if ! (($(cat "$merged_name" | wc -l) > $(cat "$HOME/.tmp/.histfile" | wc -l))); then
|
||||||
|
echo "Merged histfile '$merged_name' somehow smaller than current histfile"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
mv "$merged_name" "$HOME/.histfile"
|
||||||
fc -R # Read from new history file
|
fc -R # Read from new history file
|
||||||
echo "Uploading new shared history..."
|
echo "Uploading new shared history..."
|
||||||
tscp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile'
|
tscp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile'
|
||||||
|
|
Loading…
Reference in New Issue