zsh-users
 help / color / mirror / code / Atom feed
* turning off quote interpolation
@ 2004-04-19 11:18 Eric Smith
  2004-04-19 16:17 ` Philippe Troin
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Smith @ 2004-04-19 11:18 UTC (permalink / raw)
  To: zsh-users

I have for example a function that passes args to google search.
Most times I \"quote a few words\" but have to escape the quotes so that 
the shell passes them through to the command :)

How can I have zsh pass the quotes through without having
to type extra backslashes or whatever?

Thanks!



-- 
Eric Smith


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: turning off quote interpolation
  2004-04-19 11:18 turning off quote interpolation Eric Smith
@ 2004-04-19 16:17 ` Philippe Troin
  2004-04-19 16:22   ` Eric Smith
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Troin @ 2004-04-19 16:17 UTC (permalink / raw)
  To: Eric Smith; +Cc: zsh-users

Eric Smith <es@fruitcom.com> writes:

> I have for example a function that passes args to google search.
> Most times I \"quote a few words\" but have to escape the quotes so that 
> the shell passes them through to the command :)
> 
> How can I have zsh pass the quotes through without having
> to type extra backslashes or whatever?

Show us the function...

Phil.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: turning off quote interpolation
  2004-04-19 16:17 ` Philippe Troin
@ 2004-04-19 16:22   ` Eric Smith
  2004-04-19 16:56     ` Phil Pennock
  2004-04-20  4:00     ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Smith @ 2004-04-19 16:22 UTC (permalink / raw)
  To: zsh-users

Sure,

goo () {
        w3m "http://www.google.com/search?q=$1+$2+$3+$4+$5+$6+$7+$8&num=100"
}

... trivial

According to Philippe Troin on Mon, Apr 19, 2004 at 09:17:44AM -0700:
> Eric Smith <es@fruitcom.com> writes:
> 
> > I have for example a function that passes args to google search.
> > Most times I \"quote a few words\" but have to escape the quotes so that 
> > the shell passes them through to the command :)
> > 
> > How can I have zsh pass the quotes through without having
> > to type extra backslashes or whatever?
> 
> Show us the function...

Eric


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: turning off quote interpolation
  2004-04-19 16:22   ` Eric Smith
@ 2004-04-19 16:56     ` Phil Pennock
  2004-04-20  4:00     ` Bart Schaefer
  1 sibling, 0 replies; 5+ messages in thread
From: Phil Pennock @ 2004-04-19 16:56 UTC (permalink / raw)
  To: zsh-users

On 2004-04-19 at 18:22 +0200, Eric Smith wrote:
> goo () {
>         w3m "http://www.google.com/search?q=$1+$2+$3+$4+$5+$6+$7+$8&num=100"
> }

If memory serves, you can't turn off the quoting stuff since that
happens well before it's passed to a function or alias.

FWIW, the power of zsh lets you do something like join the elements of
an array together with a specified string used between each element.

Eg, my equivalent function is defined as:

  function google {
        ${WebBrowser:-w3m} "http://www.google.com/search?q=${(j:+:)@}"
  }

So, something like:

  function goo { w3m "http://www.google.com/search?q=${(j:+:)@}&num=100" }

should help you get rid of that limit which you have.

Beyond that, it's just a matter of getting into the habit of trapping
quotes around strings, to allow things like & in a URL.

I got in the habit of things like:
% google '"Elizabeth Moon"'
to look up information on one of my favourite authors, for instance.

-Phil


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: turning off quote interpolation
  2004-04-19 16:22   ` Eric Smith
  2004-04-19 16:56     ` Phil Pennock
@ 2004-04-20  4:00     ` Bart Schaefer
  1 sibling, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2004-04-20  4:00 UTC (permalink / raw)
  To: zsh-users

On Apr 19,  6:22pm, Eric Smith wrote:
} 
} goo () {
}   w3m "http://www.google.com/search?q=$1+$2+$3+$4+$5+$6+$7+$8&num=100"
} }

Question:  Does it harm anything to include quotes when they aren't
needed?

goo() {
  w3m "http://www.google.com/search?q=${(j:+:)${(qqq)@}}&num=100"
}

With that def'n, the command

	goo "foo bar" baz

calls w3m on a URL that looks like

	http://www.google.com/search?q="foo bar"+"baz"&num=100

where the quotes around "baz" are extraneous but (I think) harmless.

Note though that also with that def'n the command

	goo 'foo " bar'

produces the URL

	http://www.google.com/search?q="foo \" bar"&num=100

in which the backslash may not do what you want.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-04-20  4:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-19 11:18 turning off quote interpolation Eric Smith
2004-04-19 16:17 ` Philippe Troin
2004-04-19 16:22   ` Eric Smith
2004-04-19 16:56     ` Phil Pennock
2004-04-20  4:00     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).