View | Details | Raw Unified | Return to bug 216307 | Differences between
and this patch

Collapse All | Expand All

(-)b/usr.bin/grep/grep.c (-1 / +1 lines)
Lines 725-731 main(int argc, char *argv[]) Link Here
725
	if ((aargc == 0 || aargc == 1) && !Hflag)
725
	if ((aargc == 0 || aargc == 1) && !Hflag)
726
		hflag = true;
726
		hflag = true;
727
727
728
	if (aargc == 0)
728
	if (aargc == 0 && (dirbehave != DIR_RECURSE || patterns == 0))
729
		exit(!procfile("-"));
729
		exit(!procfile("-"));
730
730
731
	if (dirbehave == DIR_RECURSE)
731
	if (dirbehave == DIR_RECURSE)
(-)b/usr.bin/grep/util.c (-1 / +16 lines)
Lines 111-116 grep_tree(char **argv) Link Here
111
	FTSENT *p;
111
	FTSENT *p;
112
	int c, fts_flags;
112
	int c, fts_flags;
113
	bool ok;
113
	bool ok;
114
	char **tdir = NULL, *pwd = NULL;
114
115
115
	c = fts_flags = 0;
116
	c = fts_flags = 0;
116
117
Lines 128-134 grep_tree(char **argv) Link Here
128
129
129
	fts_flags |= FTS_NOSTAT | FTS_NOCHDIR;
130
	fts_flags |= FTS_NOSTAT | FTS_NOCHDIR;
130
131
131
	if (!(fts = fts_open(argv, fts_flags, NULL)))
132
	if (argv[0] == NULL) {
133
		tdir = grep_calloc(2, sizeof(char *));
134
		if ((pwd = getcwd(NULL, 0)) == NULL)
135
			err(2, "getcwd");
136
		tdir[0] = pwd;
137
	}
138
139
	if (!(fts = fts_open((tdir != NULL ? tdir : argv), fts_flags, NULL)))
132
		err(2, "fts_open");
140
		err(2, "fts_open");
133
	while ((p = fts_read(fts)) != NULL) {
141
	while ((p = fts_read(fts)) != NULL) {
134
		switch (p->fts_info) {
142
		switch (p->fts_info) {
Lines 165-170 grep_tree(char **argv) Link Here
165
	}
173
	}
166
174
167
	fts_close(fts);
175
	fts_close(fts);
176
177
	if(pwd != NULL)
178
		free(pwd);
179
180
	if(tdir != NULL)
181
		free(tdir);
182
168
	return (c);
183
	return (c);
169
}
184
}
170
185

Return to bug 216307