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 14473
- From: Nazri Ramliy <ayiehere@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: noquote for quotes as in noglob for filename generation?
- Date: Sat, 10 Oct 2009 17:33:49 +0800
- 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=HzZTeEXklK/dsmI3VU3FsZaEcB2aP/blK9SqoxGq+IM=; b=Ny7rBkyURuyAxgHYKDgX6PkE00m4o7P1wAwkGd7XDrETl8PNXt0jF41Mnp5eAI2+4F MWdbgfG2cy71W6QEGijj1bHBlgC1/Jpo5F0gxwgwJLEXt+IyTJ8HJOAennbZ5/GfWtAP TLp7EB8PZe6NpicKkPfu3PnlXqsuG2s/sKAA0=
- 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=qWbad2o2No68uPVGzU9crpJmK1LNFbnKL8T4IhT4mkXRR4nkjFwUuF9i2+wlrC+Ge2 AUWDBy+XsdvgSZXLli0Nswt9ZB+p23vOcjw1bb2u+cXzoxTny05UtNq0kD/9DtSNf4I4 rePlhJtaZFCTtlF7yM11x/0Eki83/qAUkmzm0=
- In-reply-to: <544dda350910100053s499c0827yd54408b7f82b696d@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <544dda350910092001r28997c41x5ef1ffe2e6d71982@xxxxxxxxxxxxxx> <87ab002aev.fsf@xxxxxxxxxxxxxxxxxxxx> <544dda350910100053s499c0827yd54408b7f82b696d@xxxxxxxxxxxxxx>
On Sat, Oct 10, 2009 at 11:30 AM, Philippe Troin <phil@xxxxxxxx> wrote:
> I don't see why you need eval or noglob here...
> What's wrong with replacing:
>
> sql_command=`noglob echo "$@"` # Note the noglob!
> eval mysql -u $username -p$password $db "\"$sql\""
>
> with simply:
>
> mysql -u $username -p$password $db "$*"
>
> ?
Nothing's wrong with it and it's actually simpler and better. The two lines
are just old artifacts.
> 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 :)
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 %'
I want the script to run this:
mysql -u $user -p$password $db -e "select * from Artist where
first_name like 'Michael %'"
but instead what the script run is:
mysql -u $user -p$password $db -e "select * from Artist where
first_name like Michael %"
which is wrong in SQL parlance because of the missing quote around "Michael %".
Right now I have to escape the single quotes:
$ sql select * from Artist where first_name link \'Michael %\'
which is quite cumbersome as it is distracting to my train of thought
when building the sql command.
I'm thinking of doing something in preexec() to achieve this but that
seems a bit overkill for
that single shell script.
While we're on this topic I wonder if it would also possible to do
something similar for
parenthesis as well but that might be asking for too much.
Nazri.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author