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

Re: quoting arguments in a script



Phil Pennock wrote:
> On 2008-10-14 at 21:28 +0200, denis wrote:
> > I'm looking for a way to quote strings in a zsh script.
>
> you should probably be looking at something like:
> 
>   ${(q)^^@}

Thank you very much, that's what I was looking for.

Although it took me a while until I figured out how to accomplish
the whole task:

  #!/bin/zsh
  helper () {
      emacsclient -e \
          "(progn
             (cd \"$PWD\")
             (grep ${(qqq)${(q)@}}))"
  }
  helper grep -nH "$@"

The arguments have to be quoted twice. One level as the parameter
to emacsclient and another one for the parameters to the
grep-command.
And then I had the problem with appending the $@-arguments to
"grep -nH", why I added the helper-function.

Probably not the neatest way to do it, but it works.

Regards,
Denis

PS: If you are using emacs you should try the script.  Grepping is
    more fun if you can click the results :-)



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