Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[zsh] How to test whether a glob has any matches?

82 views
Skip to first unread message

kj

unread,
Jul 12, 2012, 10:53:59 AM7/12/12
to


I would like to do something, in essence, like this (zsh globs):

[[ -n .*~.git ]] && git add .*~.git

In words, the *intent* of the above is something like "if there
are in the current directory any dot-items (other than .git), then
add them to the git index."

Of course, the test above is basically nonsense; it certainly does
not do what is intended.

I thought that zsh offered a mechanism for performing this sort of
test, but I can't find it. Is my memory tricking me?

Thanks!

PS: One way to achieve the desired result would be something like

[[ -n $(echo .*~.git) ]] && git add .*~.git

Stephane Chazelas

unread,
Jul 12, 2012, 2:01:24 PM7/12/12
to
2012-07-12 14:53:59 +0000, kj:
files=(.*~.git)
(($#files)) && git add $files

--
Stephane

kj

unread,
Jul 17, 2012, 9:54:57 AM7/17/12
to
In <20120712180...@chaz.gmail.com> Stephane Chazelas <stephane...@gmail.com> writes:

>files=(.*~.git)
>(($#files)) && git add $files


Nice. Thanks!

0 new messages