you're quite right - I'm quite wrong.

If I ever work out what on earth I had in mind, I'll let you know !

wanders off mumbling....

D

In article <1297201113.3030.52.camel@homebase>, [email protected]
(Paul Smith) wrote:

> *From:* Paul Smith <[email protected]>
> *To:* [email protected]
> *CC:* [email protected]
> *Date:* Tue, 08 Feb 2011 16:38:33 -0500
> 
> On Tue, 2011-02-08 at 18:31 +0000, David Collier wrote:
> > OK - I always thought that there was a fundamental incompatibility
> > between the syntax for bash functions and that for ash
> > But I couldn't recall the details when challenged above.
> > 
> > so bash has
> >     function fred{}
> >  or
> >     fred(){}
> >     
> > and ash has
> >     fred{}
> >     
> > which means I was right originally - bash and ash scripts 
> > containing
> > functions are syntactically incompatible.
> > 
> > yes ?????
> 
> No.
> 
> As Denys points out (and others including me have pointed out 
> before)
> your syntax for function declarations in ash is wrong.
> 
> Any POSIX-based shell, and that includes bash, ash, dash, ksh, zsh, 
> and
> all the others others, supports function definitions using this 
> syntax:
> 
>         <funcname> () { <funcbody>; }
> 
> (where the final semicolon can be omitted if there's a newline 
> before
> the closing brace).  That syntax is required by POSIX and is 100%
> portable across any Bourne-like shell you'll ever find in use today.
> 
> Bash, as Denys has pointed out, adds lots and lots of new features 
> in
> addition to the features required by POSIX.  Some of these are 
> actually
> extremely useful and make bash scripts more powerful than POSIX sh
> scripts. Others, not so much.
> 
> One of the features bash adds is the extra (note EXTRA, as in "in
> addition to", not "instead of") ability to define a function using a
> syntax of:
> 
>         function <funcname> { <funcbody>; }
> 
> Again as Denys has pointed out, this is an utterly useless bit of
> language over-specification and you should simply pretend it never
> existed, and never use it.  Define your functions using the POSIX 
> form
> and it will work everywhere.
> 
> Sven had an excellent suggestion: write your scripts so they work 
> with
> ash.  99.9% of the time they'll then be portable to any POSIX-based
> shell, including bash.
> 
> 
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to