Go 1.14 version check fails on Windows/amd64 #4960

Closed
opened 2025-11-02 06:09:09 -06:00 by GiteaMirror · 18 comments
Owner

Originally created by @filipnavara on GitHub (Feb 27, 2020).

  • Gitea version (or commit ref): a924a90349
  • Git version: 2.25
  • Operating system: Windows

Description

The check in make go-check fails because the regular expression for version extraction doesn't match the output of go version.

go version output is go version go1.14 windows/amd64 which cannot be matched with grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s'.

Originally created by @filipnavara on GitHub (Feb 27, 2020). - Gitea version (or commit ref): a924a90349a78ebe8e7eb560e435a7ddc1de9b84 - Git version: 2.25 - Operating system: Windows ## Description The check in `make go-check` fails because the regular expression for version extraction doesn't match the output of `go version`. `go version` output is `go version go1.14 windows/amd64` which cannot be matched with `grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s'`.
GiteaMirror added the issue/needs-feedback label 2025-11-02 06:09:09 -06:00
Author
Owner

@silverwind commented on GitHub (Feb 27, 2020):

The regex does match and it looks to be able to cope with 2-number versions too. I'm not sure what the issue exactly is.

$ printf "%03d%03d%03d" $(echo 'go version go1.13.4 linux/amd64' | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s' | tr '.' ' ')
001013004
$ printf "%03d%03d%03d" $(echo 'go version go1.14 windows/amd64' | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s' | tr '.' ' ')
001014000
@silverwind commented on GitHub (Feb 27, 2020): The regex does match and it looks to be able to cope with 2-number versions too. I'm not sure what the issue exactly is. ```console $ printf "%03d%03d%03d" $(echo 'go version go1.13.4 linux/amd64' | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s' | tr '.' ' ') 001013004 ``` ```console $ printf "%03d%03d%03d" $(echo 'go version go1.14 windows/amd64' | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s' | tr '.' ' ') 001014000 ```
Author
Owner

@filipnavara commented on GitHub (Feb 27, 2020):

Interesting, in MSYS I get this:

bash-3.1$ printf "%03d%03d%03d" $(echo 'go version go1.14 windows/amd64' | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s' | tr '.' ' ')
000000000
bash-3.1$

Perhaps an issue with escaping in the pattern vs command line escaping?

@filipnavara commented on GitHub (Feb 27, 2020): Interesting, in MSYS I get this: ``` bash-3.1$ printf "%03d%03d%03d" $(echo 'go version go1.14 windows/amd64' | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?\s' | tr '.' ' ') 000000000 bash-3.1$ ``` Perhaps an issue with escaping in the pattern vs command line escaping?
Author
Owner

@jolheiser commented on GitHub (Feb 27, 2020):

In Git Bash on Windows I get 001014000

@jolheiser commented on GitHub (Feb 27, 2020): In Git Bash on Windows I get `001014000`
Author
Owner

@filipnavara commented on GitHub (Feb 27, 2020):

I get the same garbage in Git Bash, let me check various tool versions to pinpoint which one breaks it.

@filipnavara commented on GitHub (Feb 27, 2020): I get the same garbage in Git Bash, let me check various tool versions to pinpoint which one breaks it.
Author
Owner

@filipnavara commented on GitHub (Feb 27, 2020):

Seems to be an issue with the grep in MSYS. I'll just close the issue, thanks for help.

@filipnavara commented on GitHub (Feb 27, 2020): Seems to be an issue with the `grep` in MSYS. I'll just close the issue, thanks for help.
Author
Owner

@filipnavara commented on GitHub (Feb 27, 2020):

For the record, the version of grep in Git Bash is 3.1. The one I had in my MSYS installation was version 2.5.4. The older version doesn't understand the \s syntax apparently, or interprets it incorrectly.

@filipnavara commented on GitHub (Feb 27, 2020): For the record, the version of `grep` in Git Bash is 3.1. The one I had in my MSYS installation was version 2.5.4. The older version doesn't understand the `\s` syntax apparently, or interprets it incorrectly.
Author
Owner

@zeripath commented on GitHub (Feb 27, 2020):

hmm... I think that means we should switch away from using \s as it won't work on non-GNU systems too.

@zeripath commented on GitHub (Feb 27, 2020): hmm... I think that means we should switch away from using \s as it won't work on non-GNU systems too.
Author
Owner

@zeripath commented on GitHub (Feb 27, 2020):

We should probably use \b

@zeripath commented on GitHub (Feb 27, 2020): We should probably use `\b`
Author
Owner

@filipnavara commented on GitHub (Feb 27, 2020):

\b doesn't work either. With Git Bash it matches both the version and "64" at the end. With the old MSYS grep it doesn't match anything. Putting a dumb (space) instead of \s works with both but not sure if it's reliable and future proof.

Given that version 2.5.4 is over a decade old and we don't have reports from any other system I'd just hope for the best and keep the current code.

@filipnavara commented on GitHub (Feb 27, 2020): `\b` doesn't work either. With Git Bash it matches both the version and "64" at the end. With the old MSYS grep it doesn't match anything. Putting a dumb ` ` (space) instead of `\s` works with both but not sure if it's reliable and future proof. Given that version 2.5.4 is over a decade old and we don't have reports from any other system I'd just hope for the best and keep the current code.
Author
Owner

@zeripath commented on GitHub (Feb 27, 2020):

The BSD users will complain about it too.

@zeripath commented on GitHub (Feb 27, 2020): The BSD users will complain about it too.
Author
Owner

@guillep2k commented on GitHub (Feb 27, 2020):

We should use egrep (a shortcut for grep -e) that supports the whole set of regexp syntax (grep's own, but all of it). grep without -e has a reduced set. BTW egrep has been around since Unix System V Release 4.

@guillep2k commented on GitHub (Feb 27, 2020): We should use `egrep` (a shortcut for `grep -e`) that supports the whole set of regexp syntax (grep's own, but all of it). `grep` without `-e` has a reduced set. BTW `egrep` has been around since [Unix System V Release 4](https://en.wikipedia.org/wiki/UNIX_System_V#SVR4).
Author
Owner

@silverwind commented on GitHub (Feb 27, 2020):

Maybe replace \s with (a single space). Will break on tab thought.

@silverwind commented on GitHub (Feb 27, 2020): Maybe replace `\s` with ` ` (a single space). Will break on tab thought.
Author
Owner

@silverwind commented on GitHub (Feb 27, 2020):

We should use egrep

Our grep -E is equivalent to egrep, at least on Linux.

@silverwind commented on GitHub (Feb 27, 2020): > We should use egrep Our `grep -E` is equivalent to `egrep`, at least on Linux.
Author
Owner

@zeripath commented on GitHub (Feb 27, 2020):

can do [ \t] as far as I can see. I'm just trying to find the appropriate manpages.

@zeripath commented on GitHub (Feb 27, 2020): can do [ \t] as far as I can see. I'm just trying to find the appropriate manpages.
Author
Owner

@guillep2k commented on GitHub (Feb 27, 2020):

Our grep -E is equivalent to egrep, at least on Linux.

Oh, doh! 🤦‍♂ Of course. I just felt like remembering the good old times, that's all.

@guillep2k commented on GitHub (Feb 27, 2020): > > Our grep -E is equivalent to `egrep`, at least on Linux. Oh, doh! 🤦‍♂ Of course. I just felt like remembering the good old times, that's all.
Author
Owner

@guillep2k commented on GitHub (Feb 27, 2020):

The problem is that we need to account for shell and make escaping our characters.

@guillep2k commented on GitHub (Feb 27, 2020): The problem is that we need to account for shell _and_ `make` escaping our characters.
Author
Owner

@zeripath commented on GitHub (Feb 27, 2020):

OK POSIX says that [:space:] should be supported in all locales so I think we can use that.

@zeripath commented on GitHub (Feb 27, 2020): OK POSIX says that [:space:] should be supported in all locales so I think we can use that.
Author
Owner

@zeripath commented on GitHub (Feb 27, 2020):

as in grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?[[:space:]]'

@zeripath commented on GitHub (Feb 27, 2020): as in `grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?[[:space:]]'`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4960