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

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

查看所有标签

猜你喜欢:

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

离散数学及其应用(原书第4版)

离散数学及其应用(原书第4版)

Kenneth H.Rosen / 机械工业出版社 / 2002-1-1 / 75.00

离散数学及其应用:原书第4版,ISBN:9787111075776,作者:(美)Kenneth H.Rosen著;袁崇义[等]译一起来看看 《离散数学及其应用(原书第4版)》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

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

Base64 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码