linux/ubuntu set:非法选项-O PipeFail
以下提到的代码行一直在Ubuntu 16.04发行上使用,但突然选择 PipeFail 是一个非法选项:
set -eu -o pipefail
返回:返回:
集:非法选项-O PipeFail
为什么会发生这种情况?我在一个全新的安装系统上运行命令,作为Shell脚本的一部分。该代码在开始时放置在:
myScript.sh:
1 #!/bin/bash
2 set -eu -o pipefail
3 ...
脚本以sudo:
sudo sh ./myscript.sh
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
returns:
set: Illegal option -o pipefail
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:
1 #!/bin/bash
2 set -eu -o pipefail
3 ...
The script is run as sudo:
sudo sh ./myscript.sh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在运行
bin/sh
,在ubuntu上,这是一个指向/bin/dash
的符号链接,但是pipefail
是一个狂欢。使脚本可执行:
然后按以下方式运行脚本:
You are running
bin/sh
, on Ubuntu it is a symbolic link pointing to/bin/dash
, butpipefail
is a bashism.Make the script executable:
and then run the script as follows:
从
zsh
运行脚本时,我遇到了相同的错误,并且脚本以不正确 shebang开始。错误,缺少
!
<代码>#:正确:
I had the same error when running script from
zsh
and the script began with incorrect shebang.WRONG, missing
!
after#
:Correct: