문제

I have a post-commit hook that works, but for some reason the following line of code is not working properly. It creates my test file regardless of a fail.

!#/bin/sh

# force a failure
ifconfig -z 1>/dev/null 2>&1

if [ $? -ne 0 ]
then
   touch ~/Desktop/fail.txt
fi

The fail.txt file is created with or without that -z. However, if I run this same code without executing via my post-commit hook, it works as it should.

Any suggestions?

도움이 되었습니까?

해결책

Hook scripts execute in an empty environment, including an empty or severely limited PATH. As a result, your script most likely can't find/can't execute ifconfig.

Specify full paths to everything within your hook scripts.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top