Re: [hackers] [sbase][PATCH] Add egrep and fgrep

From: Connor Lane Smith <cls_AT_lubutu.com>
Date: Tue, 5 Jan 2016 14:35:18 +0100

Hey,

On 5 January 2016 at 14:01, Roberto E. Vargas Caballero <k0ga_AT_shike2.com> wrote:
> These tools are not part of POSIX, but they were part of the original
> UNIX and even today they are still wide used. The work done by this
> tools can be done by grep, so this implementation is only masking the
> code with different names to get the work done.

I do think egrep & fgrep are worth having, but I'm not sure if
strcmp(argv[0], ...) is the way to go about it. For one thing it means
(unless I'm mistaken) that executing /bin/egrep would actually call
grep, not egrep. This could be fixed by comparing only the basename,
but in my opinion a more reliable approach would be to add two short
shell scripts to add the appropriate flag, e.g.

#!/bin/sh
exec grep -E "$_AT_"

There is the drawback here that the first grep in $PATH may not be
sbase grep, but all in all I think a shell script is better than
checking argv[0] within the binary itself. Alternatively anyone who
wants egrep & fgrep could just add shell aliases... Still, it's up to
the maintainers.

cls
Received on Tue Jan 05 2016 - 14:35:18 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 05 2016 - 14:36:12 CET