[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua as replacement for Bash scripting
- From: Alexander Gladysh <agladysh@...>
- Date: Wed, 7 Jul 2010 02:13:37 +0400
On Tue, Jul 6, 2010 at 21:10, Hisham <firstname.lastname@example.org> wrote:
> On Tue, Jul 6, 2010 at 6:52 AM, Jerome Vuarand <email@example.com> wrote:
>> 2010/7/6 Alexander Gladysh <firstname.lastname@example.org>:
>>>> What you can do is introduce some helper code to run external
>>>> utilities more easily. For example you could put a __index hook on _G
>>>> (or a module), that would check if a command line utility with the
>>>> given key exist in the path, and would wrap a call to io.popen in a
>>>> Lua function, with proper whitespace escaping. For example you could
>>>> then write :
>>>> local files = find('.', '-name' '*foo*')
>>>> for _,file in files:match('[^\n]+') do
>>>> Â Âprint(stat('%n is a %F', file))
>>>> Where find and stat are wrappers for the command line tools.
>>> That's a nice idea!
>>> I would put such hook into a separate table though â to avoid name clashes.
> That seems to be what Peter Odding's shell.lua does.
You're right. I've missed that, sorry :-)
However, I'd use a clean table for this. Peter's one still prone to
name clashes, I think.