You hear it a lot eval is evil
, whether it's in Shell/POSIX world, or in other langs like python etc…
But I'm wondering, is it actually useless? or is it there some arcane, non-documented, interesting or just useful use-cases for it?
Would prefer if the answer is sh
/bash
centric, but it's fine if it's about other Shells too.
Best Answer
I know of two ... common ... use cases for
eval
:Argument processing with
getopt
:Setting up an SSH agent:
Both uses might have alternatives, but I wouldn't bat an eyelid on seeing either of them.