agkozak/zsh-z

How do you recover from zshz divide by zero?

gelpenaddict opened this issue · 10 comments

> 
_zshz_update_datafile:30: division by zero                                                                                                                                                                
_zshz_update_datafile:36: division by zero

show up after every command, ie ls, pwd, or just pressing enter

I haven't seen that problem before. Could you try

mv ~/.z ~/.z.tmp

and see if it improves things? That would give you a fresh data file. If that helps, we can look at the old data file to see if it's been corrupted in some way. Thanks.

Thanks, I actually got rid of that vm instance and started over but hopefully the line numbers can help shed some light. The only other clue that might be helpful is that machine was running things in rapid succession. Feel free to close this ticket.

user@arch ~/.oh-my-zsh (git)-[master] % _zshz_update_datafile:30: bad math expression: operand expected at `/home/user...'
_zshz_update_datafile:36: bad math expression: operand expected at `/home/user...'

Encountered a similiar error,

mv ~/.z ~/.z.tmp

helped fixed the error.

@artisdom Could you show me the contents of the .z.tmp file? Thanks!

/home/user/w/l|13|1611304172
/mnt/t|17|1623446680
/usr/share/nginx/html|41|1617325291
/home/user/w/cc|4|1610156286
/home/user/p/cc/poco|12|1613557862
/mnt/w|16|1621635240
/home/user/w/qt|2|1618141403
/home/user/a|2|1612730835
/srv/http|2|1617264422
/srv/http/sysusage|6|1617264529
/var|1|1617264373
/home/user/p|5|1611304749
/home/user/w|38|1625832629
/usr/include|4|1615106959
/mnt|2|1621640845
/home/user/Downloads|42|1617404376
/etc/nginx|2|1614462251
/srv|2|1617264419
/home/user/w/l/compiledb|15|1611303961
/home/user/p/cc|11|1612744160
/|2|1617264416
/home/user/a/w/p|9|1614503241
/home/user/a/w|15|1617016008
/home/user/p/h|14|1615666747
/home/user/w/c|2|1611135199
/home/user/p/l|2|1611304741
/home/user/w/h|43|1617154623
/home/user/books

sure, I have removed some sensitive info from the file, and noticed the last line has a different format than the other lines,
I remembered the issue started when I'm upgrading my system but the root partition is full.

Also there're quite a few tmp files in my HOME folder, not sure if it's related.

-rw-r--r-- 1 user user     0 Jul 11 23:18 .z.28939
-rw-r--r-- 1 user user     0 Jul 17 17:13 .z.29570
-rw-r--r-- 1 user user     0 Jul 11 23:18 .z.29890
-rw-r--r-- 1 user user     0 Jul 11 23:28 .z.31126
-rw-r--r-- 1 user user     0 Jul 11 23:18 .z.31470
-rw-r--r-- 1 user user     0 Jul 11 23:17 .z.32230
-rw-r--r-- 1 user user     0 Jul 11 23:19 .z.32549
-rw-r--r-- 1 user user     0 Jul 15 22:45 .z.3732
-rw-r--r-- 1 user user     0 Jul 17 17:16 .z.3926
-rw-r--r-- 1 user user     0 Jul 13 22:48 .z.4062
-rw-r--r-- 1 user user     0 Jul 11 23:29 .z.4991
-rw-r--r-- 1 user user     0 Jul 11 23:17 .z.5006
-rw-r--r-- 1 user user     0 Jul 11 23:18 .z.5045
-rw-r--r-- 1 user user     0 Jul 11 23:19 .z.5164
-rw-r--r-- 1 user user     0 Jul 13 22:47 .z.6738
-rw-r--r-- 1 user user     0 Jul 17 17:15 .z.7619
-rw-r--r-- 1 user user     0 Jul 17 17:16 .z.8918
-rw-r--r-- 1 user user     0 Jul 17 17:16 .z.9823
-rw-r--r-- 1 user user     0 Jul 13 22:48 .z.9850

Cheers.

@artisdom curious how did you find this ticket when the error is different? Searched for _zshz_update_datafile?

Unsolicited opinion but I think the the line numbers from the initial ticket details should've been enough info to make a fix rather than closing earlier :)

Unsolicited opinion but I think the the line numbers from the initial ticket details should've been enough info to make a fix rather than closing earlier :)

It was your suggestion that we close the ticket, @gelpenaddict.

UPDATE: Your smiley emoticon suggests self-deprecating humor. Got it.

@artisdom Thanks for providing your data file. It was definitely the last, incomplete line that was causing the bad math expression. I will write some code to handle such abnormal database entries, probably by discarding them. Of course, it would be great to know how they are being created in the first place. I'll continue to think about that.

The temporary files are an unrelated issue. One of these days I may add a little code to remove them when necessary.

I've got a proposed workaround on the develop branch.

It simply discards incomplete or incorrectly formatted datafile lines. We can test it out for a bit.

All right. I've merged the fix to the master branch; you may switch back to using that. Thanks for bringing this issue to my attention.