On 10/26/2015 06:04 AM, ZyX wrote:
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.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
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?