jonmosco / kube-ps1

Kubernetes prompt info for bash and zsh
Apache License 2.0
3.52k stars 351 forks source link

_kube_ps1_file_newer_than:16: division by zero #159

Closed nareshku closed 2 years ago

nareshku commented 2 years ago

Using kube-ps1 on my Linux machine with zsh and found that zstat doesn't output nanoseconds leading to error _kube_ps1_file_newer_than:16: division by zero

zstat +mtime -F %s.%N ~/kube/config
1658797744.%N

Full output of zstat

zstat ~/.kube/config
device  64768
inode   68653976
mode    33152
nlink   1
uid     37543
gid     101
rdev    0
size    18637
atime   1658797746
mtime   1658797744
ctime   1658797744
blksize 4096
blocks  40
link

We should probably get the OS type and convert command zstat +mtime -F %s.%N to zstat +mtime -F %s if it is Linux here

jonmosco commented 2 years ago

Interesting. Which version of zsh are you using? I am running Linux and tested on different distributions without that issue:

$ zsh --version
zsh 5.8 (x86_64-ubuntu-linux-gnu)                                             
testuser at dev-box in ~ 

$ zstat +mtime -F %s.%N ~/.kube/config          
1658946238.553962684                                           
testuser at dev-box in ~ 
$ 
nareshku commented 2 years ago
zsh --version
zsh 5.0.2 (x86_64-redhat-linux-gnu)
jonmosco commented 2 years ago

Wow, ok. This version was released almost 10 years ago: 2012-12-21. I assume you are on an older version of RHEL? The nanosecond precision was introduced around version 5.5. I will add a condition for older versions of ZSH but would definitely suggest upgrading your shell at some point.

astraw99 commented 2 years ago

I also got this issue:

_kube_ps1_file_newer_than:15: division by zero
zsh --version
zsh 5.0.2 (x86_64-redhat-linux-gnu)