A
A
AlexLIn2016-06-01 16:27:24
PHP
AlexLIn, 2016-06-01 16:27:24

How to escape minus (hyphen) and bash?

Good afternoon.
I'm trying to build a Docker Container with a couple of ENV variables that I want to use later in php-fpm.
Variables with "-" in names look like this

ENV F3-ENV-DB_USER=**RANDOM** \
    F3-ENV-DB_NAME=**RANDOM**\
    F3-ENV-DB_PASS=**RANDOM**\
    F3-ENV-SMTP_HOST=mail\
    F3-ENV-SMTP_PORT=587\
    F3-ENV-SMTP_SCHEME=TLS\
    F3-ENV-SMTP_USER=noreply\
    F3-ENV-SMTP_PASS=**RANDOM**\
    F3-ENV-SMTP_FROM=noreply

You can't use them in init.sj. Since "-" cannot be used for variables in bash
if [ "$F3-ENV-DB_PASS" = "**Random**" ]; then
        unset F3-ENV-DB_PASS
fi
PASS=${F3-ENV-DB_PASS:-$(pwgen -s 12 1)}
_word=$( [ ${F3-ENV-DB_PASS} ] && echo "preset" || echo "random" )
echo "=> Creating MySQL user ${F3-ENV-DB_USER} with ${_word} password"

But I want to, because I would like to write them after in the config for php with this line
env | sed "s/\(.*\)=\(.*\)/fastcgi_param \1  '\2';/" > /etc/php/7.0/fpm/pool.d/www.conf

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-06-01
@sim3x

No way
stackoverflow.com/questions/21525424/how-to-declar...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question