[clug] Pointless time-wasting bash questions

Bob Edwards Robert.Edwards at anu.edu.au
Thu Jun 25 22:42:12 MDT 2015


On 26/06/15 14:21, Paul Harvey wrote:
>> If I was to use it for real work I'd "eval ''". e.g.:-
>> for i in /GenericAgent. . ; do eval cp 'Kernel/Config${i}pm{.dist,}' ; done
>
> Is the eval necessary? What if ${i} expands to something like:
> '; rm -rf $HOME/*; echo'
>
> I suppose it's possible your code there is immune from this style of
> thing, but I hate having to think so hard and reason about eval.
>
> Perhaps I've just been over-exposed to bad perl code from the
> "meta-programming just means building eval strings" era :)
>

In this case of iterating through a list of traditional Unix (spaceless,
non-Unicode) filenames, as per the original question, I don't think the
eval buys you anything.

I don't enjoy playing with bash when I (very rarely) come across
non-traditional Unix filenames... If I wanted to play with 'doze or
MacOSX, I'd probably bother learning how to use Excel or ...

Horses for courses.

cheers,

Bob Edwards.


More information about the linux mailing list