asdf-community/asdf-php

Regular expression parsing error when listing versions

Closed this issue · 1 comments

Provide environment information

OS:
Linux funnie 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
zsh 5.9 (x86_64-ubuntu-linux-gnu)

BASH VERSION:
5.2.15(1)-release

ASDF VERSION:
v0.13.1-0586b37

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/home/bruno/.asdf
ASDF_DIR=/home/bruno/.asdf
ASDF_CONFIG_FILE=/home/bruno/.asdfrc

ASDF INSTALLED PLUGINS:
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master c5b7c40
php                          https://github.com/asdf-community/asdf-php.git master 1eaf4de

To Reproduce

asdf list all php

Describe the Bug

When typing this command below:

asdf list all php

I receive the error:

Plugin php's list-all callback script failed with output:
awk: line 1: regular expression compile failed (bad interval expression)
({})

This is a crystal clean Ubuntu 23.10 installation.

Expected Behaviour

List all latest PHP versions, eg:

...
8.3.0beta1
8.3.0beta2
8.3.0beta3
8.3.1RC1-clean
8.3.1
8.3.1RC1
8.3.1RC2
8.3.1RC3
...

I just found how to fix the issue. It seems that in Ubuntu 23.10 version it's using 'mawk' instead of 'gawk'. The easy and quick fix would be just installing 'gawk' with the command below:

sudo apt install -y gawk

I don't know how this impact the whole system, but you can still switch easily between awk versions with the update-altenatives command, eg:

update-alternatives --config awk

Still, a possible fix for this would be

diff --git a/bin/list-all b/bin/list-all
index 3c5c3e0..a867dbf 100755
--- a/bin/list-all
+++ b/bin/list-all
@@ -10,7 +10,7 @@ sort_versions() {
 versions=$(
   git ls-remote --tags https://github.com/php/php-src.git |
     grep 'php-' |
-    awk '!/({})/ {print $2}' |
+    awk '!/(\{\})/ {print $2}' |
     sed 's/refs\/tags\/php-//' |
     sort_versions |
     xargs