by mananaysiempre · 4y ago · 0 comments
#!/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. 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.