$prefix/etc/profile.d

Blair Zajac blair at orcaware.com
Sat Aug 13 12:20:53 PDT 2011


I'm proposing that MacPorts support the $prefix/etc/profile.d as a standard place where ports can install scripts that set up the user's environment.  We would tell users to source everything in that directory from their ~/.profile or ~/.bash_profile.

This would help us:

- Multiple ports wouldn't need to tell the user to edit their ~/.bash_profile or ~/.profile, e.g. bash-completion and maven*.  One setup would be enough for all ports they install.
- Make it easier for port maintainers to set up environmental variables than writing a wrapper script.

There's precedence for this on Linux (Fedora and Ubuntu) where packages will install files to source and /etc/profile has this snippet:

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

For example, our Fedora 13 systems have these:

ls /etc/profile.d/
/etc/profile.d:
ccache.csh                 lang.csh 
ccache.sh                  lang.sh 
colorls.csh                less.csh 
colorls.sh                 less.sh 
cvs.csh                    modules.csh@
cvs.sh                     modules.sh 
glib2.csh                  mpich2.csh 
glib2.sh                   mpich2.sh 
kde.csh                    qt.csh 
kde.sh                     qt.sh 
keychain.csh               udisks-bash-completion.sh 
keychain.sh                vim.csh 
krb5-devel.csh             vim.sh 
krb5-devel.sh              which2.csh 
krb5-workstation.csh       which2.sh 
krb5-workstation.sh        

Thanks,
Blair



More information about the macports-dev mailing list