|
|
@ -37,6 +37,13 @@ else |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
awk -v position="$position" -v needle="$needle" ' |
|
|
|
awk -v position="$position" -v needle="$needle" ' |
|
|
|
|
|
|
|
function _find(_text, _pattern) { |
|
|
|
|
|
|
|
if (needle == "regex") { |
|
|
|
|
|
|
|
return match(_text, _pattern) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return index(_text, _pattern) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
BEGIN { |
|
|
|
BEGIN { |
|
|
|
getline anchor < (ENVIRON["__object"] "/parameter/" position) |
|
|
|
getline anchor < (ENVIRON["__object"] "/parameter/" position) |
|
|
|
getline pattern < (ENVIRON["__object"] "/parameter/" needle) |
|
|
|
getline pattern < (ENVIRON["__object"] "/parameter/" needle) |
|
|
@ -46,7 +53,7 @@ BEGIN { |
|
|
|
if (position == "after") { |
|
|
|
if (position == "after") { |
|
|
|
if (match($0, anchor)) { |
|
|
|
if (match($0, anchor)) { |
|
|
|
getline |
|
|
|
getline |
|
|
|
if (match($0, pattern)) { |
|
|
|
if (_find($0, pattern)) { |
|
|
|
state = "present" |
|
|
|
state = "present" |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
@ -56,7 +63,7 @@ BEGIN { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (position == "before") { |
|
|
|
else if (position == "before") { |
|
|
|
if (match($0, pattern)) { |
|
|
|
if (_find($0, pattern)) { |
|
|
|
getline |
|
|
|
getline |
|
|
|
if (match($0, anchor)) { |
|
|
|
if (match($0, anchor)) { |
|
|
|
state = "present" |
|
|
|
state = "present" |
|
|
@ -68,7 +75,7 @@ BEGIN { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (match($0, pattern)) { |
|
|
|
if (_find($0, pattern)) { |
|
|
|
state = "present" |
|
|
|
state = "present" |
|
|
|
exit 0 |
|
|
|
exit 0 |
|
|
|
} |
|
|
|
} |
|
|
|