Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Anonymous function syntax and "sh" emulation



On Aug 21,  3:52pm, Peter Stephenson wrote:
}
} What's worried me is the other part of the effect, which isn't specific
} to sh emulation, which is that the first word after "function" is
} treated as not a command word, while the remaining words are treated as
} command words:
} 
} I would hazard a guess this is a bad thing, which hasn't been noticed
} because multiple words after "function" aren't very common.

This is especially interesting in that exactly the opposite happens when
defining multiple functions WITHOUT the "function" keyword:

torch% alias first='fn1 fn2' second='fn3 fn4'
torch% first second () { print $0 }
torch% functions
fn1 () {
        print $0
}
fn2 () {
        print $0
}
second () {
        print $0
}


} I suspect we can just move the "incmdpos = 1" until after we've found
} something that is either not a STRING or a possibly tokenized "{".  Not
} included in the patch below, but I'll do it unless anyone contradicts.

I would say that prefixing with "function" is a good workaround for the
function/alias conflict (maybe even update FAQ 2.3 to describe this),
so it is good if none of the words are treated as command aliases.



Messages sorted by: Reverse Date, Date, Thread, Author