|
From: | Léa Gris |
Subject: | Re: Feature Request: scanf-like parsing |
Date: | Mon, 25 Jan 2021 19:20:05 +0100 |
User-agent: | Telnet/1.0 [tlh] (PDP11/DEC) |
Le 25/01/2021 à 18:58, Oğuz écrivait :
I rarely use eval, but when I do, it works just fine. I can't really agree with the sentiment of your article, sorry.
I use eval when I am sure there is no other safer way.Mean, if I can achieve the same with declare foo="dynamically generated content" I opt for the later, like mapping a whole file into an associative array in one go instead of iterating incrementing the array line by line. Because I know it can be done for a declare and the content is generated with printf %q or jq's @sh filter.
Anyway on systems where there is a sufficiently advanced Bash available for these nice advanced bashisms, There are probably better all-purpose scripting languages available as well like Python or Perl.
For obsolete closed-source systems where I don't have control on if a decent Bash version is available, using the nice Bash feature is not an option anyway, and sometimes, yes eval will help.
-- Léa Gris
[Prev in Thread] | Current Thread | [Next in Thread] |