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
OPTIONS
section of the manpage:From the
Special Parameters
section of the manpage:From the
Parameter Expansion
section 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
i
appeared in the value of$-
which means that (since-i
is not an argument toset
) that the-i
argument was passed to the shell and the shell is an interactive shell.