Git 如何登录/注销'exec'请求`

Git 如何登录/注销'exec'请求`,git,gitlab,sh,exec,gitlab-omnibus,Git,Gitlab,Sh,Exec,Gitlab Omnibus,我的GitLab CE服务器上有一个git预接收钩子: #!/bin/sh # This is the single source of truth for where Gitaly's embedded Git hooks are. exec "$GITALY_BIN_DIR/gitaly-hooks" "$(basename $0)" "$@" 我对通过这个exec命令传递的内容非常感兴趣,因为它“不起作用” 如何捕获exec命令的输入和输出,并将其记录到一个或多个文件中?谢谢大家! 这

我的GitLab CE服务器上有一个git预接收钩子:

#!/bin/sh

# This is the single source of truth for where Gitaly's embedded Git hooks are.
exec "$GITALY_BIN_DIR/gitaly-hooks" "$(basename $0)" "$@"
我对通过这个exec命令传递的内容非常感兴趣,因为它“不起作用”

如何捕获
exec
命令的输入和输出,并将其记录到一个或多个文件中?谢谢大家!

这是为了T形输出,但有一个
语法错误:重定向意外
。我还想记录输入

exec "$GITALY_BIN_DIR/gitaly-hooks" "$(basename $0)" "$@"  &> >(tee -a /var/log/git-as-svn/pre-receive.2.3.log)
特地看

另见

您可以从
#更改第一行/bin/sh
#/bin/sh-x

或者,您可以按照user1934428的建议将$@的值写入文件


对不起,我没有仔细阅读这个问题。使用
strace
,您可以看到输入和输出是什么

例如:

$ cat test.sh                                                                                                                          #!/bin/sh

/usr/bin/strace -f -o /tmp/strace.out -s 9999 /bin/bash -c "exec ./hello.sh"
$ cat hello.sh                                                                                                                         #!/bin/sh
echo What is your name?
read name
echo hello $name
$ ./test.sh                                                                                                                            What is your name?
John
hello John
$ grep read\(0 /tmp/strace.out                                                                                                         
104   read(0, "J", 1)                   = 1
104   read(0, "o", 1)                   = 1
104   read(0, "h", 1)                   = 1
104   read(0, "n", 1)                   = 1
104   read(0, "\n", 1)                  = 1
$ grep write\( /tmp/strace.out                                                                                                         
104   write(1, "What is your name?\n", 19) = 19
104   write(1, "hello John\n", 11)      = 11
$                                

请用shell标记替换bash标记,因为这不是bash脚本。要查看输入参数,只需在执行exec之前将“$@”转储到某个日志文件即可。我不知道gitaly,但你为什么要在这里执行
exec
?这是Gitaly中定义钩子的假定方法吗?谢谢你的建议,但它没有回答这个问题-x和$@显示被调用的二进制文件,但不显示该命令的输入和输出。我相信
exec
会切换io流。