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

Enable multiline regexp mode for patterm matcher #861

Merged
merged 9 commits into from
May 13, 2022

Conversation

ihar-orca
Copy link
Contributor

@ihar-orca ihar-orca commented May 12, 2022

In the case of pattern comparison with the multiline string, an incorrect result may occur when the matched substring appears in the not first line.

Example:

#!/bin/bash

apache2_conf="/etc/httpd/conf/httpd.conf
/etc/apache2/httpd.conf"

if [[ "$apache2_conf" == */etc/apache2* ]]; then
  exit 0
else
  exit 1
fi

returns 1 because generated regexp ^.*/etc/apache2.*$ (interp/runner.go, func match()) is not multiline enabled.
this patch adds the (?m) flag into all autogenerated regexps in this function.

@ihar-orca
Copy link
Contributor Author

Sorry for multiple commits, it seems that it's not squashed on my side

@mvdan
Copy link
Owner

mvdan commented May 12, 2022

SGTM but please add a test :)

@ihar-orca
Copy link
Contributor Author

@mvdan test added

Copy link
Owner

@mvdan mvdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@mvdan
Copy link
Owner

mvdan commented May 13, 2022

This branch cannot be rebased due to conflicts

Not sure how you ended up there. Can you try squashing and rebasing your commits?

@mvdan
Copy link
Owner

mvdan commented May 13, 2022

Ah, ignore me, I can squash-merge.

@mvdan mvdan merged commit be03afe into mvdan:master May 13, 2022
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