On Sat, Jul 09, 2011 at 10:07:30PM +0800, Herbert Xu wrote:
> On Sat, Jul 09, 2011 at 03:07:04PM +0200, Jilles Tjoelker wrote:
> > A fix for dash is below. The dash code is broken in a different way than
> > the FreeBSD sh code was, but the patched code is pretty much the same.
> > This makes the above test work and does not change the outcome of any
> > other tests in the FreeBSD sh testsuite.

> You're right.  But I think your patch may introduce a problem
> with a return statement inside a dot script.  That should not
> have an effect after exiting the script.

Interesting. Dash has been returning from the closest scope (function or
sourced script) for a while, but the SKIPFUNC/SKIPFILE distinction and
the comment in eval.c returncmd()

]       /*
]        * If called outside a function, do what ksh does;
]        * skip the rest of the file.
]        */

still gave me the impression that it behaved like older ash (also in
FreeBSD and NetBSD), trying to be bug-compatible with the Bourne shell
by having 'return' return from a function, if any, and only return from
a dot script if there is no function (because the Bourne shell gives an
error in that case).

It may be better to name the constant SKIPRETURN rather than SKIPFUNC.

> Anyway, the following patch based on your idea should fix the
> problem.

> commit 4f7e206782675b548565ca2bc82bc8c262a0f20e
> Author: Herbert Xu <[email protected]>
> Date:   Sat Jul 9 22:05:22 2011 +0800
> 
>     [BUILTIN] Merge SKIPFUNC/SKIPFILE and only clear SKIPFUNC when leaving 
> dotcmd

Yes, this works too.

-- 
Jilles Tjoelker
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to