Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Defining commands to not evaluate certain metacharacters
- X-seq: zsh-users 6934
- From: Lloyd Zusman <ljz@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Defining commands to not evaluate certain metacharacters
- Date: Sat, 20 Dec 2003 13:39:10 -0500
- Cancel-lock: sha1:C37CN0pJUaY74rVMGzU/0arIM5c=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Sender: news <news@xxxxxxxxxxxxx>
I want to define a set of commands that I can execute from the command
line under zsh. These commands will be performing certain mathematical
operations on their arguments, and therefore, I would like parentheses
and possibly also square brackets to be passed to the command unchanged
by the shell. However, I want to be able to use variable expansion.
I would like to do this without quoting these parentheses (or square
brackets, if I use them). For example, if CMD is one of the commands
that I define and OP1, OP2, and OP3 are operations that CMD understands,
I would like the following to take place:
a=3
b=4
CMD (($a OP1 1) OP2 ($b OP3 2))
means: expand $a and $b on the command line, so that the
intermediate result is this:
CMD ((3 OP1 1) OP2 (4 OP3 2))
then, pass the string '((3 OP1 1) OP2 (4 OP3 2))' as the
command line to CMD, which then interprets it as it pleases.
I know that I can achieve this result by double-quoting the command
line, as follows:
CMD "(($a OP1 1) OP2 ($b OP3 2))"
However, as I mentioned above, my goal is to avoid using quotes.
Is there any way to set up aliases or something similar under zsh so
that I can define commands that will function like my CMD example?
Thanks in advance.
--
Lloyd Zusman
ljz@xxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author