我写了一个 zsh 函数来帮助我在工作中做一些 grepping。
function rgrep (){
if [ -n "$1" ] && [ -n "$2" ]
then
exec grep -rnw $1 -r $2
elif [ -n "$1" ]
then
exec grep -rnw $1 -r "./"
else
echo "please enter one or two args"
fi
}
效果很好,但是,grep 完成执行我没有被扔回 shell。它只是卡在 [process complete] 有什么想法吗? 我的 .zshrc 中有函数
最佳答案
除了去掉不必要的exec
,你还可以去掉if
语句。
function rgrep (){
grep -rwn "${1:?please enter one or two args}" -r "${2:-./}"
}
如果 $1
未设置(或值为 null),将引发错误并显示给定的消息。如果未设置 $2
,将使用默认值 ./
代替它。
关于linux - zsh 脚本 [进程完成] 没有返回到 shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24041591/