* Exclusion on filename expansion
@ 2014-12-07 18:50 ` Vin Shelton
2014-12-07 19:01 ` Peter Stephenson
2014-12-07 19:02 ` Bart Schaefer
0 siblings, 2 replies; 4+ messages in thread
From: Vin Shelton @ 2014-12-07 18:50 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 406 bytes --]
Using a variable, I cannot get ~ exclusion to work:
setopt extended_glob
mkdir foo
cd foo
touch abc def ghi jkl
ls *~abc~def
==> ghi jkl
pat="abc~def"
ls -d *~$pat
==> abc def ghi jkl
I think that expansion of $pat is happening after globbing, so in this case
"*" expands to
abc def ghi jkl
without the application of the tilde exclusion.
Is there something I can do about this?
Thanks,
Vin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Exclusion on filename expansion
2014-12-07 18:50 ` Exclusion on filename expansion Vin Shelton
@ 2014-12-07 19:01 ` Peter Stephenson
2014-12-07 19:17 ` Vin Shelton
2014-12-07 19:02 ` Bart Schaefer
1 sibling, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2014-12-07 19:01 UTC (permalink / raw)
To: zsh-users
Vin Shelton wrote:
> Using a variable, I cannot get ~ exclusion to work:
>
> ls *~abc~def
> ==> ghi jkl
> pat="abc~def"
> ls -d *~$pat
> ==> abc def ghi jkl
>
> I think that expansion of $pat is happening after globbing, so in this case
> "*" expands to
>
> abc def ghi jkl
>
> without the application of the tilde exclusion.
>
> Is there something I can do about this?
"setopt glob_subst", or probably better use $~pat which turns on
glob_subst for that expansion. The "~" may appear to be an obvious
mnemonic, but actually it was originally introduced to do the more
standard form of ~-expansion. It now turns on that and glob expansion.
pws
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Exclusion on filename expansion
2014-12-07 18:50 ` Exclusion on filename expansion Vin Shelton
2014-12-07 19:01 ` Peter Stephenson
@ 2014-12-07 19:02 ` Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2014-12-07 19:02 UTC (permalink / raw)
To: zsh-users
On Dec 7, 1:50pm, Vin Shelton wrote:
}
} pat="abc~def"
} ls -d *~$pat
} ==> abc def ghi jkl
}
} I think that expansion of $pat is happening after globbing
No, but the expansion of $pat is not a pattern unless you make it one.
ls -d *~${~pat}
(the braces are optional in zsh default emulation, used here for clarity).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Exclusion on filename expansion
2014-12-07 19:01 ` Peter Stephenson
@ 2014-12-07 19:17 ` Vin Shelton
0 siblings, 0 replies; 4+ messages in thread
From: Vin Shelton @ 2014-12-07 19:17 UTC (permalink / raw)
To: Peter Stephenson; +Cc: zsh-users
[-- Attachment #1: Type: text/plain, Size: 830 bytes --]
Thank you, Peter and Bart.
- Vin
On Sun, Dec 7, 2014 at 2:01 PM, Peter Stephenson <
p.w.stephenson@ntlworld.com> wrote:
> Vin Shelton wrote:
> > Using a variable, I cannot get ~ exclusion to work:
> >
> > ls *~abc~def
> > ==> ghi jkl
> > pat="abc~def"
> > ls -d *~$pat
> > ==> abc def ghi jkl
> >
> > I think that expansion of $pat is happening after globbing, so in this
> case
> > "*" expands to
> >
> > abc def ghi jkl
> >
> > without the application of the tilde exclusion.
> >
> > Is there something I can do about this?
>
> "setopt glob_subst", or probably better use $~pat which turns on
> glob_subst for that expansion. The "~" may appear to be an obvious
> mnemonic, but actually it was originally introduced to do the more
> standard form of ~-expansion. It now turns on that and glob expansion.
>
> pws
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-07 19:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <acs@alumni.princeton.edu>
2014-12-07 18:50 ` Exclusion on filename expansion Vin Shelton
2014-12-07 19:01 ` Peter Stephenson
2014-12-07 19:17 ` Vin Shelton
2014-12-07 19:02 ` 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).