Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace date with perl to fix get_time() on macOS #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Frederick888
Copy link
Contributor

The BSD date on macOS doesn't support %N. It just prints a literal N (e.g. '1738285044.N'), which breaks the awk command in get_cache_val(), stopping cached values from being updated.

Instead, I found this perl command at [1]. Tested on macOS, Arch Linux, and OpenWRT (which has a minimal perl distribution. By the way, BusyBox date doesn't support %N either but it just prints e.g. '1738285044.' without an 'N'. So while the awk command works, [2] didn't really improve the time precision here).

[1] https://apple.stackexchange.com/a/359718/254536
[2] https://github.com/tmux-plugins/tmux-cpu/pull/56/files#diff-e015cc3ac522b202bb23852488a7ac2c019e2c82568ecb387b97b60ebbecdf4bR72-R74

The BSD date on macOS doesn't support %N. It just prints a literal N
(e.g. '1738285044.N'), which breaks the awk command in get_cache_val(),
stopping cached values from being updated.

Instead, I found this perl command at [1]. Tested on macOS, Arch Linux,
and OpenWRT (which has a minimal perl distribution. By the way, BusyBox
date doesn't support %N either but it just prints e.g. '1738285044.'
without an 'N'. So while the awk command works, [2] didn't really
improve the time precision here).

[1] https://apple.stackexchange.com/a/359718/254536
[2] https://github.com/tmux-plugins/tmux-cpu/pull/56/files#diff-e015cc3ac522b202bb23852488a7ac2c019e2c82568ecb387b97b60ebbecdf4bR72-R74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant