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 14479
- From: Sebastian Stark <seb-zsh@xxxxxxxxxxx>
- To: Nazri Ramliy <ayiehere@xxxxxxxxx>
- Subject: Re: noquote for quotes as in noglob for filename generation?
- Date: Sun, 11 Oct 2009 13:07:36 +0200
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <544dda350910100233r6954f653wee358fc568e3a1a8@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <544dda350910092001r28997c41x5ef1ffe2e6d71982@xxxxxxxxxxxxxx> <87ab002aev.fsf@xxxxxxxxxxxxxxxxxxxx> <544dda350910100053s499c0827yd54408b7f82b696d@xxxxxxxxxxxxxx> <544dda350910100233r6954f653wee358fc568e3a1a8@xxxxxxxxxxxxxx>
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.
What I want is for the script to receive the quotes that I gave it
from
the command line 'unscathed'.
For example, if I ran:
$ sql select * from Artist where first_name like 'Michael %‘
In the sql script the word ‚Michael %‘ will end up in some variable,
without the quotes. The script won’t even see that it was quoted
before. If you expand this variable, add the (qq) flag.
I guess your main problem in this is that you’re using $* to simply
pass all positional parameters of the script to the actual mysql
command.
What you need is a mechanism that finds out which of those parameters
should be single quoted (sql strings). Maybe it is enough if you quote
all words that have a space in them, very roughly:
for a in $*
do
if [[ -z ${a:#* *} ]]
then
print ${(qq)a}
else
print $a
fi
done
Sebastian
Messages sorted by:
Reverse Date,
Date,
Thread,
Author