在bash中,有模&QUOT的等效;错误味精" [英] In bash, is there an equivalent of die "error msg"

查看:88
本文介绍了在bash中,有模&QUOT的等效;错误味精"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Perl中,您可以用一个错误味精退出死一些味精。有没有在bash等效的单指令?现在,我实现这一目标使用命令:回声一些味精&放大器;&安培;出口1

In perl, you can exit with an error msg with die "some msg". Is there an equivalent single command in bash? Right now, I'm achieving this using commands: echo "some msg" && exit 1

推荐答案

您可以滚动您自己轻松地就够了:

You can roll your own easily enough:

die() { echo "$@" 1>&2 ; exit 1; }
...
die "Kaboom"

这篇关于在bash中,有模&QUOT的等效;错误味精"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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