Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

bash

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

I am trying to understand the first part of the line but it's hard for a noob in bash like me. If anyone has a nice doc or the answer...

like image 880
Cyril ALFARO Avatar asked Jul 01 '15 07:07

Cyril ALFARO


1 Answers

$- 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.

like image 72
choroba Avatar answered Oct 05 '22 00:10

choroba