caniuse.plugin.zsh
caniuse.plugin.zsh copied to clipboard
Error when using with Python 3.7
Hi,
I tried this but when I enter :
caniuse webgl
I have an error :
File "<string>", line 1
import sys, urllib as ul; print ul.quote('webgl');
^
SyntaxError: invalid syntax
and your script opens CanIUse without any search.
It works just fine with Python 2.7.16.
For me (with Arch Linux, Python 3.7), it works by changing the line
https://github.com/walesmd/caniuse.plugin.zsh/blob/acb4a280848b7a539dd03dbe5a1959829fcf3a61/caniuse.plugin.zsh#L19
to
query=$(python -c "import sys, urllib.parse as ul; print(ul.quote('${term}'));")
Since it's probably on purpose that this keeps with Python 2 (to my knowledge, it comes pre-installed with macOS?, for which the script is developed, according to the README), that'll have to be a manual change in different environments, though. It could also be feasible to check the python version in the script, but for now, changing that line if you're having Python 3 as python
should do the trick (and shouldn't be too difficult for the user base caring for extensions for shells :wink:)...
It might be good to note this (i.e., the supported Python version and, optionally, also the fix for Python 3) in the README, though...
PS: I've also set an alias to open to get this to work on Linux, as open
is macOS-specific:
alias open='xdg-open'