mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #57805 from liggitt/test-grep-pipe-fix
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Avoid error on closed pipe fixes https://github.com/kubernetes/kubernetes/issues/57706 from @stevekuznetsov: > If you do `echo | grep -q`, `grep` will exit when it finds the first match > If the `echo` is still writing to stdout it fails because there's no reader on that pipe anymore > So we always use `grep -q <<<"${content}"` now > since that uses a FIFO ```release-note NONE ```
This commit is contained in:
commit
17ffacc37f
@ -265,7 +265,7 @@ kube::test::if_has_string() {
|
||||
local message=$1
|
||||
local match=$2
|
||||
|
||||
if echo "$message" | grep -q "$match"; then
|
||||
if grep -q "${match}" <<< "${message}"; then
|
||||
echo "Successful"
|
||||
echo "message:$message"
|
||||
echo "has:$match"
|
||||
@ -283,7 +283,7 @@ kube::test::if_has_not_string() {
|
||||
local message=$1
|
||||
local match=$2
|
||||
|
||||
if echo "$message" | grep -q "$match"; then
|
||||
if grep -q "${match}" <<< "${message}"; then
|
||||
echo "FAIL!"
|
||||
echo "message:$message"
|
||||
echo "has:$match"
|
||||
|
Loading…
Reference in New Issue
Block a user