Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: noquote for quotes as in noglob for filename generation?



Nazri Ramliy <ayiehere@xxxxxxxxx> writes:

> What I'm trying todo:
> 
> I have a shell script named 'sql':
> that does pretty much this:
> 
> 	$ cat ~/bin/sql
> 	<uninteresting details omitted...>
> 	sql_command=`noglob echo "$@"`      # Note the noglob!
> 	eval mysql -u $username -p$password $db "\"$sql\""

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 "$*"

?

The mechanism you want is:

  ${(q)variable}    # Escaped
  ${(qq)variable}   # Single quoted
  ${(qqq)variable}  # Double quoted

(depending on which kind of quoting you want).

But again, if you remove the unnecessary intermediary variable and
eval, you shouldn't need it.

Phil.



Messages sorted by: Reverse Date, Date, Thread, Author