スクリプト /etc/profile.d/{script1}.sh が正しく動作しません。

スクリプト /etc/profile.d/{script1}.sh が正しく動作しません。
cat /etc/profile.d/atlassian-plugin-sdk.sh
export PATH=$PATH:/opt/atlassian/plugin-sdk/bin
ls -al /etc/profile.d/atlassian-plugin-sdk.sh 
-rwxr-xr-x 1 root root 48 Apr 17 21:36 /etc/profile.d/atlassian-plugin-sdk.sh
ls -al /opt/atlassian/plugin-sdk/bin 
total 408
drwxr-xr-x 2 root root  4096 Apr 17 21:37 .
drwxr-xr-x 5 root root  4096 Apr 17 21:37 ..
-rwxr-xr-x 1 root root  3534 Apr 17 21:36 atlas-clean
-rwxr-xr-x 1 root root  3506 Apr 17 21:36 atlas-compile
-rwxr-xr-x 1 root root  8460 Apr 17 21:36 atlas-create-bamboo-plugin
-rwxr-xr-x 1 root root  5985 Apr 17 21:36 atlas-create-bamboo-plugin-module
.................................
  1. このスクリプトはどのように/etc/profile.d/atlassian-plugin-sdk.sh機能しますか?そんなことを呼べばいいの?毎回手動で?それとも、システムがどのようにしてこれを引き起こすのでしょうか?

    とにかく端末にファイルは/opt/atlassian/plugin-sdk/bin表示されません。PATH

    ただし、/etc/profile.d/atlassian-plugin-sdk.sh手動で複数回呼び出した後も何も変わりません。

    echo $PATH
    ........... (`/opt/atlassian/plugin-sdk/bin` isn't here)
    
  2. なぜ?何が問題なの?

アップデート1:

zsh実際にbashの代わりにbashを使用しています。しかし、その後

sudo cp /etc/profile.d/atlassian-plugin-sdk.sh /etc/profile.d/atlassian-plugin-sdk.zsh

シェルを再起動した後も何も変わりませんでした。ディレクトリはまだ/opt/atlassian/plugin-sdk/bin追加されていません。PATH

ベストアンサー1

のスクリプトは/etc/profile.d/通常、/etc/profileBourneシェル(sh、bashなど)にログインしたときに取得されます。を見ると、/etc/profile次のようなものが表示されます(私のDebianシステムの/ etc / profileからコピーされます):

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

.shこれにより、/etc/profile.d/のすべてのファイルが現在のシェルのコンテキストで実行され、影響を受けるようになります。

zsh/etc/profileはデフォルトでは実行されないため、互換性をsh確認しman zshて検索しない限り、/etc/profile.d/のスクリプトも実行されません。必要に応じて編集してソーシングできますが、/etc/zsh/profilezshは正確にshではありません。ほとんど互換性がありますが、(/etc/profile.d/ の内容に応じて) 奇妙で予期しない側面効果がある可能性があります。

必要に応じて atlassian ディレクトリを PATH に追加する方が簡単で、~/.zshrczsh を実行しているすべてのユーザーに適用したい場合は .zsh に追加する方が簡単です。起動ファイルの1つが簡単になります/etc/zsh

おすすめ記事