Linux/Ubuntu设置:非法选项-o pipefail [英] Linux/Ubuntu set: Illegal option -o pipefail

查看:167
本文介绍了Linux/Ubuntu设置:非法选项-o pipefail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面提到的代码行一直在Ubuntu 16.04发行版上一直为我工作,但是突然选项名 pipefail 是非法的选项:

The below mentioned line of code used to work for me all the time on a Ubuntu 16.04 distribution, but suddenly option-name pipefail is an illegal option:

set -eu -o pipefail

返回:

设置:非法选项-o pipefail

set: Illegal option -o pipefail

为什么会这样?我在一个全新安装的系统上运行该命令,并将其作为Shell脚本的一部分运行.代码放在开头:

Why does this happen? I run the command on a completely new installed system and as part of a shell script. The code is placed right at the beginning:

myscript.sh:

myscript.sh:

1 #!/bin/bash
2 set -eu -o pipefail
3 ...

脚本以sudo运行:

sudo sh ./myscript.sh

推荐答案

您正在运行 bin/sh ,在Ubuntu上,它是指向/bin/dash ,但是 pipefail 是bashism.

You are running bin/sh, on Ubuntu it is a symbolic link pointing to /bin/dash, but pipefail is a bashism.

使脚本可执行:

chmod +x myscript.sh

,然后按如下所示运行脚本:

and then run the script as follows:

sudo ./myscript.sh

这篇关于Linux/Ubuntu设置:非法选项-o pipefail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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