I found this lovely snippet of code in /etc/profile
on a CentOS box:
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
I know that it loads in the .sh
files from /etc/profile.d
, but I'm confounded by the last if statement, if [ "${-#*i}" != "$-" ]
. What is this syntax doing? I'm not even sure where to look it up.
$-
contains the current shell options.