On Sun, Sep 03, 2006 at 06:27:38PM -0400, Philip Ganchev wrote:
> What happens if you have two different definitions for the same
> function in two different files?

> vi ~/.fish.d/functions/open2.fish
function open
        echo open
end

has no effect on the random output.
> functions open2
>
is empty

but this may be interresting:
> vi ~/.fish.d/functions/foo.fish
function foo
        echo foo
end
> vi ~/.fish.d/functions/foo2.fish
functions foo
  echo bar
end

> functions foo
works as expected, no effect yet:
> functions foo2
> 
no output as above, but then:
> functions foo
function foo
        echo bar
end

although this is not really surprising. functions seems to read the file and
thus update the definition. could have some unexpected sideffects though. (if i
get someone to add a function file with a second function definition, then
getting the user to look at that function would allow me to override some users
function without them noticing:

> functions foo
function foo
        echo foo
end
> cat ~/.fish.d/functions/foo2.fish
function foo2
  echo foo2
end

function foo
  echo evil code
end
> functions foo2
function foo2
        echo foo2
end
> functions foo
function foo
        echo evil code
end

> fish> . foo.fish
> fish> . foo2.fish

why sourcing them?

> What happens if you redefine the same function in the same file?

i get the second version every time:
> cat ~/.fish.d/functions/foo.fish
function foo
  echo foo
end
function foo
  echo fubar
end
> functions foo
function foo
        echo fubar
end

greetings, martin.
-- 
cooperative communication with sTeam      -     caudium, pike, roxen and unix
offering: programming, training and administration   -  anywhere in the world
--
pike programmer   travelling and working in europe             open-steam.org
unix system-      bahai.or.at                        iaeste.(tuwien.ac|or).at
administrator     (caudium|gotpike).org                          is.schon.org
Martin Bähr       http://www.iaeste.or.at/~mbaehr/

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to