[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] trap -p puzzle
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] trap -p puzzle |
Date: |
Wed, 22 Apr 2015 21:30:08 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
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/