加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

unix-tee和退出状态

发布时间:2020-12-15 18:46:36 所属栏目:安全 来源:网络整理
导读:是否有替代“tee”捕获正在执行的命令的STDOUT / STDERR,并退出与处理的命令相同的退出状态.如下所示: eet -a some.log -- mycommand --foo --bar 其中“eet”是“tee”的想象替代:)( – 表示附加,– 分离捕获的命令)应该不难劫持这样的命令,但也许它已经存
是否有替代“tee”捕获正在执行的命令的STDOUT / STDERR,并退出与处理的命令相同的退出状态.如下所示:
eet -a some.log -- mycommand --foo --bar

其中“eet”是“tee”的想象替代:)( – 表示附加,– 分离捕获的命令)应该不难劫持这样的命令,但也许它已经存在,我不知道它?

谢谢.

这是一个eet.每个Bash都可以让我的手从2.05b到4.0.
#!/bin/bash
tee_args=()
while [[ $# > 0 && $1 != -- ]]; do
    tee_args=("${tee_args[@]}" "$1")
    shift
done
shift
# now ${tee_args[*]} has the arguments before --,# and $* has the arguments after --

# redirect standard out through a pipe to tee
exec | tee "${tee_args[@]}"

# do the *real* exec of the desired program
exec "$@"

(pipefail和$PIPESTATUS是好的,但我记得他们被介绍在3.1或附近.)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读