Bug in __block type: cannot have to blocks with similar prefix #200

Closed
opened 2021-11-20 15:21:19 +00:00 by ungleich-gitea · 4 comments

Created by: telmich

Having those two blocks:

firewall_ip_web
firewall_ip_web_dmz

only the first block is created - I guess the problem is we don't match for line ending

*Created by: telmich* Having those two blocks: firewall_ip_web firewall_ip_web_dmz only the first block is created - I guess the problem is we don't match for line ending
Author
Owner

Created by: telmich

have it uncommitted lying around - will push in the next hours

*Created by: telmich* have it uncommitted lying around - will push in the next hours
Author
Owner

Created by: telmich

[15:39] artist:cdist% cat ~/test
abc
abc-def

[15:39] artist:cdist% awk '{ if(index($0, "abc")) print("ok") }' < ~/test
ok
ok

[15:39] artist:cdist% awk '{ if(match(0, "^abc")) print("ok") }' < ~/test
ok

*Created by: telmich* [15:39] artist:cdist% cat ~/test abc abc-def [15:39] artist:cdist% awk '{ if(index($0, "abc")) print("ok") }' < ~/test ok ok [15:39] artist:cdist% awk '{ if(match($0, "^abc$")) print("ok") }' < ~/test ok
Author
Owner

Created by: telmich

maybe match() is a better choice:

Returns either the position in s where the regular expression r begins, or 0 if no occurrences are found. Sets the values of RSTART and RLENGTH.

*Created by: telmich* maybe match() is a better choice: Returns either the position in s where the regular expression r begins, or 0 if no occurrences are found. Sets the values of RSTART and RLENGTH.
Author
Owner

Created by: telmich

Code:

awk -v prefix="$prefix" -v suffix="$suffix" '{
if (index($0,prefix)) {
triggered=1
}
if (triggered) {
if (index($0,suffix)) {
triggered=0
}
print
}

*Created by: telmich* Code: awk -v prefix="$prefix" -v suffix="$suffix" '{ if (index($0,prefix)) { triggered=1 } if (triggered) { if (index($0,suffix)) { triggered=0 } print }
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ungleich-public/cdist#200
No description provided.