2

I have a function. I need to use it in parallel calls. for that I need to export the function first in ksh, which O am not able to. export -f or export -q, nothing is working really.

Ansh007
  • 87
  • 9
  • I do not understand your requirements. Can you write the function in a special "utility" file and `source` that file in different scripts? – Walter A May 05 '16 at 19:39

3 Answers3

1

export -f or export -q, nothing is working really.

That's no wonder - ksh's export doesn't have such options.

Moreover, man ksh:

The export attribute of functions is currently not used.

If you don't want to use the provided means ENV and FPATH, your wish is unsatisfiable.

Armali
  • 18,255
  • 14
  • 57
  • 171
0

I know this is kinda late, but I had the same issue. So what I did was, I put my functions into a variable, and then exported the variable. In the contexts where I want the function inside of the variable, I eval the variable.

Also, you can define the function in a here document and put them into an variable as seen in this question How to assign a heredoc value to a variable in Bash?.

Stupid right? Well, it works. What a kludge. :/

Adrian
  • 10,246
  • 4
  • 44
  • 110
-1

If you are using ksh, then simply write export function_name without any options. I tried it, and it worked for me.

For example

function foo {
   #some linux scripting
}

export foo

That's it...

firoj_mujawar
  • 301
  • 4
  • 14