Revision [845]
This is an old revision of BasicSyntax made by DavidLee on 2009-11-07 12:32:43.
Basic Syntax
xmlsh can run in 2 modes, interactive and batch. In interactive mode, a prompt ("$ ") is displayed and in batch mode there is no prompt. Otherwise they are identical. Running xmlsh with no arguments starts an interactive shell. Running with an argument runs in batch mode and invokes the given script.
You can run an xmlsh script by passing it as the first argument, followed by any script arguments
xmlsh myscript.xsh arg1 arg2
For details on xmlsh invocation and parameters see xmlsh command
Environment
On invocation, xmlsh inherits the process environment of the caller. In particular this includes- Current Directory
- Environment variables
- Standard ports ( input/output/error )
The shell itself maintains additional environment which is passed to all subshells, but not to external (sub process) commands.
- Namespaces, including the default namespace
- Declared functions
- imported modules and packages
- Shell variables (Environment variables and internal shell variables)
- Positional parameters ($1 ... $n)
- Shell Options (-v, -x ...)
Running Commands / Basic Syntax
On startup, xmlsh reads the standard input (interactive mode) or the script file (batch mode), parses one command at a time and executes it. The following steps are performed
- Parse statement. Statements are parsed using the Core Syntax.
- Expand variables. Variable expansion is performed. See Variables and CoreSyntax.
- Variable assignment. Prefix variable assignment is performed. Variables and CoreSyntax.
- IO Redirection. IO redirection (input,output, here documents) CommandRedirect and CoreSyntax.
- Command execution. Commands are executed. CommandExecution
- Exceptions raised can be handled with a try/catch block.
After the command is executed, then the process repeats.