Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

LUA enhanced shell
[Shell commands]


Detailed Description

LUA enhanced shell.

Introduction
LUA enhanced shell improved basic shell. It adds common syntax to shell commands, a smartest line edition with command historic recall.

Edition enhancement
LUA enhanced shell use zed to edit the command line. left / right / home / end keys (may be others ?) could be use with great advantage here.

Syntax enhancement
LUA enhanced shell adds UNIX like shell command syntax. Since LUA shell only understand LUA statement, this shell transforms UNIX like commands into LUA statement. To do this the enhanced shell parse the command line end tries to determine if it is a LUA syntax or not. If it is a LUA syntax the shell will perform some supplemental checks like function or object:method existence. For enhanced commands the same checks are performed and other substition can be done depending on the shell_substitut variable. By default this variable is unset so that any substition is disable and all parameters will be sent as string.

Historic enhancement
LUA enhanced shell allow to recall a previous command and to edit it in a new line buffer. The historic is stored in shell_recalltable table and its maximum size is set in shell_toggleconsolekey.

Warning:
The enhanced shell is in charge to call the getchar() function which responsible of event dispatching. Sometime the shell is shutdowned by LUA error at shell level (typically when a application handler or update function failed). In that case the shell should fallback to basic shell, and enhanced shell should be start again by typing `shell()`. If the error occurs in update function you probably have to kill the application that fault this the evt_shutdown_app() function. If the error appends in the handle function, sometime the application could continue to work properly depending on which event causes the fault.

Todo:
historic search.

completion.

handling CTRL for terminal control codes.

Author:
vincent penne

benjamin gerard


Files

file  shell.lua
 LUA enhanced shell.


Functions

 doshellcommand (var string)
 Enhanced doshellcommand() reimplementation.

 shell_input (var string)
 Read a string shell command.

 shell_error (var err)
 Shell error exception handling.

 shell ()
 Call a new shell with enhanced line editing and more.


Variables

boolean shell_lua_key_words [keyword]
 Keywords that could begin a lua sentence.

boolean shell_default_substitut [type_name]
 Default table of variable type that the shell is allowed to substitut.

table shell_substitut [typename]
 Current table for shell substitution.

string shell_recalltable []
 Enhanced shell command historic table.

number shell_maxrecall
 Enhanced shell command historic table maximum size (default:20).

number shell_toggleconsolekey
 Enhanced shell toggle key.


Function Documentation

doshellcommand var  string  ) 
 

Enhanced doshellcommand() reimplementation.

Reimplementation of the doshellcommand function to extend the shell syntax. Hopefully this new syntax should be backward compatible with lua normal syntax. It adds possibility to type more usual command like "ls" without brackets () or a `cd plugins` without quoting.

This only replace syntax at shell level, the lua syntax remains unchanged so lua scripts should use normal syntax ...

shell_input var  string  ) 
 

Read a string shell command.

Do line edition, command historic and more ...

Parameters:
string Initial string (typically "").
Returns:
read string

shell_error var  err  ) 
 

Shell error exception handling.

This function relaunch the shell !

Deprecated:
Does not seem necessary actually.

shell  ) 
 

Call a new shell with enhanced line editing and more.

Just type `exit` to quit that shell.


Variable Documentation

boolean shell_default_substitut[type_name]
 

Default table of variable type that the shell is allowed to substitut.

Deprecated:
Not used.

table shell_substitut[typename]
 

Current table for shell substitution.

If this variable is set, it must be a table indexed by type name which are allowed to be substitued from the shell command line in shell enhanced syntax mode.

shell_substitut is unset by default.

number shell_toggleconsolekey
 

Enhanced shell toggle key.

Warning:
Do not redefine it : too many hard codes depend on it.


dcplaya documentation version 2.0 Generated on November 2004 by doxygen 1.3.6