2

I write simple bash script and run it:

#!/bin/bash
set -e

bq load --replace ...

and I get this error:

ERROR: permission denied for table message
WRITING LINES: 0

As we can see, we got an obvious error related to access. Why did the script end with 0 code?

Really when using gcloud or bq (and other google-family cli utils) need write catch errors in bash?

This method works and successfully “breaks” the execution on error:

#!/bin/bash
set -e

function error() {
  exitcode=$1
  shift
  echo "ERROR: exited with level $exitcode, error was '$@'" >&2
  kill -s TERM $TOP_PID
}

bq load --replace ...
responseCode=$?
if [[ $responseCode -eq 1 ]]; then
  error 1
fi

This important for me, I run scripts in Kubernetes (cronjob). Thanks

Arslanbekov Denis
  • 1,674
  • 12
  • 26
  • i have been trying to reproduce what you experienced, but couldn't. could you give more info about the script, and the big query permissions of the account that is making the request? what is your bash configuration? – asbovelw May 13 '20 at 14:50

0 Answers0