From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, URIBL_SBL,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 2208455a for ; Fri, 25 Oct 2019 17:52:52 +0000 (UTC) Received: (qmail 20398 invoked by alias); 25 Oct 2019 17:52:47 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44871 Received: (qmail 29982 invoked by uid 1010); 25 Oct 2019 17:52:47 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr1-f46.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25608. spamassassin: 3.4.2. Clear:RC:0(209.85.221.46):SA:0(-0.3/5.0):. Processed in 3.533019 secs); 25 Oct 2019 17:52:47 -0000 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.221.46 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6WnQIy/fOyxmhbN4XkRwOPfqVMGtmL4ZqIlP/5wYZvs=; b=NKK3jxjG/wiffKVDbMWpDySnPbDFQ61mxyYCGcP127OWoRiO8v44FcPgGfm5s+7Xn2 4BK/QxWgcOdwustJn11ZfG2QC0OVeaX3bl3LVohzwVLIqQ6u5kcjKB2rVfurdn+JA1Gi wxdp2RggjdfHKvjNLvUOdDoDZGNEzA9OKrWGvclXH28xPLTtq3NttAjMAn51poqME3op Cx67VNM7fGDtCUu9tKdtaLUJLak9wEfqwg9OBV3EuK2VH8J0zWVujye9n6SgYqrc2pk+ fKM8uunhYafdharTLfNGQH38m1wzzNn9I8BBl0pDi1DZduXh7QEjYsewclqJ7TArtOmk +Scw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=6WnQIy/fOyxmhbN4XkRwOPfqVMGtmL4ZqIlP/5wYZvs=; b=o1F4YdukzR0EH5nRjLQenPsF3n2+hx936xW42KBt/iTR6S1g6bwR3XgcjxeIDYIfbX KzYqCelgHrywMGxVgeMfPp2FyAAwI6jlgkZNVw4NY0i9LypdSi90F6s6nJVaLLHRnvCc t95GswLo4aQYckmX1stIvZjjUoTAtXQFaA5C7evghXnIls1t8RMEp5Vly+47GH9IVAuV il8tJiOdFIctJAGgzdeIFyAiwyJeKWVr2u9/D4cBit6fNF4qXXpuXnxhsdYuAlH/2rOd Mn9EgvqurOmMaTdwQSCBNv3VZI3tYl/HujgypgoHGZhur3O0O1PdN5YSu27dK0MqAq9g iPKg== X-Gm-Message-State: APjAAAUr5vfGnGtfciS5znuuZ1gk4M3gD8uawu8ZrC0eRloQm4LsQPGx H9qZxckEX8D+QzMiB83lwcc= X-Google-Smtp-Source: APXvYqyBlaNMgpNYBrqXcIPYixRPdRaKloHdsskFDf2bYmqIBlQZWeDdnkoIL8UNpeK05FpIu+Tnrw== X-Received: by 2002:adf:fc10:: with SMTP id i16mr3976057wrr.157.1572025928732; Fri, 25 Oct 2019 10:52:08 -0700 (PDT) Date: Fri, 25 Oct 2019 18:52:06 +0100 From: Stephane Chazelas To: Rocky Bernstein Cc: zsh-workers@zsh.org Subject: Re: Feature Request: Allow skipping zsh statement on return from trap DEBUG Message-ID: <20191025175206.7lpnhzcenlwqs4el@chaz.gmail.com> Mail-Followup-To: Rocky Bernstein , zsh-workers@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 2019-10-24 16:17:27 -0400, Rocky Bernstein: > A while ago I wrote a debugger for zsh called zshdb > . See also > https://repology.org/project/zshdb/versions . > > A feature that is missing in the debugger and that is available in the > corresponding debugger for bash, bashdb, is the skip command. > > This command skips over the upcoming statement to be executed. The way this > works in bashdb, is that if the debug hook returns with a nonzero value. > The way BASH works is that if the trap DEBUG hook returns a nonzero value, > BASH skips statement to be run. > > Thoughts about extening zsh so that it too will skip the upcoming statement > if the zsh trap DEBUG hook return a non-zero value. Or more generally some > means by which a DEBUG hook can indicate to zsh to skip the upcoming > statement? [...] See info zsh trap: } If SIG is DEBUG then ARG will be executed before each command if } the option DEBUG_BEFORE_CMD is set (as it is by default), else } after each command. Here, a 'command' is what is described as a } 'sublist' in the shell grammar, see *note Simple Commands & } Pipelines::. If DEBUG_BEFORE_CMD is set various additional } features are available. First, it is possible to skip the next } command by setting the option ERR_EXIT; see the description of the } ERR_EXIT option in *note Description of Options::. Also, the shell } parameter ZSH_DEBUG_CMD is set to the string corresponding to the } command to be executed following the trap. Note that this string } is reconstructed from the internal format and may not be formatted } the same way as the original text. The parameter is unset after } the trap is executed. Was added in 2008: https://www.zsh.org/mla/workers/2008/msg01075.html You participated in that discussion, sounds likely you actually requested the feature then. TRAPDEBUG() { echo "$ZSH_DEBUG_CMD" [[ $ZSH_DEBUG_CMD = *x* ]] && set -o errexit } echo x echo y gives: echo x echo y y -- Stephane