-
Notifications
You must be signed in to change notification settings - Fork 1
A XSH file is a XML document describing UNIX shell program and/or functions. The need for such a system comes from the development of the program interface definition framework to which it is tightly linked.
Functions and code snippets can be included in a XSH through XInclude calls.
There is several way to include existing code in a UNIX shell script program
- Copy/Paste
- The dot syntax (
. /path/to/sharedcode.sh
)
The first should be, of course, avoided. The second solution is the standard way to include function definitions. However, it is a run-time inclusion. You have to assume that the included file will not change in a way where it will break compatibility with your cade. XSH adds a compile-time approach when Xinclude is used to add XSH nodes from another file. The final script is bigger but it will not be affected by other files changes until a rebuild.
A certain level of abstraction over different UNIX shell syntaxes is addressed including function definitions and local variable definitions. In fact, while the Bash and Zsh interpreters accept both
#!bash
myfunc()
{
local v="hello"
echo $v world
}
and
#!bash
function myfunc
{
typeset var v="hello"
echo $v world
}
the (D)ash interpreter family only accepts the first syntax while Ksh accepts only the second. See examples to learn more.
- Requires a little knowledge of XML technologies, especially XInclude and XPath syntax.
- Requires a XSLT processor to generate the final script.