Use "grep -xF ... >/dev/null" instead of "grep -qxF ..."
authorTom Clegg <tom@curoverse.com>
Mon, 2 May 2016 21:13:35 +0000 (17:13 -0400)
committerTom Clegg <tom@curoverse.com>
Mon, 2 May 2016 21:13:35 +0000 (17:13 -0400)
1. -q "Exit immediately with zero status if any match is found, even if
an error was detected." --grep(1)

Depending on buffering and timing, if grep exits early (before
consuming stdin) "docker images" can receive SIGPIPE and exit
non-zero. We use "set -o pipefail" here, so this fails the "docker
load" phase and then the whole job.

2. "Portable shell scripts should avoid both -q and -s and should
redirect standard and error output to /dev/null instead." --grep(1)

No issue #

sdk/cli/bin/crunch-job

index 149d20b1d887369027a313d360dd013bdfbc0933..39238b0fc649d400a380e397c8f0520fbc75b476 100755 (executable)
@@ -416,7 +416,7 @@ if ($docker_locator = $Job->{docker_image_locator}) {
   Log (undef, "docker image hash is $docker_hash");
   $docker_stream =~ s/^\.//;
   my $docker_install_script = qq{
-if $docker_bin images -q --no-trunc --all | grep -qxF \Q$docker_hash\E; then
+if $docker_bin images -q --no-trunc --all | grep -xF \Q$docker_hash\E >/dev/null; then
     exit 0
 fi
 declare -a exit_codes=("\${PIPESTATUS[@]}")