Shell脚本问题|${-#*i}在概要文件中的含义

Shell脚本问题|${-#*i}在概要文件中的含义,shell,Shell,我正在查看一个shell文件,发现了以下部分: 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 我想知道在这个上下文中,${-#*I}是什么意思?在POSIX shell中,-是一个特殊的shell变量。

我正在查看一个shell文件,发现了以下部分:

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

我想知道在这个上下文中,
${-#*I}
是什么意思?

在POSIX shell中,
-
是一个特殊的shell变量。从手册页:

#
用于返回一个变量的值,并将其部分删除:

请阅读说明,然后添加实际外壳的标签。
 - (Hyphen.)  Expands to the current option flags (the single-letter option
              names concatenated into a string) as specified on invocation,
              by the set builtin command, or implicitly by the shell.
 ${parameter#word}     Remove Smallest Prefix Pattern.  The word is expanded
                       to produce a pattern.  The parameter expansion then
                       results in parameter, with the smallest portion of the
                       prefix matched by the pattern deleted.