On 2018-01-15, Hongyi Zhao <
hongy...@gmail.com> wrote:
> Hi all,
>
> In the /etc/profile, I found the following snippet:
>
> ------------------
> 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
> ------------------
>
> But, I cann't figure out the meaning of the following line in above code:
>
> if [ "${-#*i}" != "$-" ]; then
>
> Any hints?
Well, you should see that ${-#*i} is some sort of variable evaluation.
Firstly, the variable is the special variable $- (look it up).
Secondly, the #*i bit modifies the value - there is a set of these
beginning with # or ## or % or %% , searching the man page for the last
of these should take you to the right bit.
Thirdly, the whole line compares the modified value to the whole value
and either just sources the file, or sources it supressing all output.
eric
--
ms fnd in a lbry