Zsh Mailing List Archive
Messages sorted by:
Re: echo "!" ... what's wrong with the exclamation point ?
- X-seq: zsh-users 11323
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: echo "!" ... what's wrong with the exclamation point ?
- Date: Wed, 21 Mar 2007 11:52:49 +0000
- In-reply-to: <20070321124237.0e17eace@xxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20070321124237.0e17eace@xxxxxxxxxxxxxxxxx>
> I'm using zsh for some time but I just needed to put an exclamation
> point inside double quotes and I get something wierd:
This is traditional C shell "bang history". It's described in the
zshexpn manual page under HISTORY EXPANSION. You can turn it off
if you never use it (it sounds like you don't). Alternatively,
- single quotes quote the !'s (double quotes don't)
- sticking a !" near the start of the line will turn off bang history
for that line.
- add an extra \ before an exclamation mark.
Note that !'s are never active in text read from files (including
autoloaded functions), so you only see this effect at the command
> $ echo "abc ! def"
> abc ! def
This still works because a ! followed by a space is specially treated.
That's so other uses of exclamation marks in tests still work.
> $ echo "abc !"
> dquote> "
This is the use I mentioned above to turn off special handling of !'s
for the rest of the line. The !" gets swallowed up in one go by
the history mechanism---that's way it's still waiting for a double
quote and you don't get a ! in the output.
> $ echo "abc !! def"
> echo "abc echo "abc
> " def"
> abc echo abc
> zsh: command not found: def
The !! refers to the complete previous line.
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview
Messages sorted by: