Kurt Peek
Kurt Peek

Reputation: 57771

What would be the purpose of 'set -e' without any arguments?

I'm trying to write a Bash script to control startup order in Docker Compose, similar to the example script given on https://docs.docker.com/compose/startup-order/:

#!/bin/bash
# wait-for-postgres.sh

set -e

host="$1"
shift
cmd="$@"

until psql -h "$host" -U "postgres" -c '\l'; do
  >&2 echo "Postgres is unavailable - sleeping"
  sleep 1
done

>&2 echo "Postgres is up - executing command"
exec $cmd

I'm trying to understand what the purpose is of the first line, set -e. The usage from the man page reads

set ( -e | --erase ) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]...

Without a VARIABLE_NAME, what does this command do? Nothing I guess?

Upvotes: 0

Views: 85

Answers (1)

hek2mgl
hek2mgl

Reputation: 158250

Not sure what you are referring to. Read help set:

-e Exit immediately if a command exits with a non-zero status.

Upvotes: 2

Related Questions