start working on runtime optimisation
Merge branch 'dev' into runtime-opt
Runtime optimization mostly works.

Enclosing env vars made clear. Shell script file contents are executed
in one batch to make env persistent during the execution.
io_stack is now processed separately from state_stack
Do not add history for lines in rcfile.
Add persist options to allow the source command to be possible.
Default history is managed by the number of threads layers.
Add command line arguments for shell scripts.
Add custom expanvars to do variable expansion.

It expands undefined variables to emtpy strings which is consistent to
shell behaviour, while the python builtin one leaves them unchanged.

Need to take care the situtation where args or even commands expand to
empty strings.
Recheck simple_command after expansion to remove empty fields.