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 14481
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: noquote for quotes as in noglob for filename generation?
- Date: Sun, 11 Oct 2009 17:05:25 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=iK2Rql2uBE61faZQyNr8F1yuuL+8viC2IxwAwdBBGA4=; b=O1qy4jiEWdQ7qkaxO6KLdr1xHUj7AoOjveRWsqtRxhZEVWV12p1Ds4YbQwfiFEumSu cp2PPq+et0Eb1wDmd+NL8P9kldymcHvs2go/1VlkuHGevBXI/bodHIjRMSJFDzKUGzRc ZCou+xPBlazp+olqrXF9LkA7mOTGVD6VTjz/k=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=aZDmgCvMt8A0syfnH6EYHqfWOZPgtD00iyceBVPQkk+UKBrEXkawfFvjenLBcol/HE r1XEsfmuUV7SyTvXqD6AKAB7xIsxf+K/HMb1yB5ia9elS/Nh0P1TKim1kc47cpSRuCWG qMd6Q/cLgnhYGxKhgCSd3s/0sFUvvsGrg6odU=
- In-reply-to: <20091011145833.GA1254@xxxxxxxxxxxxxx>
- 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> <20091011145833.GA1254@xxxxxxxxxxxxxx>
2009/10/11 DraÅen KaÄar <dave@xxxxxxxxxxxxxx>:
> 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.
Or you can just use double quotes instead.
sql "select * from foo where id = 'bar';"
or you can make sql read a line of input and do
sql
select * from foo where id = 'bar';
but of course, the whole point of the exercise was to have 'select' be an alias,
and maybe
select "* from foo where id = 'bar';"
looks weird?
I think an accept-line widget is really the only thing that could
work, but of course it will only work in simple commands, ie not for
things like echo $(for i in 1 2; do select foo) or something. (Unless
you reimplement all of zsh's parsing in the widget (not recommended)).
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author