lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Apr 23, 2012 at 10:52, Jay Carlson <nop@nop.com> wrote:
> On Mon, Apr 23, 2012 at 9:25 AM, Robert Klemme
> <shortcutter@googlemail.com> wrote:
>> On Mon, Apr 23, 2012 at 1:24 PM, Rena <hyperhacker@gmail.com> wrote:
>
>>> I've always wanted to see an "OS" written in Lua, which in reality
>>
>> It's interesting to see this type of discussion: over there in the
>> Ruby community it came (or: comes) up from time to time, sometimes in
>> the variant of wanting a Ruby shell (note: there is already IRB, pry
>> and rush).
>
> Well, considered as a proposed modern language, /bin/sh kinda blows.
> /bin/rc is better. Something like bash 4.0 is pretty featureful, but
> it has little unity.
>
>> Apparently some fans of a scripting language are so
>> enthralled by the respective language that they deem it desirable to
>> extend that language's usage to all aspects of a shell / an operating
>> system.  These things rarely come into existence (or fill a niche
>> only)
>
> OpenWrt is wandering that way with LuCI.
>
> IMO on Unix if you want to play the part of a shell, the problem comes
> down to embedding a reasonable domain-specific quasiquotation syntax
> for constructing process invocation structures. Which would you rather
> write?
>
>  proc{'find', "/usr", "-name", pattern, "-print0"}.pipe{'xargs', '-0', 'du'}()
>
>  find /usr -name "$pattern" -print0 | xargs -0 du
>
>  find /usr -name $pattern -print0 | xargs -0 du

My thought would be something a little more verbose, like:
proc1 = create_process('find', {path='/usr', name=pattern, print0=true})
proc2 = create_process('xargs', {nullsep=true, delim='u'})
proc1.stdin = proc2.stdout
proc2:start(); proc1:start()

(create_process would create but not start; you'd have another
function to create and start.) Of course the programs would have to be
designed to accept name key/value pairs as arguments, and this would
be how you do it in a script - there'd be a bash-like shell for manual
invocation by the user for simple commands. To me shell scripting
always seemed like a bit of a hack, twisting a simple UI prompt to
function as a crude scripting engine, when what you really need is a
scripting engine. :-)

-- 
Sent from my toaster.