On 9/11/06, Jason Grossman <[EMAIL PROTECTED]> wrote:
>
> On 11/09/2006, at 10:36 pm, Axel Liljencrantz wrote:
>
> > I'm not sure yet, but I'm
> > leaning towards including a function like that with fish, so that you
> > can simply issue a command like 'save_function foo' once the 'foo'
> > function works the way you want. Slightly more verbose, but less bloat
> > in the shell.
>
> Good idea.  And then why not make 'function -S foo bar' call
> 'function foo bar; save_function bar'?  That would make it more
> discoverable, wouldn't it?  Am I missing something?

That is a reasonable question. Unfortunatly there is no good way of
implementing that.

The obvious and nice way of doing that would be write a shellscript
function called 'function' that was a wrapper around the 'function'
builtin. Fish already does this with e.g. the 'cd' function that adds
additional functionality to the 'cd' builtin. Unfortunatly, fish
disallows you wo wrap 'function', 'if', 'while' 'end' and the other
builtins that create or destory a block scope. If fish didn't do this,
it would be impossible to perform many of the rather detailed syntax
checks fish does ahead of time. You might say that in the context of
function names, these words are reserved words, much like how you
can't redefine 'if' in C, Python or most other languages.

The other way of doing this, which is certainly possible, is to add
the switch parsing functionality to the 'function' builtin, but then
make 'function' call out to a shellscript function to do the heavy
lifting. This seems to me to offer very little improvement with
regards to bloat, and adds a new magic function name, which is, in my
opinion, not ideal.

It would be possible to write a wrapper around the 'functions' builtin
to save a function, though, since that builtin does not create a new
block scope. That way you'd write 'function foo; blah blah blah; end;
functions -S foo'. Would that be an improvement?

>
> Jason
>

-- 
Axel

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