* SUMMARY: Exporting functions in Korn shell.
@ 1997-01-27 12:01 Matthew Calthrop +44 (0) 171 542 5317
0 siblings, 0 replies; only message in thread
From: Matthew Calthrop +44 (0) 171 542 5317 @ 1997-01-27 12:01 UTC (permalink / raw)
To: tru64-unix-managers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-01-27 12:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-01-27 12:01 SUMMARY: Exporting functions in Korn shell Matthew Calthrop +44 (0) 171 542 5317
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox