Replace date with perl to fix get_time() on macOS#97
Open
Frederick888 wants to merge 1 commit intotmux-plugins:masterfrom
Open
Replace date with perl to fix get_time() on macOS#97Frederick888 wants to merge 1 commit intotmux-plugins:masterfrom
Frederick888 wants to merge 1 commit intotmux-plugins:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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