What is the `<< - EOSQL` code block in Bash when running SQL?

I need to run a bash script containing SQL, so I use a script to add custom configurations to the Postgres Docker container according to the docs here:

https://github.com/docker-library/docs/tree/master/postgres#how-to-extend-this-image

But I do not know what it means EOSQL. Here is an example of my script taken from the docs above:

#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
    CREATE USER docker;
    CREATE DATABASE docker;
    GRANT ALL PRIVILEGES ON DATABASE docker TO docker;
    CREATE EXTENSION $MY_EXTENSION;
EOSQL

So what is EOSQL? I can not find much information about this command or keyword.

+4
source share
1 answer

EOSQL - Bash Here Document. , . .

:

#!/usr/bin/env bash
cat <<-EOF
$MY_EXTENSION
EOF

:

$ MY_EXTENSION=something ./test.sh
something

Docker ENV MY_EXTENSION=something Dockerfile docker run -e MY_EXTENSION=something <image> , .

+7

Source: https://habr.com/ru/post/1650384/


All Articles