Hacker Newsnew | past | comments | ask | show | jobs | submit | thepawn1's commentslogin

"older than myself"

#rightinthefeels


Loved this game. Still holds up...


This DPA has already expired ( https://www.marketwatch.com/story/doj-seeks-to-end-hsbc-defe... ) . .

And HSBC has already had another that was enforced and expired already on tax evasion though it's Swiss private bank.


The age old issue. There's oodles of data at how people don't keep doing it because it's toil to them.


alias fgrep='grep -F'


the issue is that programs rely on the existence of fgrep in its PATH. your shell alias doesn't fix that.


It is a bit hacky but you could put "grep -F" in a script file in your path.



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


Of course it can be solved; no one claimed you can't. The choice here is:

- Thousands of users have to update their scripts, habits, shell configs; or

- The GNU Grep maintainers spend essentially zero minutes "maintaining" a few lines of code to automatically use -E or -F based on argv[0].

It seems to me the second is obviously the better option.


So. Thought experiment.

Which has lower cognitive load if everyone starts doing it?

Explicitly specifying switches, or argv magic? I'd argue, the switches are. In the abscence of the symlinking, that is how the tool functionality would have to be driven anyway.

Argv magic now runs into a problem if another program sharing the name ever comes into existence on the path. It's also completely unergonomic in a sense, because short of looking at the source, you have no way of knowing what argv transforms implementations support are, and in order to use them, you must explicitly pollute the Symbol namespace with a denormalized util. Also, the argv magic does require one extra shell to do the transform from !grep to grep -!, Which is technically more overhead. On the other hand, fgrep and egrep are ironically easier to grep/sed for as opposed to grep/ -[F|E]

One tool, one manual, one name, one argv0.

I am not the Grand Poobah of the Internet, however, even if their hat is in my possession, so I understand that it is likely that the fgrep/egrep convention is probably deeply entrenched, and likely to spawn a new holy war on par with Emacs/Vim. Tabs/spaces, etc...


I don't think grep does any argv-stuff; I took a quick look and I don't see it.

As far as I can tell this is the entire maintenance burden:

  $ cat =egrep =fgrep
  #!/bin/sh
  exec grep -E "$@"
  #!/bin/sh
  exec grep -F "$@"


what shell does this?


Apparently zsh replaces =cmd with cmd's absolute path. TIL.


Yes, very useful to bypass aliases if need be, quickly edit a script ("vi =my-script"), etc. I don't think bash has it; you need to use where/whence/which/command/whatever (I can never remember, why are there so many?!)


Hack: \command instead of command is very unlikely to be aliased, so should work fine.


This is a very useful hack, thanks. Unfortunately, my defensive scripting instincts do not allow me to use it on the "serious" situations.


    # unalias grep && unalias egrep && cp "$(command -v grep)" "$(dirname "$(command -v grep)")/egrep"
1 line. Fixed. Done. Btw needs to be run as root ( as signified by # prompt above)

EDIT: see other comment in this thread from FreeBSD user that on FreeBSD grep, egrep, and fgrep are all separate but identical (copies) of the same file. So this isn’t quite such a silly solution as some might think.


The current contents (not joking): (this is why the situation is crazy)

  #!/bin/sh
  cmd=${0##\*/}
  echo "$cmd: warning: $cmd is obsolescent; using grep -E" >&2
  exec grep -E "$@"


I cannot edit anymore, so I add this:

This is the case in a distribution (Arch) that has effectively taken the maintainer's advice into account, not the reverse.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: