--- grep-2.5e/doc/grep.1.dev Mon May 21 14:29:26 2001 +++ grep-2.5e/doc/grep.1 Mon May 21 14:29:26 2001 @@ -129,6 +129,20 @@ .BR \-v ", " \-\^\-invert-match option (see below), count non-matching lines. .TP +.BI \-D " ACTION" "\fR,\fP \-\^\-devices=" ACTION +If an input file is a device, FIFO or socket, use +.I ACTION +to process it. By default, +.I ACTION +is +.BR read , +which means that devices are read just as if they were ordinary files. +If +.I ACTION +is +.BR skip , +devices are silently skipped. +.TP .BI \-d " ACTION" "\fR,\fP \-\^\-directories=" ACTION If an input file is a directory, use .I ACTION --- grep-2.5e/doc/grep.texi.dev Mon May 21 14:29:26 2001 +++ grep-2.5e/doc/grep.texi Mon May 21 14:29:26 2001 @@ -315,6 +315,17 @@ depend on whether the @samp{-u} (@samp{--unix-byte-offsets}) option is used; see below. address@hidden -D @var{action} address@hidden address@hidden address@hidden -D address@hidden --devices address@hidden device search +If an input file is a device, FIFO or socket, use @var{action} to process it. +By default, @var{action} is @samp{read}, which means that devices are +read just as if they were ordinary files. +If @var{action} is @samp{skip}, devices, FIFOs and sockets are silently +skipped. + @item -d @var{action} @itemx address@hidden @opindex -d --- grep-2.5e/doc/grep.info.dev Mon May 21 14:29:26 2001 +++ grep-2.5e/doc/grep.info Mon May 21 14:30:02 2001 @@ -1,4 +1,4 @@ -This is grep.info, produced by makeinfo version 4.0 from grep.texi. +This is grep.info, produced by makeinfo version 4.0b from grep.texi. START-INFO-DIR-ENTRY * grep: (grep). print lines matching a pattern. @@ -148,8 +148,7 @@ `--colour[=WHEN]' `--color[=WHEN]' The matching string is surrounded by the marker specify in - GREP_COLOR. - WHEN may be `never', `always', or `auto'. + GREP_COLOR. WHEN may be `never', `always', or `auto'. `-NUM' Same as `--context=NUM' lines of leading and trailing context. @@ -184,6 +183,13 @@ byte offsets depend on whether the `-u' (`--unix-byte-offsets') option is used; see below. +`-D ACTION' +`--devices=ACTION' + If an input file is a device, FIFO or socket, use ACTION to + process it. By default, ACTION is `read', which means that + devices are read just as if they were ordinary files. If ACTION + is `skip', devices, FIFOs and sockets are silently skipped. + `-d ACTION' `--directories=ACTION' If an input file is a directory, use ACTION to process it. By @@ -894,6 +900,7 @@ * control characters: Regular Expressions. * counting lines: Invoking. * default options environment variable: Invoking. +* device search: Invoking. * digit characters: Regular Expressions. * directory search: Invoking. * DOS byte offsets: Invoking. @@ -984,6 +991,7 @@ * --colour: Invoking. * --context: Invoking. * --count: Invoking. +* --devices: Invoking. * --directories: Invoking. * --exclude: Invoking. * --extended-regexp: Grep Programs. @@ -1021,6 +1029,7 @@ * -C: Invoking. * -c: Invoking. * -d: Invoking. +* -D: Invoking. * -E: Grep Programs. * -e: Invoking. * -F: Grep Programs. @@ -1077,15 +1086,15 @@  Tag Table: -Node: Top1046 -Node: Introduction1817 -Node: Invoking2544 -Node: Diagnostics15239 -Node: Grep Programs15564 -Node: Regular Expressions16534 -Node: Usage24371 -Node: Reporting Bugs29802 -Node: Concept Index30334 -Node: Index36036 +Node: Top1047 +Node: Introduction1818 +Node: Invoking2545 +Node: Diagnostics15594 +Node: Grep Programs15919 +Node: Regular Expressions16889 +Node: Usage24726 +Node: Reporting Bugs30157 +Node: Concept Index30689 +Node: Index36442  End Tag Table --- grep-2.5e/src/grep.c.dev Mon May 21 14:29:26 2001 +++ grep-2.5e/src/grep.c Mon May 21 14:32:41 2001 @@ -77,7 +77,7 @@ static struct exclude *included_patterns; /* Short options. */ static char const short_options[] = -"0123456789A:B:C:EFGHIPUVX:abcd:e:f:hiKLlm:nqRrsuvwxyZz"; +"0123456789A:B:C:D:EFGHIPUVX:abcd:e:f:hiKLlm:nqRrsuvwxyZz"; /* Non-boolean long options that have no corresponding short equivalents. */ enum @@ -102,6 +102,7 @@ {"color", optional_argument, NULL, COLOR_OPTION}, {"colour", optional_argument, NULL, COLOR_OPTION}, {"count", no_argument, NULL, 'c'}, + {"devices", required_argument, NULL, 'D'}, {"directories", required_argument, NULL, 'd'}, {"extended-regexp", no_argument, NULL, 'E'}, {"exclude", required_argument, NULL, EXCLUDE_OPTION}, @@ -157,7 +158,14 @@ READ_DIRECTORIES, RECURSE_DIRECTORIES, SKIP_DIRECTORIES - } directories; + } directories = READ_DIRECTORIES; + +/* How to handle devices. */ +static enum + { + READ_DEVICES, + SKIP_DEVICES + } devices = READ_DEVICES; static int grepdir PARAMS ((char const *, struct stats const *)); #if defined(HAVE_DOS_FILE_CONTENTS) @@ -248,6 +256,8 @@ } if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode)) return 0; + if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISFIFO(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode))) + return 0; if (S_ISREG (stats->stat.st_mode)) { if (file) @@ -1026,6 +1036,8 @@ -I equivalent to --binary-files=without-match\n\ -d, --directories=ACTION how to handle directories\n\ ACTION is 'read', 'recurse', or 'skip'\n\ + -D, --devices=ACTION how to handle devices, FIFOs and sockets\n\ + ACTION is 'read' or 'skip'\n\ -R, -r, --recursive equivalent to --directories=recurse\n\ --include=PATTERN files that match PATTERN will be examine\n\ --exclude=PATTERN files that match PATTERN will be skip.\n\ @@ -1290,6 +1302,15 @@ context_length_arg (optarg, &default_context); break; + case 'D': + if (strcmp (optarg, "read") == 0) + devices = READ_DEVICES; + else if (strcmp (optarg, "skip") == 0) + devices = SKIP_DEVICES; + else + error (2, 0, _("unknown devices method")); + break; + case 'E': setmatcher ("egrep"); break;