From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18150 invoked from network); 21 Dec 2003 01:32:28 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 21 Dec 2003 01:32:28 -0000 Received: (qmail 14625 invoked by alias); 21 Dec 2003 01:32:10 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6936 Received: (qmail 14483 invoked from network); 21 Dec 2003 01:32:09 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 21 Dec 2003 01:32:09 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.11.8.53] by sunsite.dk (MessageWall 1.0.8) with SMTP; 21 Dec 2003 1:32:8 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id hBL1W7e03221 for zsh-users@sunsite.dk; Sat, 20 Dec 2003 17:32:07 -0800 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to schaefer@closedmail.com using -f From: Bart Schaefer Message-Id: <1031221013206.ZM3220@candle.brasslantern.com> Date: Sun, 21 Dec 2003 01:32:06 +0000 In-Reply-To: Comments: In reply to Lloyd Zusman "Defining commands to not evaluate certain metacharacters" (Dec 20, 1:39pm) References: X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.dk Subject: Re: Defining commands to not evaluate certain metacharacters MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Dec 20, 1:39pm, Lloyd Zusman wrote: } } I want to define a set of commands that I can execute from the command } line under zsh. This is very nearly a non-starter. The shell parses shell syntax, not the syntax of some other language. You can get part of the way there with the "noglob" precommand modifier, but that doesn't change the special meanings of parentheses, braces, or redirections. You can get somewhat farther by using ZLE widgets to read the input and reprocess it before handing it to the shell parser, but that still means using some additional step to invoke that ZLE widget. Theoretically you could rebind accept-line to a wrapper that checks whether the first word on the line is one of your special commands, but that gets fragile if you make any attempt to handle multi-line inputs. function quoting-accept-line { local q='"' words words=( $=BUFFER ) case $words[1] in CMD|etc) BUFFER="$words[1] $q${words[2,-1]}$q";; esac zle .accept-line } zle -N accept-line quoting-accept-line However what I'd most recommend is that you write a function that runs a "while read line; do ...; done" loop, which "eval"s anything that looks like a shell assignment and otherwise invokes your mathematical processor.