From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96076450423438.tru64-unix-managers.marc@archive.invalid> From: "Matthew Calthrop +44 (0) 171 542 5317" Date: Mon, 27 Jan 1997 12:01:40 +0000 To: tru64-unix-managers Subject: SUMMARY: Exporting functions in Korn shell. X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96076450423438 My original posting: =It seems impossible to export a function so that it is inherited by a =new invocation of the Korn shell, despite what the manual page says. = =I have tried everything I could think of, including using "typeset =-xf", and I can't get it to work. = =Can anyone help me on this one? =Is this a "known bug"? =Is there another version of the Korn shell which actually does this? The solution was quite simple and neat, if poorly (un?) documented. 1. In /etc/profile (or a user's .profile, as required) define the environment variable FPATH to point to a directory in which functions will exist, eg export FPATH=/usr/local/functions. You can treat this env. variable like the PATH variable, and append other directories, separated by a colon. 2. For each function required, create a file in one of the directories in $FPATH. The name of the file will be the name of the function, and the file will contain the function definition as well. Eg, contents of /usr/local/functions/dir: #!/bin/ksh # do a long listing, piped to $PAGER dir() { /bin/ls -lAF $* | $PAGER } The function will not be loaded into memory until called: mjc@knowledge> type dir dir is an undefined function mjc@knowledge> dir /tmp total 1426 drwxrwxrwt 2 root 8192 Jan 23 10:12 .X11-unix/ drwx------ 2 root 8192 Dec 19 12:53 .tags/ ...blah... mjc@knowledge> type dir dir is a function mjc@knowledge> Thanks to Steve Beikman (beikman@xtdl.com) for his help. regards, Matt matthew.calthrop@reuters.com