|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
Re: [OT] Re: how to start in "overwrite-mode"> zle-line-init() zle overwrite-mode
> zle -N zle-line-init > > To get back on topic, bash is the only Bourne-like shell that I > know that doesn't allow that function definition syntax above, > I've always wondered why. The Posix grammar has never allowed it (a `function_body' must be a compound command, and that's what bash implements), and there has never been sufficient demand to add it as an extension. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@... http://cnswww.cns.cwru.edu/~chet/ |
|
|
Re: [OT] Re: how to start in "overwrite-mode"2009-10-28 09:00:59 -0400, Chet Ramey:
> > zle-line-init() zle overwrite-mode > > zle -N zle-line-init > > > > To get back on topic, bash is the only Bourne-like shell that I > > know that doesn't allow that function definition syntax above, > > I've always wondered why. > > The Posix grammar has never allowed it (a `function_body' must be a > compound command, and that's what bash implements), and there has > never been sufficient demand to add it as an extension. It's never allowed it to POSIX _scripts_, but it won't make a shell non-conformant to support it (and ksh, pdksh, ash, zsh even posh all do support it), just like most POSIX conformant shells support arrays for instance even though that's not a POSIX feature. bash not supporting it helps for writing POSIX compliant scripts (as it will return an error if one tries to use that non-standard feature), but as bash is the only POSIX shell that doesn't support it, it feels a bit silly. I wonder what's the rationale for POSIX not supporting it (is it because of bash?). -- Stephane |
|
|
Re: [OT] Re: how to start in "overwrite-mode"Stephane CHAZELAS wrote:
> 2009-10-28 09:00:59 -0400, Chet Ramey: >>> zle-line-init() zle overwrite-mode >>> zle -N zle-line-init >>> >>> To get back on topic, bash is the only Bourne-like shell that I >>> know that doesn't allow that function definition syntax above, >>> I've always wondered why. >> The Posix grammar has never allowed it (a `function_body' must be a >> compound command, and that's what bash implements), and there has >> never been sufficient demand to add it as an extension. > [...] > > It's never allowed it to POSIX _scripts_, but it won't make a > shell non-conformant to support it (and ksh, pdksh, ash, zsh > even posh all do support it), just like most POSIX conformant > shells support arrays for instance even though that's not a > POSIX feature. That's why I said it would be added as an extension. > bash not supporting it helps for writing POSIX compliant scripts > (as it will return an error if one tries to use that > non-standard feature), but as bash is the only POSIX shell that > doesn't support it, it feels a bit silly. "Silly" it may be, but there's not really the demand for it. > I wonder what's the rationale for POSIX not supporting it (is it > because of bash?). That would be the tail wagging the dog, wouldn't it? It's never been in the grammar. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@... http://cnswww.cns.cwru.edu/~chet/ |
|
|
Re: [OT] Re: how to start in "overwrite-mode"2009-10-28 09:46:49 -0400, Chet Ramey:
[...] > >> The Posix grammar has never allowed it (a `function_body' must be a > >> compound command, and that's what bash implements), and there has > >> never been sufficient demand to add it as an extension. > > [...] > > > > It's never allowed it to POSIX _scripts_, but it won't make a > > shell non-conformant to support it (and ksh, pdksh, ash, zsh > > even posh all do support it), just like most POSIX conformant > > shells support arrays for instance even though that's not a > > POSIX feature. > > That's why I said it would be added as an extension. Sorry, I overlooked that bit. > > bash not supporting it helps for writing POSIX compliant scripts > > (as it will return an error if one tries to use that > > non-standard feature), but as bash is the only POSIX shell that > > doesn't support it, it feels a bit silly. > > "Silly" it may be, but there's not really the demand for it. I can understand it. I was more curious about the origins. After all, that breaks Bourne backward compatibility (in a shell called Bourne-again shell)) and it seems more effort to exclude one form of command rather than include any form of command. f() for i in 1; do echo test; done f() { echo test; } > xx are allowed (and I doubt there has been a lot of demand for that), and can be confusing all the same (the second one for instance is not interpreted POSIXly by zsh). > > I wonder what's the rationale for POSIX not supporting it (is it > > because of bash?). > > That would be the tail wagging the dog, wouldn't it? It's never been > in the grammar. OK, but again, why exclude simple commands here? Would there be some implication? Has there be historical versions of sh that didn't support it? I guess I should ask the question on the POSIX list. Cheers, Stephane |
|
|
Re: [OT] Re: how to start in "overwrite-mode"On Wed, Oct 28, 2009 at 02:00:53PM +0000, Stephane CHAZELAS wrote:
> I can understand it. I was more curious about the origins. After > all, that breaks Bourne backward compatibility (in a shell > called Bourne-again shell) Bourne shell has no functions at all. > Has there be historical versions of sh that > didn't support it? Bourne shell on Ultrix and (I believe still to this day) Sun Solaris. No functions at all. None. |
|
|
Re: [OT] Re: how to start in "overwrite-mode"On Wed, 28 Oct 2009, Greg Wooledge wrote:
> On Wed, Oct 28, 2009 at 02:00:53PM +0000, Stephane CHAZELAS wrote: > > I can understand it. I was more curious about the origins. After > > all, that breaks Bourne backward compatibility (in a shell > > called Bourne-again shell) > > Bourne shell has no functions at all. Had. Only before 1984. Since then it has had functions. The first shell I used, the Bourne shell on AT&T SVR3.2, had functions. -- Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com> =================================================================== Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) |
|
|
Re: [OT] Re: how to start in "overwrite-mode"2009-10-28 11:06:09 -0400, Chris F.A. Johnson:
> On Wed, 28 Oct 2009, Greg Wooledge wrote: > > > On Wed, Oct 28, 2009 at 02:00:53PM +0000, Stephane CHAZELAS wrote: > > > I can understand it. I was more curious about the origins. After > > > all, that breaks Bourne backward compatibility (in a shell > > > called Bourne-again shell) > > > > Bourne shell has no functions at all. > > Had. Only before 1984. Since then it has had functions. > > The first shell I used, the Bourne shell on AT&T SVR3.2, had > functions. Yes, The best place for information on the Bourne shell IMO is http://www.in-ulm.de/~mascheck/bourne/index.html Where we learn that Solaris (well SunOS at the time) sh has had functions since SunOS 3, which according to http://www.levenez.com/unix/ (another great site about Unix history) takes us back to early 1986. -- Stephane |
|
|
Re: [OT] Re: how to start in "overwrite-mode"Stephane CHAZELAS wrote:
> 2009-10-28 11:06:09 -0400, Chris F.A. Johnson: >> On Wed, 28 Oct 2009, Greg Wooledge wrote: >> >>> On Wed, Oct 28, 2009 at 02:00:53PM +0000, Stephane CHAZELAS wrote: >>>> I can understand it. I was more curious about the origins. After >>>> all, that breaks Bourne backward compatibility (in a shell >>>> called Bourne-again shell) >>> Bourne shell has no functions at all. >> Had. Only before 1984. Since then it has had functions. >> >> The first shell I used, the Bourne shell on AT&T SVR3.2, had >> functions. > [...] > > Yes, > > The best place for information on the Bourne shell IMO is > http://www.in-ulm.de/~mascheck/bourne/index.html > > Where we learn that Solaris (well SunOS at the time) sh has had > functions since SunOS 3, which according to > http://www.levenez.com/unix/ (another great site about Unix > history) takes us back to early 1986. Functions were the last thing added to sh by Steve Bourne before he left Bell Labs (he finished in 1983) and first appeared in the SVR2 shell (1984). Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@... http://cnswww.cns.cwru.edu/~chet/ |
|
|
Re: [OT] Re: how to start in "overwrite-mode"Chet Ramey a écrit :
> Functions were the last thing added to sh by Steve Bourne before he > left Bell Labs (he finished in 1983) From Steve Bourne himself: <http://www.computerworld.com.au/article/279011/-z_programming_languages_bourne_shell_sh?pp=3> (very interesting interview) |
| Free embeddable forum powered by Nabble | Forum Help |