Reputation: 672
I have checked out a project, the project contains a .gitignore
file.
The contents of this file are like so
vx1% head .gitignore
./deps
/*.exe
/*.la
/.auto
.libs
ChangeLog
Makefile
Makefile.in
aclocal.m4
autom4te.cache
The reason for wanting to do this - is that I don't trust the project Makefile to fully clean up it's generated files.
As you can see, the .gitignore uses some globs that I need to modify before running the commands, otherwise the glob will resolve to my root directory.
DYN="*.c"
print $~DYN
DYN="/*.c"
print ${~DYN/#//}
cat .gitignore | while read i; do echo $i ; print ${~i/#//} ; done
The first glob failure that this loop encounters, it terminates with error
zsh: no matches found: *.exe
The 'script' should keep going through each line of the file, trying each line in turn.
Upvotes: 6
Views: 1342
Reputation: 672
Found the answer on the zsh mailing list, in typical Zsh fashion - it's very simple when you know how, and impossible otherwise.
print *.nosuchextension(N)
The (N) glob parameter prevents raising an error on match failure.
Upvotes: 18