シェルスクリプトのヒアドキュメントで変数を展開しない方法を記載する。 .bash_profileにproxyの設定をする場合を例を記載する。 そのまま、行うと以下のようになる
$ cat >> .bash_profile <<EOF export http_proxy=http://<ID>:<PW>@<proxy>:8080 export https_proxy=${http_proxy} export HTTP_PROXY=${http_proxy} export HTTPS_PROXY=${http_proxy} EOF $ cat .bash_profile export http_proxy=http://<ID>:<PW>@<proxy>:8080 export https_proxy=http://<ID>:<PW>@<proxy>:8080 export HTTP_PROXY=http://<ID>:<PW>@<proxy>:8080 export HTTPS_PROXY=http://<ID>:<PW>@<proxy>:8080
その場合は、最初のEOFをダブルクオーテーション"でくくると変数が展開されない
$ cat >> .bash_profile <<"EOF" export http_proxy=http://<ID>:<PW>@<proxy>:8080 export https_proxy=${http_proxy} export HTTP_PROXY=${http_proxy} export HTTPS_PROXY=${http_proxy} EOF $ cat .bash_profile export http_proxy=http://<ID>:<PW>@<proxy>:8080 export https_proxy=${http_proxy} export HTTP_PROXY=${http_proxy} export HTTPS_PROXY=${http_proxy}