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

Re: PATCH: skip command from debug trap



On Wed, Aug 06, 2008 at 07:22:36AM -0700, Bart Schaefer wrote:
[...]
> 	x=3
> 	return --x
> 
> returns "2".  How are you going to make any kind of option parsing for
> return behave compatibly with that? 

See for instance kill(1). To kill a process group, you have to
do:

kill -- -<pid>

So you'd have to do

return -- -3

> } (In fact, the lack of option parsing, even --, in return is strictly a
> } bug, so this even makes it more compatible with other shells.)
> 
> It'd have to be only in emulation mode, then.

-- is not a valid math expression, so changing return -- so that
it is the same as "return" instead of giving an error message
shouldn't be a problem.

Changing return -1 so that it outputs an error message instead
of returning with $? == -1 could break existing scripts.

BTW, is this:

$ zsh -c '(){echo test;return 1}; echo $?'
test
0

the expected output?

-- 
Stéphane



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