XML Shell script overview

What is this ?

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.

Benefits

Flexibilty

Functions and code snippets can be included in a XSH through XInclude calls.

Robust inclusion

There is several way to include existing code in a UNIX shell script program

  1. Copy/Paste
  2. 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.

Genericity

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

myfunc()
{
  local v="hello"
  echo $v world
}

and

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.

Drawbacks

See also