zsh-users
 help / color / mirror / code / Atom feed
From: "Jesper Nygårds" <jesper.nygards@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Some problems with recursive globbing
Date: Fri, 8 May 2015 05:37:59 +0200	[thread overview]
Message-ID: <CABZhJg9h6_ZefdUzOF2r7rBjo8xz9NZ4x6bYf-GVZ5KJBs2=sA@mail.gmail.com> (raw)
In-Reply-To: <CABZhJg8xzCNeTNRks2HV8AXTe_Vj9Sf=N3wrOg--kG+uwZWuwg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]

I found a solution to my particular problem. I can quote the dir, and then
remove the quoting of the spaces afterwards.

myfiles() {
    emulate -L zsh
    setopt LOCAL_OPTIONS EXTENDED_GLOB

    local dir="${(q)1:a}/"

    dir=${dir/\\\ / }

    local filepattern="${dir}**/*"

    print -c ${~filepattern}
}

I realize this could brake on even more exotic file names, but for now I'm
happy with this solution.


On Thu, May 7, 2015 at 7:21 PM, Jesper Nygårds <jesper.nygards@gmail.com>
wrote:

> On Thu, May 7, 2015 at 7:00 PM, Peter Stephenson <p.stephenson@samsung.com
> > wrote:
>
>> $dir contains a straight string with unquoted parentheses.  The
>> ~filepattern then turns those parentheses into pattern characters.
>>
>> Yes, I understand.
>
>
>> I'm not sure why you want filepattern anyway, but
>>
>> I tried to simplify my function to make my problem obvious. In my "real"
> function, I am collecting several function arguments into a combined
> pattern, which is why I need to use this indirect method.
>
> local filepattern="**/*"
>
>> print -c ${dir}${~filepattern}
>>
>> ought to work.  Otherwise you'll need to quote metacharacters in dir,
>> which is possible but should be unnecessary.
>>
>
> Yes, but as my second example demonstrates: if I quote my filepattern, it
> then doesn't work for files with spaces in their names. I was hoping for a
> solution where it would be possible to get this to work for both situations.
>
>
>

  reply	other threads:[~2015-05-08  3:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-07 14:35 Jesper Nygårds
2015-05-07 15:52 ` Peter Stephenson
2015-05-07 15:59   ` Peter Stephenson
2015-05-07 16:46     ` Jesper Nygårds
2015-05-07 17:00       ` Peter Stephenson
2015-05-07 17:21         ` Jesper Nygårds
2015-05-08  3:37           ` Jesper Nygårds [this message]
2015-05-08  8:40             ` Peter Stephenson
2015-05-08 10:34               ` Jesper Nygårds

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='CABZhJg9h6_ZefdUzOF2r7rBjo8xz9NZ4x6bYf-GVZ5KJBs2=sA@mail.gmail.com' \
    --to=jesper.nygards@gmail.com \
    --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).