Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does +x mean in Bash scripting? [duplicate]

Tags:

bash

shell

What does +x mean in the below statement?

if[ -z ${FSV_ROOT+x} ]
like image 475
Bob Banner Avatar asked Sep 13 '25 17:09

Bob Banner


1 Answers

Read up on Use Alternative Value. See 2.6.2 Parameter Expansion.

In parameter expansion, if a parameter is unset or null, null shall be substituted; otherwise, the expansion of word shall be substituted. Use of the colon in the format shall result in a test for a parameter that is unset or null; omission of the colon shall result in a test for a parameter that is only unset.

So in your case:

If FSV_ROOT is set and not null, substitute x

If FSV_ROOT set but null, substitute x

If FSV_ROOT is unset, substitute null

like image 102
Jesse Avatar answered Sep 15 '25 10:09

Jesse