bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature Request: scanf-like parsing


From: Daniel Colascione
Subject: Re: Feature Request: scanf-like parsing
Date: Mon, 25 Jan 2021 12:10:36 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 1/25/21 11:59 AM, Greg Wooledge wrote:

On Mon, Jan 25, 2021 at 06:47:36PM +0200, Oğuz wrote:
25 Ocak 2021 Pazartesi tarihinde Chet Ramey <chet.ramey@case.edu> yazdı:
declare -A copy
eval copy=( "${assoc[@]@K}" )
So many reputable people contributed to the demonization of `eval' that I
don't think I can convince anyone that there's nothing wrong with it
anymore.
It's a tricky thing to deal with.  Eli referenced my wiki, which has a
page dedicated to it, with contributions from many different authors.
The resulting quasi-consensus is complex and perhaps even a little
bit self-contradictory as a result.

You'll want to use eval only when it's absolutely necessary, and only when
it's safe.  If bash's @K feature is designed to be fed to eval, then we
can assume it's safe.  It becomes one of the very small number of
green-lighted cases where eval is OK.

The problem with eval is that for every OK usage, there are a thousand
incorrect and dangerous uses.  Avoid those, by being absolutely sure
you know what you're doing, and why you're doing it.


And it's also worth systematically creating alternatives for all the safe and legitimate uses of "eval" so that eventually the whole mechanism can be discouraged without having to rely on the nuance you've just described.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]