LoginSignup
4
5

More than 5 years have passed since last update.

KEY=VALUE が並んだファイルを読みこんで環境変数にexportしたい

Posted at

元ネタ:http://stackoverflow.com/questions/32761478/export-all-variables-from-key-value-file-to-shell

こんなファイルがあったとき

.env
AWS_ACCESS_KEY_ID=xxx
AWS_SECRET_ACCESS_KEY=yyy

単純にsourceしても何も起きないので

uraura@rosemary$ source .env

set -aしてからやると良いよっていう話でした.

uraura@rosemary$ set -a
uraura@rosemary$ source .env
uraura@rosemary$ set +a

-ahttp://itpro.nikkeibp.co.jp/article/COLUMN/20060227/230881/ によると

新規に作成した変数や関数,値を変更した変数や関数を,以後,自動的にエクスポートする

とのことなので,使用後はちゃんと戻しておきましょう.

4
5
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5