Reapply ijar race fix

Cloned from https://github.com/bazelbuild/bazel/pull/18146 that got
reverted by https://github.com/bazelbuild/bazel/commit/ecf1db0020ac139d10c5067cd0cbd1c2b53c67b6

PiperOrigin-RevId: 528784345
Change-Id: I06063c517a4e91b3ec49632483876a5baf5b20fe
diff --git a/third_party/ijar/test/ijar_test.sh b/third_party/ijar/test/ijar_test.sh
index 905d038..2c436cf 100755
--- a/third_party/ijar/test/ijar_test.sh
+++ b/third_party/ijar/test/ijar_test.sh
@@ -106,8 +106,8 @@
   local actual="$(cat $1 | ${MD5SUM} | awk '{ print $1; }')"
   local filename="$(echo $1 | ${MD5SUM} | awk '{ print $1; }')"
   local expected="$actual"
-  if (echo "${expected_output}" | grep -q "^${filename} "); then
-    echo "${expected_output}" | grep -q "^${filename} ${actual}$" || {
+  if (grep -q "^${filename} " <<<"${expected_output}"); then
+    grep -q "^${filename} ${actual}$" <<<"${expected_output}" || {
       ls -l "$1"
       fail "output file contents differ"
     }