Skip to content

Commit

Permalink
Check exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scavo committed Oct 30, 2016
1 parent 6c7c765 commit bc5f2ac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bin/cget.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ if [ -z "$CACHE_DIR" ]; then
exit 2
fi
if [ ! -d "$CACHE_DIR" ]; then
# think carefully about this...
/bin/mkdir "$CACHE_DIR"
exit_code=$?
if [ $exit_code -ne 0 ]; then
Expand Down Expand Up @@ -203,6 +202,7 @@ else
TMP_DIR="${tmp_dir%%/}/${script_name%%.*}"
$verbose_mode && printf "$script_name creating temp dir: %s\n" "$TMP_DIR"
fi
# create a subdirectory
if [ ! -d "$TMP_DIR" ]; then
/bin/mkdir "$TMP_DIR"
exit_code=$?
Expand Down Expand Up @@ -234,5 +234,12 @@ if [ $exit_code -ne 0 ]; then
fi
$verbose_mode && printf "$script_name successfully obtained resource: %s\n" "$tmp_file"

# output the resource
/bin/cat "$tmp_file"
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "ERROR: ${script_name} unable to cat output with status code: $exit_code" >&2
exit 3
fi

exit 0

0 comments on commit bc5f2ac

Please sign in to comment.