help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Are all traps global to a script?


From: Eric Blake
Subject: Re: [Help-bash] Are all traps global to a script?
Date: Fri, 7 Dec 2018 14:21:23 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1

On 12/7/18 2:18 PM, Eric Blake wrote:

The same way that you implement different traps for different portions of a shell script that does not use functions. You can use 'trap -p' to save off the previous trap definition, install your new trap, then when done with your code, call trap to set things back to the value you saved off earlier.

Or, by creating a subshell within the body of your function, and changing the traps local to that subshell.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

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