grep weirdness

Steve Coile scoile at nandomedia.com
Fri Aug 8 04:33:19 PDT 2003


On Thu, 7 Aug 2003, Ryan Thompson wrote:
>doug at safeport.com wrote to freebsd-questions at freebsd.org:
[...]
>> artemis:~> grep -ilr taiwan *                    \
>> grep: unrecognized option `--showDropTarget'      |____ does not work
>> Usage: grep [OPTION]... PATTERN [FILE]...         |
>> Try `grep --help' for more information.          /
>>
>> while
>
>Hmm... My guess is that * expands to something containing a leading
>hyphen, most likely called --showDropTarget :-) The * is expanded by the
>shell, not grep(1).

If so, that's bad: the first non-option should disable further option
processing.  In the example cited, "taiwan" is not a command option,
so anything to the right of "taiwan" should not be interpreted as a
command option, even if it begins with a hyphen.

This also suggests that grep is re-invoking itself as it recurses.  If so,
it should be an easy thing to patch the source so that a double hyphen
("--") occurs before the first argument.

-- 
Steve Coile
Systems Administrator
Nando Media
ph: 919-861-1200
fax: 919-861-1300
e-mail: sysadmins at nandomedia.com
http://www.nandomedia.com


More information about the freebsd-questions mailing list