From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: How to exit function on a trap (INT)
Date: Tue, 16 Oct 2018 19:10:39 +0200 [thread overview]
Message-ID: <CAKc7PVBk385dgzMOO_3gJjaRZxSq95Tv+_7cY=g9PLFSV71Ntw@mail.gmail.com> (raw)
Hello,
I have an adhoc tests-related autoload-*function* `test-id-as':
https://github.com/zdharma/zplugin/blob/c1fc6d9325f97264ff155210fedd6bebc421b5e4/doc/test-id-as
It's doing `setopt localtraps' and essentially `trap '...; return 0;'
EXIT INT TERM QUIT
The problem: Single Ctrl-C doesn't stop the function, I have to hold
the key combination, see fast sequence of interrupted states of the
trying-to-execute-anyway function, to finally luckily "reach" the exit
of the function, via dense Ctrl-C signaling (result of continuous hold
of Ctrl-C keys).
I have some experience with functions and traps, and I recall I was
successfully exiting functions this way. Should this method work? What
can be wrong?
The actual trap setup is little long, but it simply has `; return 0;'
at the end:
trap '[[ $argv1 != "--keep" ]] && { ZPLGM[PLUGINS_DIR]=$plg_bkp;
ZPLGM[SNIPPETS_DIR]=$snp_bkp; } || { print; print "Kept
${ZPLGM[PLUGINS_DIR]} :: ${ZPLGM[SNIPPETS_DIR]}"; }; return 0;' EXIT
INT TERM QUIT
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
next reply other threads:[~2018-10-16 17:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 17:10 Sebastian Gniazdowski [this message]
2018-10-16 17:53 ` Daniel Shahaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKc7PVBk385dgzMOO_3gJjaRZxSq95Tv+_7cY=g9PLFSV71Ntw@mail.gmail.com' \
--to=sgniazdowski@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).