zyrikby / pyenv-pip-upgrade

Upgrade all packages to the latest versions in pyenv environments
Other
8 stars 4 forks source link

MacOS ZSH version? #8

Open thebrownjumper opened 1 year ago

thebrownjumper commented 1 year ago

In zsh there's no builtin readarray command, however it does have a one line expression which achieves the basic syntax of readarray -t.

myarray=("${(@f)$(command)}")

Are you looking to provide a macOS version of this plugin?

zyrikby commented 1 year ago

Hi @thebrownjumper! Actually, I use only Linux with bash, so I do not have a possibility to develop and test this tool for Mac (although, I think zsh should be the same in Linux and Mac). Moreover, I am not a big expert in this area, so I maybe not the right person to develop this plugin for Mac. However, I would be grateful if you can make it working for Mac as well.

costastf commented 4 months ago

this change fixed it on my M1

diff --git a/bin/pyenv-pip-upgrade b/bin/pyenv-pip-upgrade
index d59350f..8fd2d3d 100755
--- a/bin/pyenv-pip-upgrade
+++ b/bin/pyenv-pip-upgrade
@@ -56,7 +56,7 @@ function __element_in () {
 function pip_upgrade_packages () {
   # https://stackoverflow.com/a/3452888/1108213
   local outdated_packages=()
-  readarray -t outdated_packages < <(__pip list --outdated --format=freeze 2>/dev/null | awk 'match($0, /^(.+?)==/, arr) {print arr[1]}')
+  readarray -t outdated_packages < <(__pip list --outdated --format=freeze 2>/dev/null | gawk 'match($0, /^(.+?)==/, arr) {print arr[1]}')
   if [[ ${#outdated_packages[@]} -eq 0 ]]; then
     __msg_info "Nothing to update in this environment..."
     return

after an

 brew install gawk

ps: took the shortest way out.

costastf commented 4 months ago

Just a little more context, according to https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html

The array argument to match() is a gawk extension. In compatibility mode (see Command-Line Options), using a third argument is a fatal error. 

that is why i installed gawk on my M1.