TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:6938] More /etc/profile.d



On Mon, 12 Jul 1999, Bob Tanner wrote:

> /etc/csh.cshrc is properly sourcing /etc/profile.d/jdk.csh, but it does not
> alter my path. Anyway to have /etc/profile.d stuff add to the PATH
> environment variable?

Are you "sourcing" the scripts in your profile.d directory, or are you
simply executing them?  There is a difference.  If you simply execute
a shell script, any environment changes you make are local to the
execution of the script itself.  The script is executed in a separate
shell from your login.  If you "source" the script, however, the
script is executed in your existing shell.  Any changes you make to
your environment is performed to your existing shell and saved.

So...  These are actually different... (in bash... as I don't have csh
installed to reference the correct syntax for the for/if
statements)...

#!/bin/bash

# Actually sources the scripts...
    for i in /etc/profile.d/*.{sh,bash} ; do
        echo -n "Sourcing login scripts."
        if [ -x ${i} ] ; then
            . ${i}
            echo -n "."
        fi
        echo "done."
    done

# verses...
# Executes the scripts in separate shells
    for i in /etc/profile.d/*.{sh,bash} ; do
        echo -n "Executing login scripts."
        if [ -x ${i} ] ; then
            ${i}
            echo -n "."
        fi
        echo "done."
    done


^chewie

http://nerp.net/~chewie  <<--- Check it out!  I'm selling my truck!