zsh-users
 help / color / mirror / code / Atom feed
* (No) Exported Functions
@ 2004-05-25 10:34 Suresh.Kannan
  2004-05-25 11:18 ` Peter Stephenson
  2004-05-25 11:49 ` Thomas Köhler
  0 siblings, 2 replies; 3+ messages in thread
From: Suresh.Kannan @ 2004-05-25 10:34 UTC (permalink / raw)
  To: zsh-users

Hi,

I've read the manuals and googled and as far as I can see, zsh doesn't appear to support exported functions. Is this true? If not please ignore the rest of the mail :)

Also, going through some old discussions, it appears that some people feel that the feature itself is of dubious value. However, I find it a shortcoming in the following situations:

1. In my environment are weird and wonderful functions that do some useful stuff on a list of files, let's say coolfun()

I can't do a 
$ find . -name '*.blah' | xargs coolfun # coolfun: No such file or directory

2. I can't invoke 
:!coolfun % 
from vim, my favourite editor.

Both shortcomings are somewhat rectified by arranging to have coolfun's definition in $HOME/.zshenv. However, this gets tedious (and possibly inefficient) when a large number of functions are involved. I tried doing a
$ functions >> ~/.zshenv
in my .zshrc as a shortcut but this puts all the autoloaded functions into the env file causing error messages when completion is first attempted etc. like:
$ cd sss<tab>
_next_label:comptags:8: no tags registered

Does anyone have a better solution / workaround to this problem. Or is exported functions somewhere in the feature-list ?

Thanks,
Suresh

Visit our website at http://www.ubs.com

This message contains confidential information and is intended only
for the individual named.  If you are not the named addressee you
should not disseminate, distribute or copy this e-mail.  Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses.  The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission.  If
verification is required please request a hard-copy version.  This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: (No) Exported Functions
  2004-05-25 10:34 (No) Exported Functions Suresh.Kannan
@ 2004-05-25 11:18 ` Peter Stephenson
  2004-05-25 11:49 ` Thomas Köhler
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2004-05-25 11:18 UTC (permalink / raw)
  To: zsh-users

Suresh.Kannan@ubs.com wrote:
> Hi,
> 
> I've read the manuals and googled and as far as I can see, zsh doesn't
> appear to support exported functions. Is this true?

That's correct.

The right way to do this is:

1. Create a directory with your functions in them, each with the same name as
   the function.  Call this ~/zsh_functions, for example.  (The standard
   zsh format is for only the body of the function to be in the file,
   but if it's all surrounded by funcname() { ... } it will still work.)

2. In your ~/.zshenv, add

   fpath=(~/zsh_functions $fpath)
   autoload ~/zsh_functions/*(:t)

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: (No) Exported Functions
  2004-05-25 10:34 (No) Exported Functions Suresh.Kannan
  2004-05-25 11:18 ` Peter Stephenson
@ 2004-05-25 11:49 ` Thomas Köhler
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Köhler @ 2004-05-25 11:49 UTC (permalink / raw)
  To: Suresh.Kannan; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 960 bytes --]

Hi,

Suresh.Kannan@ubs.com wrote:
> Hi,
> 
> I've read the manuals and googled and as far as I can see, zsh
> doesn't appear to support exported functions. Is this true? If
> not please ignore the rest of the mail :)

Apart from Peter's answer which explains all of that "exported
function" stuff, I'd like to add something...

> 1. In my environment are weird and wonderful functions that do
> some useful stuff on a list of files, let's say coolfun()
> 
> I can't do a 
> $ find . -name '*.blah' | xargs coolfun # coolfun: No such file or directory

But with "setopt extendedglob" you can do a
$ coolfun **/*.blah
which is shorter anyways :)

> Thanks,
> Suresh

Ciao,
Thomas

-- 
 Thomas Köhler       Email:       jean-luc@picard.franken.de
     <><             WWW:           http://jeanluc-picard.de
                     IRC:                           tkoehler
                     PGP public key available from Homepage!

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-05-25 12:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-25 10:34 (No) Exported Functions Suresh.Kannan
2004-05-25 11:18 ` Peter Stephenson
2004-05-25 11:49 ` Thomas Köhler

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).