开发者

Grep 'hg incoming' result for specific files and save result - if there is files im looking for

开发者 https://www.devze.com 2023-01-07 10:44 出处:网络
I want to create a script that will do something if hg incoming -v contains specific file. Say if hg incoming -v | grep models.py > 0 than do ./manage.py resetdb. Something like this.

I want to create a script that will do something if hg incoming -v contains specific file. Say if hg incoming -v | grep models.py > 0 than do ./manage.py resetdb. Something like this.

How can i set a flag (in开发者_StackOverflow社区 bash script) based on hg incoming -v | grep manage.py result?


if hg incoming -v | grep -q 'models\.py'; then
  ./manage.py resetdb
fi

However, this seems fragile: it matches when models.py is present in other output than files (such as description) and won't work when you modify models.py locally. You can set a variable within the above to control later actions, if that's what you meant by "set a flag."


count=`hg incoming -v | grep -c 'models\.py'`
if test $count -gt 0; then
   ./manage.py resetdb
fi
0

精彩评论

暂无评论...
验证码 换一张
取 消