Adr*_*nch 6 bash shell jenkins
在 Jenkins 项目中使用变量时,这之间有区别吗:
node index.js ${arg}
和这个:
node index.js $arg
其中 arg 是项目的参数。
更新: 有趣的是,它不是 Jenkins 特定的。
我认为这个问题应该保留,因为其他人可能会认为这与詹金斯有关。
它实际上是一个标准的 shell 语法。
操作变量/将变量的内容连接到其他变量名称中更容易。例如
${foo}bar
Run Code Online (Sandbox Code Playgroud)
您还可以使用以下命令执行其他字符串操作{}:
STRING="This is a string"
echo ${STRING// /_}
Run Code Online (Sandbox Code Playgroud)
http://www.tldp.org/LDP/abs/html/string-manipulation.html
我还发现变量{}更好地阅读,但这是个人偏好。
这里的通用答案是:我们什么时候需要使用 Bash 在变量中使用花括号?