fix oops with -D and a single file Reference: /n/atom/patch/applied/findoops Date: Sat Feb 22 16:29:00 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/find.c Sat Feb 22 16:28:55 2014 +++ /sys/src/cmd/find.c Sat Feb 22 16:28:56 2014 @@ -105,7 +105,7 @@ void find(char *name) { - int fd, n; + int fd, n, t; Dir *buf, *p, *e; char file[256]; @@ -115,8 +115,10 @@ } if(!flag['D']) Bprint(&out, fmt, name); + t = 0; for(; (n = dirread(fd, &buf)) > 0; free(buf)) for(p = buf, e = p+n; p < e; p++){ + t = 1; snprint(file, sizeof file, "%s/%s", name, p->name); if((p->qid.type&QTDIR) == 0 || !dskip(p)){ if(!flag['d']) @@ -124,6 +126,8 @@ }else if(!skip(p)) find(file); } + if(flag['D'] && !t) + Bprint(&out, fmt, name); close(fd); }