The first two statements of your BASH script should be…

栏目: IT技术 · 发布时间: 5年前

内容简介:The first statement is a Mac, GNU/Linux, and BSD portable way of finding the location of the bash interpreter. The second statement combinesReferences:
#!/usr/bin/env bash
set -euo pipefail

The first statement is a Mac, GNU/Linux, and BSD portable way of finding the location of the bash interpreter. The second statement combines

  1. “set -e” which ensures that your script stops on first command failure. By default, when a command fails, bash executes the next command. Looking at the logs, you might feel that the script executed successfully while some commands might have failed.
  2. “set -u” which ensures that your script exits on first unset variable encountered. Otherwise, bash replaces the unset variables with empty default values.
  3. “set -o pipefail” which ensures that if any command in a set of piped commands failed, the overall exit status is the status of the failed command. Otherwise, the exit status is the status of the last command.

References:

  1. Unofficial Bash strict mode
  2. ExplainShell

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

爆发

爆发

[美] 艾伯特-拉斯洛·巴拉巴西 / 马慧 / 中国人民大学出版社 / 2012-6 / 59.90元

1. 本书是一本超越《黑天鹅》的惊世之作。如果说塔勒布认为人类行为是随机的,都是小概率事件,是不可以预测的;那么全球复杂网络权威Barabasi则认为,人类行为93%是可以预测的。 2. Barabasi的研究是在人类生活数字化的大数据时代基础上进行的,移动电话、网络以及电子邮件使人类 行为变得更加容易量化,将我们的社会变成了一个巨大的数据库。他认为,人类正处在一个聚合点上,在这里数据、科学......一起来看看 《爆发》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试