Re: [BUG] RETURN trap with -o functrace: infinite recursion on 'eval return'

2018-04-13 Thread Chet Ramey
On 4/10/18 5:56 AM, Martijn Dekker wrote:
> $ bash -o functrace -c 'fn() { eval "return"; }; trap "fn" RETURN; fn'
> 
> Result: segfault due to infinite recursion.

Thanks for the report; I'll fix this.

 __
> 
> Even apart from this bug with 'eval return', the effect of '-o functrace'
> is a bit strange:
> 
> $ bash -o functrace -c 'fn() { printf foo; fn2; };
> fn2() { printf bar; fn3; };
> fn3() { printf baz\\n; };
> trap fn RETURN; fn'
> foobarbaz
> foobarbaz
> foobarbaz
> foobarbaz
> 
> (I'd expect one 'foobarbaz', not four)
> 
> It seems odd that the RETURN trap would be triggered while a RETURN trap
> action is still being executed. Might it be better to temporarily
> deactivate the effect of '-o functrace' while a RETURN trap action is being
> executed?

Well, trap handlers are recursive, in the sense that you can execute a trap
on signal X from a signal X trap handler. If the RETURN trap is inherited
by functions, and traps are recursive, wouldn't the bash behavior be the
logical thing to do? (Yes, I know there are problems with recursive signal
handler invocations in bash-4.4.)

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: Character \001 disappears from here document if 'word' is unquoted.

2018-04-13 Thread Chet Ramey
On 4/12/18 12:13 PM, Jorge Alberto Baca Garcia wrote:

> Bash Version: 4.4
> Patch Level: 18
> Release Status: release
> 
> Description:
> Character \001 disappears from here document if 'word' is unquoted.

Thanks for the report. This will be fixed in the next devel branch push.

Chet


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: Errors in documentation

2018-04-13 Thread Chet Ramey
On 4/12/18 6:07 PM, Jorge Maldonado Ventura wrote:
>> The SVR4.2 shell has two privilege-related builtins (|mldmode| and
> |priv|) not present in Bash.
> 
> This text is under the section "Appendix B Major Differences From The
> Bourne Shell"; it should be under the section "B.1 Implementation
> Differences From The SVR4.2 Shell".

No, that's not what that section means.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: [BUG] RETURN trap with -o functrace: infinite recursion on 'eval return'

2018-04-13 Thread Martijn Dekker

Op 14-04-18 om 03:49 schreef Chet Ramey:

On 4/10/18 5:56 AM, Martijn Dekker wrote:

It seems odd that the RETURN trap would be triggered while a RETURN trap
action is still being executed. Might it be better to temporarily
deactivate the effect of '-o functrace' while a RETURN trap action is being
executed?


Well, trap handlers are recursive, in the sense that you can execute a trap
on signal X from a signal X trap handler.


I'm not sure how that would happen. Isn't a signal blocked while 
executing its trap handler?



 If the RETURN trap is inherited
by functions, and traps are recursive, wouldn't the bash behavior be the
logical thing to do?


I suppose. But if a signal is blocked while executing the respective 
trap, perhaps it would also be logical to deactivate the RETURN 
pseudosignal while executing a RETURN trap.


It seems like this is already done for the ERR pseudosignal, as "trap 
false ERR; false" does not cause an infinite loop.


- M.