4 ms·
Currently, egrep and fgrep are shell scripts (the too-simple version of this idea would be #!/bin/sh exec /usr/bin/grep -E "$@" but that would mess up hel
by mananaysiempre 4y ago
Currently, egrep and fgrep are shell scripts (the too-simple version of this idea would be
#!/bin/sh
exec /usr/bin/grep -E "$@"
but that would mess up help messages and probably also needs disaster handling in case exec fails). Another traditional way, however, is to symlink everything to a single binary, which uses argv[0] or getprogname() to see which name the user called it under and acts accordingly. In the extreme case, you get the "multi-call binaries" Busybox or Toybox, which contain an entire set of Unix utilities in a single (not-too-slim) executable image. GNU grep also used that technique at some point in its history, but it was discarded for a reason I don't recall.
- smellf 4y agoActually it turns out that, at least in debian 11, you were right on the money: cat `which egrep` #!/bin/sh exec grep -E "$@" But I agree that it would be cleaner and trivial to implement this behavior by depending on argv[0], GNU style guide be damned.