用法: - 在bash [英] Usage of :- in bash

查看:193
本文介绍了用法: - 在bash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是什么风格在bash的含义是什么?

What is the meaning of this style in bash?

${PUBLIC_INTERFACE:-eth0}

什么是使用: -

推荐答案

如果 $ PUBLIC_INTERFACE 存在并且不为空,返回其值,否则返回eth0的

If $PUBLIC_INTERFACE exists and isn't null, return its value, otherwise return "eth0".

其实有一些这类在 bash的手册页记载:

There are actually a few of these documented in the bash man page:

$ {参数:-word} 使用缺​​省值。如果参数没有设置或者为空,word的扩展将被替换。否则,参数的值是取代

${parameter:-word} Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.

$ {参数:=字} 指定的默认​​值。如果参数没有设置或者为空,word的扩展被分配到参数。参数的值,然后被取代。位置参数和特别参数可能不以这种方式被分配给

${parameter:=word} Assign Default Values. If parameter is unset or null, the expansion of word is assigned to parameter. The value of parameter is then substituted. Positional parameters and special parameters may not be assigned to in this way.

$ {参数:?单词} 显示错误,如果空或取消。如果参数为null或取消,文字的扩大(或一条信息,影响,如果字不是present)被写入标准错误和外壳,如果不是交互式的,退出。否则,参数的值是取代

${parameter:?word} Display Error if Null or Unset. If parameter is null or unset, the expansion of word (or a message to that effect if word is not present) is written to the standard error and the shell, if it is not interactive, exits. Otherwise, the value of parameter is substituted.

$ {参数:+单词} 使用替代值。如果参数为null或取消,没有被取代,否则单词的扩张将被替换。

${parameter:+word} Use Alternate Value. If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted.

这篇关于用法: - 在bash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆