${parametre-default}与{parameter:-default}的输出等效,只当parameter被声明但值为null时候,二者才有区别。
//变量未声明、未赋值
[root@instructor ~]# echo $a
[root@instructor ~]# echo ${a-1}
1
[root@instructor ~]# echo ${a:-1}
1
//变量声明、赋值为null
[root@instructor ~]# a=
[root@instructor ~]# echo $a
[root@instructor ~]# echo ${a-1}
[root@instructor ~]# echo ${a:-1}
1
//变量声明、赋值为2
[root@instructor ~]# a=2
[root@instructor ~]# echo $a
2
[root@instructor ~]# echo ${a-1}
2
[root@instructor ~]# echo ${a:-1}
2