[clug] Pointless time-wasting bash questions

Scott Ferguson scott.ferguson.clug at gmail.com
Thu Jun 25 23:24:45 MDT 2015


On 26/06/15 14:42, Bob Edwards wrote:
> 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.

Agreed. The point of the interview test was to solve the specific
problem (which still interests me) - not make portable or multipurpose code.

The eval was just for my usage (thanks for the reminder Alex), testing
the upgrade of server applications from Squeeze servers to Jessie
servers, which involves a lot of path changes and digging through config
files to find out which package changes are causing errors. Lots of
"script `timestamp`-$something" and "cp
$variation_of_stock_config_file{,.`timestamp`.bak}" so I can (try and)
figure out where the many errors are without getting too lost.
> 
> I don't enjoy playing with bash when I (very rarely) come across
> non-traditional Unix filenames... 

Agreed, I just like interesting ways of learning a little more bash -
never know when it'll prove useful.

> If I wanted to play with 'doze or
> MacOSX, I'd probably bother learning how to use Excel or ...

Excel? I thought that was only for displaying tables and other things
that don't process data. My bad.
> 
> Horses for courses.
> 
> cheers,
> 
> Bob Edwards.


Kind regards


More information about the linux mailing list