Translate

Archives

Custom Arithmetic Functions in Korn Shell 93

In modern versions of Korn Shell 93, arithmetic functions can be defined using the following shell function syntax: function .sh.math.fuctname x y z { … } where name is the function name invoked within the arithmetic syntax ((…)) and x, y and z are long double arguments passed to fuctname as name references. x, y and z are used for functions with one, two and three arguments respectively. The return value of the function is the value of the long double .sh.value variable when the function returns. Here is a simple example to try: #!/bin/ksh function .sh.math.mymath x { ((