sudoコマンドで環境変数を引き継ぐ方法を紹介します。
「-E」オプションもしくは「–preserve-env」オプションを使用します。
「man sudo」コマンドでは以下の説明が書かれています。
1 2 3 4 5 |
-E, --preserve-env Indicates to the security policy that the user wishes to pre‐ serve their existing environment variables. The security policy may return an error if the user does not have permis‐ sion to preserve the environment. |
覚えておきましょう!