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

Re: is text file?



TGAPE! <tgape@xxxxxxxxxxxxx> writes:

> Greg Badros wrote:
> >
> > "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx> writes:
> >
[ NOTE: This is misattributed to Bart Scahefer, I wrote this ]
> > 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.

No then you simply add a built-in test to zsh that is true iff that
argument is a text file.  No extra exec-s, but still clean.

> 
> >> 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,

But you apparently can't even attribute text in emails properly.

The point isn't whether I could figure out such a line, it's whether
being able to throw together nonsensical characters correctly after 8
attempts proves anything.  Yes, zsh can [almost] do it, but it's way
easier to just use find or a cmd-line filter that removes arguments that
aren't text files.

Greg



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