Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: is text file?

Greg Badros wrote:
> "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx> writes:
> Perhaps it would seem less hacky if there were a general
> user-programmable glob feature that would call a function on each
> filename and accept that file for the glob iff the function returns
> 0.  Then the way that you determine what kind of file a filename points
> to is not part of the shell, but the nice glob modifier interface is
> permitted. 

It thusly degenerates to the case of running a find operation which execs
file on all of your files, and greps out binaries & data.  Nothing really
gained, execept baggage.

>> An approximation might be (with extendedglob set):
>> % ls **/*~*(${~${(j/|/)fignore}})(.)
>> That is, all plain files that do not have extensions listed in `fignore'.
>> You could change (.) to (.^*) to omit executables, but that would also
>> omit most shell scripts.
>> (Somebody tell me why the extra ${~...} is needed in that expression.)
> I'm fairly certain I'll never type such an incantation (how long did it
> take to dream it up? :-) ).

Leave wizard's school now.  You don't have the potential.  That
incantation is trivial compared to somethings I've done.  Remember,
everything can be done as a perl one-liner.  This can be translated into
a zsh command line.  There's an emacs minor editting mode which already
does it, however.


(well, everything except testing links, rather than what they point to.
Or am I missing something?  Please tell me I am; I've a tchell script
I don't want to admit to owning.  Overly-complicated programs should
never be written in csh-family shells.)

Messages sorted by: Reverse Date, Date, Thread, Author