Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ghost
Copy link

@ghost ghost 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.

@ghost
Copy link
Author

ghost commented May 12, 2022

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 :)

@ghost
Copy link
Author

ghost commented May 13, 2022

@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.

1 participant