Antoine via Dng wrote:
> Steve Litt wrote:
> > With my /bin/sh (which I believe is dash) I had to change:
> > 
> > function whatever {
> > 
> > to
> > 
> > whatever() {
> > 
> > on all three function declarations.
> 
> Yes, now that you mention it, that tends to vary between shells. I should
> have included them.

Portable shell use would be "whatever() {" which I wish to encourage
by saying that here.  Please use only that form for /bin/sh scripts. :-)

The "function" keyword was introduced by ksh.  This syntax is also
supported by bash and zsh but not by other shells.  When "function" is
used then the #! line must be /bin/ksh, /bin/bash, or /bin/zsh.

The ksh book refers to the other format as compatible "with recent
versions of the Bourne shell" (which I find funny now) because as we
know the original Bourne shell did not support functions at all.  The
book also reminds us that "{" and "}" are reserved words.  Meaning
that they must be separated from other tokens by whitespace in order
to be recognized.  They form a shell compound-list of commands.

Bob

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to