title: How to correctly use `gsutil -q stat` in scripts?
body: <p>I am creating a KSH script to check whether a subdirectory is exist on GCS bucket. I am writing the script like this:</p>
  
  <pre><code>#!/bin/ksh
  
  set -e
  set -o pipefail
  
  gsutil -q stat ${DESTINATION_PATH}/
  PATH_EXIST=$?
  if [ ${PATH_EXIST} -eq 0 ] ; then
     # do something
  fi
  </code></pre>
  
  <p>Weird thing happens when the <code>${DESTINATION_PATH}/</code> does not exist, the script exit without evaluating <code>PATH_EXIST=$?</code>. If <code>${DESTINATION_PATH}/</code> is exist, the script will run normally as expected.</p>
  
  <p>Why does that thing happen? How can I do better?</p>