Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: greps pipes and eval bad patterns



On 10/26/2015 06:04 AM, ZyX wrote:
Specifically this I would write as

     local -a gcmd
     gcmd=( cat )
     if [[ $1 == ,f ]] ; then
         gcmd=( grep '\[01;34m' )
         shift
     endif
     integer levels=$(( ($1 + 1) * 4 ))
     tree --du -haC | grep -Ev '^[^\[]{'"$levels"'\[* ' | $gcmd
That is better. The pipe shouldn't be in the variable. But because you can't have nothing on the right side of the pipe, I had been using ' grep .* ' as the default for '$gcmd' which seemed rather clumsy.

Question: Why can't we have nothing on the right side? Why not just ignore the pipe in that case? It would obviate this situation. Logic being that a pipe to nowhere is a null command thus ignored. Or is there some other syntactic use for a pipe to nowhere?



Messages sorted by: Reverse Date, Date, Thread, Author