I have made the following bash script in order to export values from a specific file named params.env:
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SOURCE=$(dirname ${SOURCE})
export $(cat "${SOURCE}/../params.env" | xargs)
The params.env has the values:
Param1=param1
Param2="Space separated value"
But it successfully exports Param1 but it fails to export Param2.
Do you have any idea how to solve this?
set -a(causing all defined variables to be automatically exported), and thensource params.env.while IFS='=' read -r name value; do printf -v "$name" %s "$value"; export "$name"; donewould suffice in that case).SOURCE. All-caps names are used for variables with meaning to the OS or shell; lowercase variable names are reserved for application use and guaranteed not to modify shell behavior. See pubs.opengroup.org/onlinepubs/9699919799/basedefs/…, fourth paragraph.SYMFONY__var_1for Symfony's enviromental variable. So I use convension Instead of conviguration form parameters.