Warning: file_get_contents(documentation/articles/samplesminiappcmdline.h.html): failed to open stream: No such file or directory in /home/norejdls/sites/ns-xml/www/lib/ns-php/ns/ui/tab.5.php on line 90

Warning: file_get_contents(documentation/articles/samplesminiappcmdline.h.html): failed to open stream: No such file or directory in /home/norejdls/sites/ns-xml/www/lib/ns-php/ns/ui/tab.5.php on line 90

Warning: Cannot modify header information - headers already sent by (output started at /home/norejdls/sites/ns-xml/www/lib/ns-php/ns/ui/tab.5.php:90) in /home/norejdls/sites/ns-xml/www/index.php on line 124
ns-xml project home ~ XSLT documentation
  / languages / shellscript.html

Table of content

Parameters

Variables

Templates


Details

Parameters

Interpreter dialect. Could be bash, ksh or zsh

Default value: 'sh'
If set, force to use this expression to adjust array indexes

Variables

sh.endl="$str.unix.endl"
End of line character for UNIX shell scripts

Default value: $str.unix.endl

Templates

sh.block(indent="true()", content, addFinalEndl="true()")

UNIX shell script code block (Indented code block)
  1. indent
    Indent the content if true (the default)
    Default value: true()
  2. content
    Code snippet
  3. addFinalEndl
    Add a End-of-line at end of block
    Default value: true()

UNIX shell comment block
  1. content
    Comment text
    Default value: .
sh.local(name, interpreter="$sh.interpreter", value, quoted="'auto'")

UNIX shell local variable definition
  1. name
    Variable name
  2. interpreter
    Interpreter type
    Default value: $sh.interpreter
  3. value
    Variable initial value
  4. quoted
    Indicates if the value value have to be quoted. Expect a boolean or the special value 'auto'
    Default value: 'auto'

Attempt to transform a string into a valid identifier name (variable, function)
  1. name

UNIX shell variable call
  1. name
    Variable nmme
  2. index
    Treat the variable as an array and retrieve the $index element (not compatible with all shells)
  3. start
    Retrieve a substring of the variable content starting at offset $start (not compatible with all shells)
  4. length
    Retrieve a substring of $length character of the variable content (not compatible with all shells)
  5. quoted
    Add quotes around
    Default value: false()
sh.varLength(name, quoted="false()")

Create the expression to retrieve a variable value length (${#var})
  1. name
    Variable name
  2. quoted
    Add quotes around
    Default value: false()

Operations on itself
  1. name
    Variable name
  2. operator
    Operator
    Default value: '+'
  3. value
    Second operand
    Default value: 1

Treat the variable as an integer value and increment its value
  1. name
    Variable name
  2. value
    Increment value
    Default value: 1

Create the expression to retrieve an array element count (not compatible with all shells)
  1. name
    Variable name
sh.arrayIndex(index, interpreter="$sh.interpreter", offsetExpression="$sh.arrayOffsetExpression")

Adjust array index according interpreter array indexing offset policy. Most of interpreters use 0-based index whereas Zsh use 1-based index
  1. index
    Zero-based index to adjust
  2. interpreter
    Interpreter dialect
    Default value: $sh.interpreter
  3. offsetExpression
    User-defined array index offset expression. This parameter prevails on $interpreter
    Default value: $sh.arrayOffsetExpression
sh.arraySetIndex(name, index, value, interpreter="$sh.interpreter", offsetExpression="$sh.arrayOffsetExpression")

Set an element of an array variable
  1. name
    Variable name
  2. index
    Array index.
  3. value
    Element value
  4. interpreter
    Interpreter dialect. If specified, the index value will be adjusted according interpreter array indexinngpolicy
    Default value: $sh.interpreter
  5. offsetExpression
    User-defined array index offset. This prevails over the $interpreter value
    Default value: $sh.arrayOffsetExpression

Append a new element to an array variable
  1. name
    Variable name
  2. value
    New element value
  3. startIndex
    First element of the array (depends on interpreter type)
    Default value: 0
sh.arrayCopy(from, to, indexVariableName="'i'", append="true()", interpreter="$sh.interpreter", offsetExpression="$sh.arrayOffsetExpression", declareLocal="false()")

Copy array elements to another variable (not compatible with all shells)
  1. from
    Input variable name
  2. to
    Output variable name
  3. indexVariableName
    Name of the index variable used in loop
    Default value: 'i'
  4. append
    Default value: true()
  5. interpreter
    Interpreter dialect. Array indexes will be adjusted according interpreter array indexing policy
    Default value: $sh.interpreter
  6. offsetExpression
    User-defined array index offset. This prevails over the $interpreter value
    Default value: $sh.arrayOffsetExpression
  7. declareLocal
    Declare temporary variable as local variable
    Default value: false()
sh.arrayForEach(name, elementVariableName="'i'", interpreter="$sh.interpreter", declareLocal="false()", do)

Iterate through array elements
  1. name
    Array variable name
  2. elementVariableName
    Variable representing the current element
    Default value: 'i'
  3. interpreter
    UNIX shell interpreter type
    Default value: $sh.interpreter
  4. declareLocal
    Declare temporary variable as local variable
    Default value: false()
  5. do
sh.functionDefinition(name, content, indent="true()", interpreter="$sh.interpreter")

UNIX shell function definition (not compatible with all shells)
  1. name
    Function name
  2. content
    Function body
  3. indent
    Indicates if the function body have to be indented
    Default value: true()
  4. interpreter
    UNIX shell interpreter type
    Default value: $sh.interpreter

While statement
  1. condition
    Condition
  2. do
    Loop code
  3. indent
    Default value: true()
sh.for(condition, do, indent="true()")

For statement
  1. condition
    For condition
  2. do
  3. indent
    Indent *do* block
    Default value: true()
sh.sequenceFor(variable="i", init="0", limit, increment="1", do, indent="true()", interpreter="$sh.interpreter", declareLocal="false()")

Range for loop
  1. variable
    Default value: i
  2. init
    Initial value
    Default value: 0
  3. limit
    Outer limit
  4. increment
    Default value: 1
  5. do
  6. indent
    Default value: true()
  7. interpreter
    UNIX shell interpreter type
    Default value: $sh.interpreter
  8. declareLocal
    Declare temporary variable as local variable
    Default value: false()
sh.incrementalFor(variable="i", init="0", operator="'<'", limit, increment="1", do, indent="true()", interpreter="$sh.interpreter", declareLocal="false()")

C-style for loop
  1. variable
    Increment variable name
    Default value: i
  2. init
    Initial value
    Default value: 0
  3. operator
    Default value: '<'
  4. limit
    Increment limit
  5. increment
    Default value: 1
  6. do
  7. indent
    Default value: true()
  8. interpreter
    UNIX shell interpreter type
    Default value: $sh.interpreter
  9. declareLocal
    Declare temporary variable as local variable
    Default value: false()
sh.if(condition, then, else, indent="true()", shortForm="true()")

IF statement
  1. condition
    Condition
  2. then
    Code to execute if the condition is true
  3. else
    Code to execute if the condition is false
  4. indent
    Indent 'then' and 'else' blocks
    Default value: true()
  5. shortForm
    When possible, use the short form [ {condition} ] && {then}
    Default value: true()
sh.case(case, in, indent="true()")

CASE statement
  1. case
    Case variable name
  2. in
    Case body
  3. indent
    Default value: true()
  1. case
  2. content
  3. indent
    Default value: true()

Escape a string literal
  1. value
  2. quoteChar
    Value to escape. Assumes the given parameter does not already contains any escaped character
    Default value: "'"
  3. evaluate
    Enclosing quotes character
    Default value: false()

1>/dev/null 2>&1
sh.chunk.arrayValueExists(name, value, interpreter="$sh.interpreter", declareLocal="false()", onExists="'return 0'", otherwise="'return 1'")

Check if a value exists in array elements.
  1. name
    Array variable name
  2. value
    Value to check
  3. interpreter
    UNIX shell interpreter type
    Default value: $sh.interpreter
  4. declareLocal
    Declare temporary variable as local variable
    Default value: false()
  5. onExists
    What to do if value exists
    Default value: 'return 0'
  6. otherwise
    What to do if value does not exists
    Default value: 'return 1'