From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1447 invoked by alias); 21 Feb 2017 16:22:11 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22478 Received: (qmail 25517 invoked from network); 21 Feb 2017 16:22:11 -0000 X-Qmail-Scanner-Diagnostics: from mta02.eastlink.ca by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(24.224.136.13):SA:0(-0.7/5.0):. Processed in 0.986662 secs); 21 Feb 2017 16:22:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: rayandrews@eastlink.ca X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.eastlink.ca designates 24.224.136.13 as permitted sender) X-Authority-Analysis: v=2.2 cv=DOfN2GFb c=1 sm=1 tr=0 a=aWG3ZaPfpGbmBTXoUM+q2Q==:117 a=aWG3ZaPfpGbmBTXoUM+q2Q==:17 a=IkcTkHD0fZMA:10 a=k1o5rhKkhq6N8x-i4g0A:9 a=QEXdDO2ut3YA:10 X-EL-IP-NOAUTH: 24.207.17.185 Subject: Re: trap ERR To: zsh-users@zsh.org References: From: Ray Andrews Message-id: Date: Tue, 21 Feb 2017 07:52:02 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-version: 1.0 In-reply-to: Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit On 20/02/17 10:08 PM, Ray Andrews wrote: > I haven't played around with traps much, but trying this in a script: > > trap 'echo ERROR at $0 $LINENO; return' ERR > > cp file1/tmp > cp no_such_file/tmp > cp file2/tmp > > # trap '' ERR > > I want to return with the message at any error, and it does return, > but it seems that the trap remains in effect which puzzles me since > when a script quits, I expect things to be returned to stock, no? The > commented line kills the trap fine, but of course if I return at the > first error, it's never executed. > > Also, I'd expect to 'exit' a script, but it ends up killing the whole > terminal. I'm used to using 'return' but now that I stop to think > about it, that should be wrong, no? Pardon, that was a moronic question. I'm so used to sourcing scrips that I mostly forget that there is any such thing as executing them and I'm sourcing automatically even when I think I'm executing -- I type the little dot so fast I don't even notice it. I don't execute because I don't know how to have access to my functions inside an executed script. Can I? If so, all the above difficulties go away. > > > >