[英]grep with regex in pre-commit git hook
我正在編寫一個預提交的掛鈎來檢查調試代碼,該代碼在使用時效果很好:
FORBIDDEN='console.log'
但是當我更改為:
FORBIDDEN='die(|console.log(|print_r('
它無法捕獲任何東西。
完整代碼:
FILES_PATTERN='(\..+)?$'
FORBIDDEN='die(|console.log(|print_r('
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
xargs grep -E --with-filename -n $FORBIDDEN | \
grep -v '//';
不知道它的正則表達式還是其他
嘗試轉義括號:
FORBIDDEN='die\(|console.log\(|print_r\('
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.