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

前端 未结 2 687
半阙折子戏
半阙折子戏 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:08

    It is checking whether the options for the shell $- contains an i in them. The i is for interactive

    From the Bash man page:

    An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.

    Also relevant

提交回复
热议问题