我在一个bash脚本中看到行数据= $(cat)(只是声明一个空的变量),并且对这可能做什么感到神秘.
我阅读手册页,但没有一个例子或解释.这是否捕获标签?任何有关这方面的文件?
编辑:具体如何做数据= $(cat)允许它运行这个钩子脚本?
#!/bin/bash # Runs all executable pre-commit-* hooks and exits after,# if any of them was not successful. # # Based on # http://osdir.com/ml/git/2009-01/msg00308.html data=$(cat) exitcodes=() hookname=`basename $0` # Run each hook,passing through STDIN and storing the exit code. # We don't want to bail at the first failure,as the user might # then bypass the hooks without knowing about additional issues. for hook in $GIT_DIR/hooks/$hookname-*; do test -x "$hook" || continue echo "$data" | "$hook" exitcodes+=($?) done
https://github.com/henrik/dotfiles/blob/master/git_template/hooks/pre-commit