|
|
Subscribe / Log in / New account

GNU grep's new features (Linux.com)

GNU grep's new features (Linux.com)

Posted Jun 2, 2006 12:00 UTC (Fri) by jond (subscriber, #37669)
In reply to: GNU grep's new features (Linux.com) by nix
Parent article: GNU grep's new features (Linux.com)

egrep and fgrep are just shell scripts that call grep -E and grep -F on my system (sarge). I found this out the hard way, when I was using fgrep in a busy loop.


to post comments

GNU grep's new features (Linux.com)

Posted Jun 2, 2006 16:14 UTC (Fri) by nix (subscriber, #2304) [Link] (4 responses)

This is true in the upstream distro, and has been true since at least 2002. (Before that they were three separate binaries with different behaviours; having a single program that acts differently depending on its name is a violation of the GNU Coding Standards, so it wasn't implemented like that except for a brief period in 2002.)

GNU grep's new features (Linux.com)

Posted Jun 4, 2006 2:21 UTC (Sun) by vonbrand (subscriber, #4458) [Link] (3 responses)

...having a single program that acts differently depending on its name is a violation of the GNU Coding Standards, ...

Yet another reason to consider the coding standard to be braindamaged.

GNU grep's new features (Linux.com)

Posted Jun 5, 2006 9:56 UTC (Mon) by nix (subscriber, #2304) [Link] (2 responses)

The reasoning is entirely sensible: it is counterintuitive to have a program act differently simply because you mv'ed it to a different name. Among other things, having grep behave differently simply because you called it egrep *bans* you from making egrep a wrapper script, unless there is some other way to get at egrep's behaviour.

POSIX agreed: hence grep -E and grep -F, and the deprecation of look-at-argv[0] programs.

GNU grep's new features (Linux.com)

Posted Jun 8, 2006 7:41 UTC (Thu) by lysse (guest, #3190) [Link] (1 responses)

Where does that leave BusyBox?

GNU grep's new features (Linux.com)

Posted Jun 8, 2006 12:34 UTC (Thu) by nix (subscriber, #2304) [Link]

busybox isn't specified by POSIX nor is it a GNU project (nor does it even slightly conform to the GNU Coding Standards).

busybox is also a bit of a special case, in that 'size is everything', so the heaps-of-symlinks approach actually makes sense.

(But you don't necessarily need any of the symlinks. If you're running everything from a busybox shell, you can tell it to find busybox commands first regardless of the absence of symlinks.)

The BSDs have a tool called crunchgen which smashes a bunch of programs into one which conditionalizes off argv[0] in much the same way. (Except that busybox is smaller and doesn't penalize the rest of the system by forcing the *default* tools to be little featureless ones.)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds