In RHEL6 /etc/profile near the end there's an if statement:
if [ "${-#*i}" != "$-" ];
The !=
I'm guessing is the "not equal" for strings comparison operator. The left side I'm guessing is the string within the variable -@*i
and the right side is the string within $-
(which I think are the flags passed to the script). This is in the middle of a for loop and $i should exist however I don't know what -#*i
might possibly be.
Assuming I'm correct that $-
are flags passed to the script, I'm thinking ${-#*i}
must also be flags but I don't really have a clue.
Can someone please explain. Links with list of these special variables would be appreciated too.
Thanks in advance.
It is checking if the current shell is an interactive shell or not.
Presence of -i
in the $-
variable (which contains the list of flags passed to the shell) is one way of checking for interactive vs non-interactive shell. See here for a list of internal shell variables including $-
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With