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:
Kubernetes Submit Queue 2018-01-03 15:40:43 -08:00 committed by GitHub
commit 17ffacc37f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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