help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] trap -p puzzle


From: Peter West
Subject: Re: [Help-bash] trap -p puzzle
Date: Thu, 23 Apr 2015 11:57:36 +1000

Thanks.  I keep forgetting about subshells.  (I do more and more forgetting 
nowadays.) I’m grateful for this list.

bash 3.2.57(1) the current Yosemite distribution.

I wonder if it would not have been better to leave this behaviour as it was.  
It may be confusing to the novice and the forgetful, but it is consistent, and 
a constant reminder of the peculiarities of pipelines.

Peter West
"Why do you seek the living among the dead? He is not here, but has risen."

> On 23 Apr 2015, at 11:30 am, Chet Ramey <address@hidden> wrote:
> 
> On 4/22/15 9:17 PM, Peter West wrote:
>> $ trap -p USR1
>> trap -- ‘rm rhubarb’ SIGUSR1
>> $ trap -p USR1 >f
>> $ cat f
>> trap -- ‘rm rhubarb' SIGUSR1
>> $ cat f|hexdump -C
>> 00000000  74 72 61 70 20 2d 2d 20  27 72 6d 20 72 68 75 62  |trap -- 'rm 
>> rhub|
>> 00000010  61 72 62 27 20 53 49 47  55 53 52 31 0a           |arb' SIGUSR1.|
>> 0000001d
>> $ trap -p USR1 | hexdump -C
>> $
>> 
>> Que?
> 
> It depends on the version of bash you're using.  Each pipeline element is
> executed in a subshell environment, and subshells do not inherit traps.
> Bash changed starting with bash-4.2 to keep the trap strings while still
> resetting the signal dispositions just so the above would work.
> 
> -- 
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]