The first two statements of your BASH script should be…

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

内容简介: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

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

查看所有标签

猜你喜欢:

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

谷歌的断舍离:互联网企业的破坏式创新

谷歌的断舍离:互联网企业的破坏式创新

[日]辻野晃一郎 / 樊颖 / 机械工业出版社 / 2018-1 / 45.00

本书主要分为三部分: 第一部分主要讨论了世界当下如火如荼的互联网企业进军传统产业大潮,并探讨了传统企业在互联网时代的救赎之路。 第二部分主要探讨了成功体验的反面:速度与迭代,并讨论了传统企业之所以无法实现迭代与快速发展的关键原因。介绍互联网公司如何通过组织精简流程来实现高速竞争时代的机动性。 第三部分讨论了互联网时代究竟需要什么样的人才,传统企业的员工应当怎样投身互联网企业才能避......一起来看看 《谷歌的断舍离:互联网企业的破坏式创新》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

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

Markdown 在线编辑器

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具