Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generate_config.sh version checking for wider compatibility #6270

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

digitalhen
Copy link

fix: replace grep -oP with grep -oE for broader compatibility

The -P option (Perl-compatible regex) is not supported in all versions of grep, particularly the default BSD grep on macOS. This change replaces -P with -E (extended regex), which is more widely available and ensures compatibility across different environments.

Tested on macOS and Linux.

Contribution Guidelines

What does this PR include?

Short Description

This PR replaces grep -oP with grep -oE to improve compatibility across different environments. The -P option (Perl-compatible regex) is not supported in all versions of grep, particularly the default BSD grep on macOS. The script fails in its current format on MacOS. Using -E (extended regex) ensures broader support while maintaining the intended functionality.

Affected Containers

None (this is a script change, not a change to Docker containers).

Did you run tests?

What did you test?

Tested the updated command on both macOS and Linux to ensure it extracts the major version correctly.

What were the final results? (Expected, actual)

Expected: The command should return only the major version number from docker --version.
Actual: The command correctly returns the major version number on both macOS and Linux.

fix: replace `grep -oP` with `grep -oE` for broader compatibility

The `-P` option (Perl-compatible regex) is not supported in all versions of `grep`, particularly the default BSD `grep` on macOS. This change replaces `-P` with `-E` (extended regex), which is more widely available and ensures compatibility across different environments.

Tested on macOS and Linux.
@DerLinkman
Copy link
Member

You know that we do not support macOS right?

@digitalhen
Copy link
Author

This was the only line preventing it working on my Mac. Would be great if it could be included -- would diversify where the container can run -- even if unsupported.

@DerLinkman
Copy link
Member

On which Linux did you tested this?

@digitalhen
Copy link
Author

I tested on CentOS, but I see it doesn't work on Ubuntu. A more universal approach would be this. This works on Ubuntu, MacOS, CentOS.

docker version --format '{{.Server.Version}}' | cut -d '.' -f 1

@DerLinkman
Copy link
Member

Yes your last approach works better it seems.

Can you update your pr?

Replaced version checking using free-form text. Instead, uses Docker’s built-in templating instead of parsing free-form text. This gives cross-platform consistency without dependency on particular versions of grep.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants