Command
set -a; source .env; set +a;
Example
echo "EXAMPLE1=ABC\nEXAMPLE2=DEF" >> .env
cat .env
EXAMPLE1=ABC
EXAMPLE2=DEF
env | grep EXAMPLE
set -a; source .env; set +a;
env | grep EXAMPLE
EXAMPLE1=ABC
EXAMPLE2=DEF
It seems that set -a can treat a variable definition as an environment variable definition, export. Run it "front" of the shell with the source command.
NAME
set - Set or unset values of shell options and positional parameters.
SYNOPSIS
set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]
DESCRIPTION
Set or unset values of shell options and positional parameters.
Change the value of shell attributes and positional parameters, or
display the names and values of shell variables.
Options:
-a Mark variables which are modified or created for export.
http://linuxcommand.org/lc3_man_pages/seth.html
Linux — what the source command is doing> it's not really meant to reload the environment-Qiita
Original by Github issue
https://github.com/YumaInaura/YumaInaura/issues/3008
Recommended Posts