What does [[ $- = *i* ]] mean in bash?

前端 未结 2 682
半阙折子戏
半阙折子戏 2021-02-01 14:39

I\'m installing liquidprompt and in the documentation they ask you to add [[ $- = *i* ]] && source ~/liquidprompt/liquidprompt in your .bashrc

2条回答
  •  执笔经年
    2021-02-01 15:14

    $- contains the current shell options.

    In [[ ... ]], the right hand side of a = is interpreted as a pattern if not quoted. Therefore, *i* means i possibly preceded or followed by anything.

    In other words, it checks wheter the i option is present, i.e. whether the current shell is interactive.

提交回复
热议问题