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

前端 未结 4 1248
既然无缘
既然无缘 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:12

    Simple examples will prove

    I check for presence of a parameter TEST, if present echo "Yes" else I echo "No"

    openvas:~$ ${TEST+:} false  &&  echo "yes" || echo "no"
    no
    openvas:~$ TEST=1
    openvas:~$ ${TEST+:} false  &&  echo "yes" || echo "no"
    yes
    openvas:~$ 
    

    If you see, the parameter TEST is evaluated and it is actually unset, so it returns false and exit the path and goes to the OR Once I set the same, and test again, it flows to the echo part (continued &&) since it returns true

    Refer: this and that

提交回复
热议问题