zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Defining commands to not evaluate certain metacharacters
Date: Sun, 21 Dec 2003 01:32:06 +0000	[thread overview]
Message-ID: <1031221013206.ZM3220@candle.brasslantern.com> (raw)
In-Reply-To: <m3y8t7jpv5.fsf@asfast.com>

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.


  reply	other threads:[~2003-12-21  1:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-20 18:39 Lloyd Zusman
2003-12-21  1:32 ` Bart Schaefer [this message]
2003-12-21  1:38   ` Philippe Troin
2003-12-21  6:53     ` Bart Schaefer
2003-12-22  4:29       ` Philippe Troin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1031221013206.ZM3220@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).