From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3324 invoked by alias); 7 Jun 2013 10:16:49 -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: 17825 Received: (qmail 2516 invoked from network); 7 Jun 2013 10:16:34 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) X-AuditID: cbfec7f4-b7fd76d0000035e1-85-51b1b2fd7541 Date: Fri, 07 Jun 2013 11:16:29 +0100 From: Peter Stephenson To: Zsh Users Subject: Re: trigger prexec function from a script Message-id: <20130607111629.1dd65bd0@pwslap01u.europe.root.pri> In-reply-to: <20130607094711.GA29399@trustfood.org> References: <20130607094711.GA29399@trustfood.org> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmluLIzCtJLcpLzFFi42I5/e/4Nd2/mzYGGjS26VjsOLmS0YHRY9XB D0wBjFFcNimpOZllqUX6dglcGR8WTWMquMdWsfX7HrYGxs2sXYycHBICJhKbrp5lhLDFJC7c W8/WxcjFISSwlFFi2pP1jFAOk0Tz9m1AGQ4OFgFViabvsSANbAKGElM3zQZrFhFQlDjz6xsT iC0sYCTxfNNZVpByXgF7ib3LY0DCnALGEjO3PWQGsYWASg5sfMEOYvML6Etc/fuJCeIGe4mZ V86AjeQVEJT4MfkeC4jNLKAlsXlbEyuELS+xec1b5gmMArOQlM1CUjYLSdkCRuZVjKKppckF xUnpuYZ6xYm5xaV56XrJ+bmbGCEB+GUH4+JjVocYBTgYlXh4f67aECjEmlhWXJl7iFGCg1lJ hPflrI2BQrwpiZVVqUX58UWlOanFhxiZODilGhh7BZmVH2V8SPyo+n+DgZPSpezlhf9Ocd5j 8np+rCh0w4OihJhpLJ78xlbhwUbbulwirmi8Xhx0+Ybw8iWc61tuhL22u/Aty/183hWps7UT 3s4J6k7N2qimNOm4+ivmx+mFZx+uX3bB4MUl51NauhtVK6/lmVqtFttuErriqHtad+2sfw1H q+cpsRRnJBpqMRcVJwIAzYtsBh4CAAA= On Fri, 07 Jun 2013 11:47:11 +0200 Eric Smith wrote: > I have a prexec function and this works fine when I put a > filename on the prompt and press enter. How do I make the preexec > fire when I deliver the command from script? Unfortunately this is quite heavily tied to executing an interactive command line, and I don't think turning on interactive mode for executing the script is good enough either (though I haven't actually tried). You're best bet might be to use the DEBUG trap. If you define the function as TRAPDEBUG instead of preexec it'll get called before each command. The effect isn't quite the same, since it'll get called more often than it would before a complete command line. You can examine what is about to be executed in $ZSH_DEBUG_CMD (see the documentation for the trap builtin). pws