zsh-workers
 help / color / mirror / code / Atom feed
* export -f problem
@ 2001-11-02 19:01 Borsenkow Andrej
  2001-11-03  0:23 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Borsenkow Andrej @ 2001-11-02 19:01 UTC (permalink / raw)
  To: ZSH Workers Mailing List

Mandrake has startup function that looks like:

mc ()
{
... define some suff ...
}

[[ $SHELL = "/bin/bash" ]] && export -f mc

If your login shell is bash and you call zsh you get:

[root@localhost root]# zsh
mc () {
         mkdir -p $HOME/.mc/tmp 2> /dev/null
         chmod 700 $HOME/.mc/tmp
         MC=$HOME/.mc/tmp/mc-$$
         /usr/bin/mc -P "$@" > "$MC"
         cd "`cat $MC`"
         rm -i -f "$MC"
         unset MC
}

because export -f mc just prints out mc() code.

While the condition above is wrong (it should test for BASH_VERSION) - 
should we either make zsh set SHELL or be more compatible with export -f?

-andrej


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

* Re: export -f problem
  2001-11-02 19:01 export -f problem Borsenkow Andrej
@ 2001-11-03  0:23 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2001-11-03  0:23 UTC (permalink / raw)
  To: ZSH Workers Mailing List

Egad.  Apparently the rule is, if the first four characters of the value
of an environment variable are `() {', it gets defined as a function upon
import.  Look:

schaefer[504] export foo='(){echo hi there;}'
schaefer[505] bash2
bash2-2.03$ foo
bash2: foo: command not found
bash2-2.03$ 
schaefer[506] export foo='() {echo hi there;}'
schaefer[507] bash2
bash2: foo: line 1: syntax error near unexpected token `{echo'
bash2: foo: line 1: `foo () {echo hi there;}'
bash2: error importing function definition for `foo'
bash2-2.03$ 
schaefer[508] export foo='() { echo hi there; }'
schaefer[509] bash2
bash2-2.03$ foo
hi there
bash2-2.03$ 

I think this is rather horrible; but, if we actually implement something
like this, we have to make sure that we do not allow `preexec', `precmd',
`periodic', `TRAPxxx', etc. to be imported.


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

end of thread, other threads:[~2001-11-03  0:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-02 19:01 export -f problem Borsenkow Andrej
2001-11-03  0:23 ` Bart Schaefer

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).