Adjust run test for target runs.

Test: 172-app-image-twice
Bug: 77342775
Bug: 79200502
Change-Id: I8a1c5ef775e40f0596f2f183aa32ea307b8ae93b
diff --git a/test/172-app-image-twice/run b/test/172-app-image-twice/run
index d1ad043..aa28190 100644
--- a/test/172-app-image-twice/run
+++ b/test/172-app-image-twice/run
@@ -16,5 +16,13 @@
 
 # Build an app image with TestClass (specified by profile) and class loader
 # context that skips the duplicate class checks.
-exec ${RUN} $@ --profile -Xcompiler-option --compiler-filter=speed-profile \
-    -Xcompiler-option --class-loader-context=\&
+
+# Target and host use a different shell, and we need to special case the
+# passing of the class loader context marker.
+if [[ "$@" = *" --host "* ]]; then
+  ${RUN} $@ --profile -Xcompiler-option --compiler-filter=speed-profile \
+      -Xcompiler-option --class-loader-context=\&
+else
+  ${RUN} $@ --profile -Xcompiler-option --compiler-filter=speed-profile \
+      -Xcompiler-option '--class-loader-context=\&'
+fi