What does “plus colon” (“+:”) mean in shell script expressions?

前端 未结 4 1249
既然无缘
既然无缘 2020-11-28 13:25

What does this mean?

if ${ac_cv_lib_lept_pixCreate+:} false; then :
  $as_echo_n \"(cached) \" >&6
else
  ac_check_lib_save_LIBS=$LIBS
4条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 14:27

    To illustrate what has already been said:

    Unset variable (note the blank lines as a result of some echo commands):

    $ unset foo
    $ echo ${foo}
    
    $ echo ${foo:+:}
    
    $ echo ${foo+:}
    

    Null variable:

    $ foo=""
    $ echo ${foo}
    
    $ echo ${foo:+:}
    
    $ echo ${foo+:}
    :
    

    Non-null variable:

    $ foo="bar"
    $ echo ${foo}
    bar
    $ echo ${foo:+:}
    :
    $ echo ${foo+:}
    :
    

提交回复
热议问题