From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 356 invoked by alias); 29 Feb 2012 15:56:08 -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: 16815 Received: (qmail 11205 invoked from network); 29 Feb 2012 15:56:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120229075548.ZM27723@torch.brasslantern.com> Date: Wed, 29 Feb 2012 07:55:48 -0800 In-reply-to: <20120229134829.GA31200@localhost.mi.fu-berlin.de> Comments: In reply to "Christoph (Stucki) von Stuckrad" "Re: s/pattern/pattern/g on the commandline ?" (Feb 29, 2:48pm) References: <20120225182450.GA31597@solfire> <20120227041300.GA3063@solfire> <20120229134829.GA31200@localhost.mi.fu-berlin.de> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: s/pattern/pattern/g on the commandline ? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Feb 29, 2:48pm, Christoph (Stucki) von Stuckrad wrote: } } BUT I never fond out, how to put the edited lines into the history } BUT NOT EXCUTE them (once I'm in the editor by fc...). } So in this case I always saved to some other place and aborted editing. fc_noexec() { integer skip_count=0 setopt DEBUG_BEFORE_CMD TRAPDEBUG() { if (( skip_count > 1 )) then unfunction TRAPDEBUG setopt ERR_EXIT no_DEBUG_BEFORE_CMD return 1 else (( skip_count++ )) return 0 fi } fc "$@" } I think there's a small bug with DEBUG_BEFORE_CMD in that the debug trap is executed *twice* for the single command "fc", which is why the (( skip_count > 1 )) is in there. If that behavior changes, the test will also need to change. Also I've assumed DEBUG_BEFORE_CMD is normally off, tweak that if you have it on. -- Barton E. Schaefer