I just noticed this line in my /etc/profile, and I wondered what this if means and when it is true.
if [ "${-#*i}" != "$-" ]; then
i iterates over several *.sh files.
Sorry if this is a silly question, but as you can imagine, looking for mostly symbols in Google is really not an option.
Thanks!
From the
OPTIONSsection of the manpage:From the
Special Parameterssection of the manpage:From the
Parameter Expansionsection of the manpage:So
"${-#*i}"says expand the$-variable and remove from the start of the string until the letteri. That expansion is then compared!=against the expansion of$-(the same variable only unmodified).When those are not the same it means the first expansion removed some contents which means the letter
iappeared in the value of$-which means that (since-iis not an argument toset) that the-iargument was passed to the shell and the shell is an interactive shell.