tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: "Matthew Calthrop +44 (0) 171 542 5317" <matthew.calthrop () reuters ! com>
To: tru64-unix-managers
Subject: SUMMARY: Exporting functions in Korn shell.
Date: Mon, 27 Jan 1997 12:01:40 +0000	[thread overview]
Message-ID: <96076450423438.tru64-unix-managers.marc@archive.invalid> (raw)


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

                 reply	other threads:[~1997-01-27 12:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox