From: Zach Riggle <zachriggle@gmail.com>
To: "Lawrence Velázquez" <larryv@zsh.org>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Setting GLOB_DOTS for a single command
Date: Tue, 23 Nov 2021 20:20:00 -0600 [thread overview]
Message-ID: <CAMP9c5=KK71OJ3NfDPv22f3UkcYLV=pBQBqxuRhvJvM2ZzutTQ@mail.gmail.com> (raw)
In-Reply-To: <719906ad-5f27-4eaf-ba34-f559ebcad523@www.fastmail.com>
[-- Attachment #1: Type: text/plain, Size: 2502 bytes --]
Indeed, it does appear that the D modifier does what I want!
Thanks Alex, Bart, and Lawrence.
*Zach Riggle*
On Sat, Nov 20, 2021 at 11:28 PM Lawrence Velázquez <larryv@zsh.org> wrote:
> On Sat, Nov 20, 2021, at 11:46 PM, Zach Riggle wrote:
> > I recently learned about GLOB_DOTS, which is pretty useful in some
> > scenarios, e.g.
> >
> >> echo *(md-1)
> >
> > To show all files modified within the last day. However, in some cases
> > I want to see hidden files (e.g. ./.foo) as well. The globdots option
> > is excellent for this!
> >
> > Is there an easy way to set this for a single expression?
>
> Yes, the "D" glob qualifier.
>
> % touch {.,}{a..c}
> % print -r -- *
> a b c
> % print -r -- *(D)
> .a .b .c a b c
>
> > I know I can use a function / anonymous function combined with
> > LOCAL_OPTIONS to get this, but I wondered if there's something more
> > clever.
> >
> > [...]
> >
> > I expect that there's something I can do for scripts that I fully
> > control, to declare some function ('globdots') which is invoked with
> > noglob, and can then internally set the flag, and then trigger
> > expansion of each argument in "$@".
> >
> > [...]
> >
> > I can just invoke "eval" on something that I KNOW will be a glob
> > expression to get it to expand, but blindly calling eval will execute
> > things that are NOT glob expressions, and I only want filename
> > expansion.
> >
> > What I have found that DOES work (but overkill and a hack) is just to
> > shell out to zsh again, while passing in all options that are currently
> > set -- plus globdots.
> >
> > [...]
> >
> > Then there's also the issue of causing filename expansion to occur when
> > unintended -- for example, if '*' is indeed just a string argument, and
> > should not be subject to expansion. I think this corner case I can
> > ignore, as any user will explicitly be asking for glob expansion.
>
> What verve! Fortunately you don't have to do any of this :)
>
> > Finally, I wanted to say that I genuinely appreciate the help and
> > answers I've gotten from this community. You're all very welcoming,
> > experienced, and get down to the point / answers quickly.
>
> On behalf of the actual helpful people, you're quite welcome.
>
> > If there's any way that I can help support Zsh development or the
> > community around it, please let me know.
>
> I think your using zsh is already quite supportive!
>
> --
> vq
>
[-- Attachment #2: Type: text/html, Size: 3361 bytes --]
next prev parent reply other threads:[~2021-11-24 2:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-21 4:46 Zach Riggle
2021-11-21 5:11 ` FW: " agkozak
2021-11-21 5:20 ` Bart Schaefer
2021-11-21 5:28 ` Lawrence Velázquez
2021-11-24 2:20 ` Zach Riggle [this message]
2021-11-21 5:36 ` Bart Schaefer
2021-11-21 5:38 ` Bart Schaefer
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='CAMP9c5=KK71OJ3NfDPv22f3UkcYLV=pBQBqxuRhvJvM2ZzutTQ@mail.gmail.com' \
--to=zachriggle@gmail.com \
--cc=larryv@zsh.org \
--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).