* Paul Wise <[email protected]>, 2015-09-02, 18:14:
Right now the checks for the various scripting languages only match specific filename extensions, 'sh' check only matches *.sh, 'python' *.py, 'perl' *.{pl,pm}, etc. It would be good to scan all files for a #! line and check those too.

This is on the TODO list. The plan is to use MIME types stuff but I haven't been able to find a good way to do that on the command-line, if you can think of a method for this, that would be nice.

For source code, we might use ack(1). For example, this prints names of Python code:

ack -f --python --print0

... except that ack, unlike find, doesn't prefix filenames with "./". To avoid argument injections, we'd have to add it manually:

ack -f --python --print0 | perl -0pe 's,\A,./,'

... which looks less attractive. :\


For binary files, I came up with this monster:

find . -type f -exec sh -c 'file -i --print0 "$1" | cut -d "" -f 2 | grep -q ": image/png;" && 
printf "%s\0" "$1"' sh {} \;

It's horrible enough that I'll probably write a new tool, so that you can write:

find . -type f -print0 | mimegrep -0 image/png

--
Jakub Wilk

Reply via email to