In my Oracle Linux box, I found a block of script in /etc/profile
that is hard to figure out:
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
My question is the variables in the if statement ${-#*i}
and $-
.
What does that mean? And why should add an else statement to redirect output?
Thanks!