Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: noquote for quotes as in noglob for filename generation?
- X-seq: zsh-users 14480
- From: Dražen Kačar <dave@xxxxxxxxxxxxxx>
- To: Sebastian Stark <seb-zsh@xxxxxxxxxxx>
- Subject: Re: noquote for quotes as in noglob for filename generation?
- Date: Sun, 11 Oct 2009 16:58:33 +0200
- Cc: Nazri Ramliy <ayiehere@xxxxxxxxx>, zsh-users@xxxxxxxxxx
- In-reply-to: <7591F47B-F5AA-42EE-849A-9D8B1EC5FCFF@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <544dda350910092001r28997c41x5ef1ffe2e6d71982@xxxxxxxxxxxxxx> <87ab002aev.fsf@xxxxxxxxxxxxxxxxxxxx> <544dda350910100053s499c0827yd54408b7f82b696d@xxxxxxxxxxxxxx> <544dda350910100233r6954f653wee358fc568e3a1a8@xxxxxxxxxxxxxx> <7591F47B-F5AA-42EE-849A-9D8B1EC5FCFF@xxxxxxxxxxx>
Sebastian Stark wrote:
> Am 10.10.2009 um 11:33 schrieb Nazri Ramliy:
>>> The mechanism you want is:
>>>
>>> ${(q)variable} # Escaped
>>> ${(qq)variable} # Single quoted
>>> ${(qqq)variable} # Double quoted
>>
>> Thank you Philippe for the tip (I learned something new). But I don't
>> think that's what I want here (or maybe I'm just too stupid to see how
>> I
>> can make use of it to do what I want :)
>
> You can't prevent zsh from removing the quotes if you add them to the
> command line of your sql script, as far as I know.
>
> But using the (q..) expansion flag you can re-add the quotes later.
I think he wants Perl quoting operators:
Customary Generic Meaning Interpolates
'' q{} Literal no
"" qq{} Literal yes
`` qx{} Command yes*
qw{} Word list no
// m{} Pattern match yes*
qr{} Pattern yes*
s{}{} Substitution yes*
tr{}{} Transliteration no (but see below)
<<EOF here-doc yes*
* unless the delimiter is ''.
So one could write "ordinary" quoting characters for other programming
languages, without quoting those characters in the zsh script source. That
would look like this:
sql_execute q{select * from foo where id='bar';}
Since the pair 'q{', '}' encloses the string, one doesn't need to quote
apostrophes inside. Something like that would be useful, mostly because
"{}" can be replaced with any pair of delimiters, so one can pick
characters which are not used in the other language (SQL in this example).
The above example could also be written as:
sql_execute q(select * from foo where id='bar';)
The minimal quoting syntax I managed to find in zsh is:
setopt rc_quotes
sql_execute 'select * from foo where id=''bar'';'
That's a bit more readable than id=\'bar\' but still requires quoting.
--
.-. .-. Yes, I am an agent of Satan, but my duties are largely
(_ \ / _) ceremonial.
|
| dave@xxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author