DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Writing Deskshell commands

Function definitions

Functions can be defined to perform frequently-needed sequences of commands. The syntax is:

function name { script }

which assigns name as the name of script.

The script is not evaluated at this point, though it will be parsed and checked for syntax errors.

The assignment can be canceled with:

   function name { }

The list of arguments to the function is passed to the function in the variable ``*''.

A function can return a result, which can be used with the `( ) syntax. For example:

   function makeday
   {
       return $*^'day'
   }
defines a function to append 'day' to each of its arguments. Thus:
   A=Sun
   B=`(makeday $A)
sets $B to ```Sunday'''.
Next topic: Status
Previous topic: Control constructs

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003