2

Centos7 has the following in /etc/profile:

for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

AND the following in /etc/bashrc (which is run from ~/.bashrc):

    for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            if [ "$PS1" ]; then
                . "$i"
            else
                . "$i" >/dev/null
            fi
        fi
    done

Debian and Ubuntu only run these from /etc/profile, which is what I would expect.

  • why does Centos run them from both ?
  • why the disparity in sh.local ?
2
  • interesting observation. interesting the difference in how they check for interactive shells, too. Nov 18, 2020 at 16:33
  • i think the interactive test difference is probably due to one being bash-only and the other being sh-alikes.
    – Spongman
    Nov 18, 2020 at 23:25

1 Answer 1

2

I don't know for sure on the first question, but I assume the reasons for it is Debian-based shell acts "dumber" by default when called as sh than Red Hat-based ones; they act like bash even when called as sh.

This Red Hat bug explains that sh.local is for the SA to override everything else found in /etc/profile.d.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .