zsh-users
 help / color / mirror / code / Atom feed
From: "Lawrence Velázquez" <vq@larryv.me>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: protect spaces and/or globs
Date: Tue, 9 Feb 2021 20:46:40 -0500	[thread overview]
Message-ID: <3E154CC1-4B1F-4ADB-993F-89100A7F766A@larryv.me> (raw)
In-Reply-To: <29a203d5-bf53-9cb7-7a49-2705c3b1d8f2@eastlink.ca>

> On Feb 9, 2021, at 7:51 PM, Ray Andrews <rayandrews@eastlink.ca> wrote:
> 
> On 2021-02-09 4:22 p.m., Lawrence Velázquez wrote:
>> For the less clairvoyant of us, your refusal to reveal anything but
>> the smallest slice of your actual code makes it rather difficult
>> to help.
>> 
> I'm trying to keep is as simple as possible because the totality of the thing doesn't
> matter, just the specific problem.

Imagine developing stomach pain, self-diagnosing an ulcer, and
refusing to answer doctors' questions about medication, diet,
existing conditions, or anything not ulcer-related because you're
"trying to keep it as simple as possible because the totality of
the thing doesn't matter, just the specific problem", which you
have already decided is an ulcer and cannot possibly be anything
other than an ulcer.

> When a function argument will end up making
> an argument to grep, and the argument to grep must have single quotes, but the single
> quotes typed in the function argument are stripped off. What's the solution? grep must
> have " $ grep 'file name'  " with intact quotes but zsh always strips them off.

grep does not need those arguments to have single quotes. It needs
them to remain a single word, which is related but not identical.

> There
> must be a solution.  Or perhaps I'm stuck with " $ grep 'file\ name' -- seems the single
> quotes preserve the backlash which in turn forces 'file name' to be a single word as
> wanted.  It's ok, but I wonder if there's a better way.  I thought the (q) flag might
> do it.  Memory tickles that I learned how to do this once.
> 
> Hey, just fiddling around with it right now and:
> 
> $ g ,H 'execute' "'g,46,w4 now default'" f
> ... double quote the single quotes and the single quotes remain. Logical too, outer
> quotes will be stripped, so just throw in another set.  Final grep is:
> 
> GREP_COLOR='01;33' grep --color=always -iFIHn -d skip -- 'execute' 'g,46,w4 now default' f
> ... all good.

It sure sounds like you're assembling a scalar and eval-ing it, but
who's to say. (q) works fine in this toy example.

	% () { eval "print -rC1 -- $@" } a 'b c' d 'e f g'
	a
	b
	c
	d
	e
	f
	g
	% () { eval "print -rC1 -- ${(q)@}" } a 'b c' d 'e f g'
	a
	b c
	d
	e f g

--
vq

  reply	other threads:[~2021-02-10  1:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 20:42 Ray Andrews
2021-02-09 21:05 ` Lawrence Velázquez
2021-02-09 21:08 ` Peter Stephenson
2021-02-09 23:45   ` Ray Andrews
2021-02-10  0:22     ` Lawrence Velázquez
2021-02-10  0:51       ` Ray Andrews
2021-02-10  1:46         ` Lawrence Velázquez [this message]
2021-02-10  2:25           ` Ray Andrews
2021-02-10  2:52             ` Lawrence Velázquez
2021-02-10  1:52         ` Greg Klanderman
2021-02-10  2:29           ` Ray Andrews
2021-02-10 15:18           ` Ray Andrews
2021-02-10 15:47             ` Peter Stephenson
2021-02-10 16:19               ` Ray Andrews
2021-02-10 16:29                 ` Peter Stephenson
2021-02-10 20:53                   ` Ray Andrews
2021-02-10 22:14                     ` Bart Schaefer
2021-02-11 16:31                       ` Ray Andrews
2021-02-11 17:19                         ` Lawrence Velázquez
2021-02-11 19:48                           ` Ray Andrews
2021-02-10 18:08                 ` Bart Schaefer
2021-02-10 20:56                   ` Ray Andrews
2021-02-10 16:28             ` Lawrence Velázquez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E154CC1-4B1F-4ADB-993F-89100A7F766A@larryv.me \
    --to=vq@larryv.me \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).