On Mon, Jan 25, 2021 at 06:47:36PM +0200, Oğuz wrote: > 25 Ocak 2021 Pazartesi tarihinde Chet Ramey <chet.ra...@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.