iterm2_shell_integration.zsh "bad FP constant" bug
Bug report
Thanks for filing an issue! Please answer the questions below so I can help you.
- iTerm2 version: 3.4.18
- OS version: 12.6.1
(plist file not applicable here)
Detailed steps to reproduce the problem
- Install shell integration
- open a new iTerm2 tab/window
What happened
Above the shell prompt in new tabs/windows, error message appears:
/Users/<username>/.iterm2_shell_integration.zsh:32: bad floating point constant
What should have happened
There shouldn't have been an error message.
It looks like the bug is that printf's floating point formatter doesn't understand the 3 part version string. While zsh has is-at-least
[1] for comparing version numbers, for portability with bash, a little bit of awk can fix it right up.
--- ver=$(printf "%.0f" $(sw_vers | grep ProductVersion | cut -d':' -f2 | tr -d ' ' | sed -e 's/ //g'))
+++ ver=$(printf "%.0f" $(sw_vers | awk -F'[:.]' '/ProductVersion/ {print $2}'))
This has awk break up the version string and only the major version number is passed to printf. (Technically speaking, either printf
or a pipe to tr -d '[:space:]'
would work the same but only one is necessary.)
[1] https://linux.die.net/man/1/zshcontrib