Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
How to exit function on a trap (INT)
- X-seq: zsh-users 23712
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: How to exit function on a trap (INT)
- Date: Tue, 16 Oct 2018 19:10:39 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=QTb8HMlgTY9e8ngNUnE0/XY4/Wcv2jrAQ4/2zde3Edo=; b=oB/8s7dEBvSlDVRTg+vbbyEHY8d9B2wDYajCx2iI+tmRLT91SQwYD+81XqiJ5eQ4LE 6Fh9hXYDMMYXuzzBHWEYoGGF9s27PyR16w/n7Ny3N2C3ACqXpa/r0oeP5BDaTRfIDRoy ULHHVyM6lEcKLzvsUu6LhHfjJ7INsgNoE1VPSWQ469zgZVMSr+3c8NBUB5Ss8VJ07R25 XoFk+8yYpVtQm9SuyHZ25c5mEiudwt62mJFXJ8G0/WwWYHGkWybDojgqdnsBP0/Qgz+B CkGnv5rWNBoE5eymfEcsYc67bIVDKKgkFQGUu7s9lp0c1iDG6LF7MnDH/zDqD6Og/PEl Ip5A==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author