tap: avoid deep inspection of scripts by dropping file(1)'s `--keep-going` option

The --keep-going option of file(1) might trigger false positives like:

  % file -b --keep-going hooks/pre-commit
  POSIX shell script text executable\012- awk or perl script text\012- a /bin/sh script, ASCII text executable

while this is a shellscript where perl is used in a sub-process only.

It (kind of) works fine when using file's `-i' option:

  % file -b --keep-going -i hooks/pre-commit
  text/x-shellscript; charset=us-ascii

Sadly `-i` doesn't work for detecting perl scripts:

  % file helper/sync-db
  helper/sync-db: a /usr/bin/perl -CSD script, ASCII text executable
  % file -b --keep-going -i helper/sync-db
  text/plain; charset=us-ascii

So instead drop the deep inspection of files via `--keep-going`
to keep the behavior consistent across all tap scripts WRT
file(1) options, except for the missing `-i` option inside
perlcritic_tap.

Development sponsored by Sipwise GmbH, recorded as
TT#19714 in customers' ticket system.
remotes/origin/HEAD
Michael Prokop 9 years ago
parent c6c8c0246f
commit 5d02459e9a

@ -18,7 +18,7 @@ if not File.exists? file
end
# Make sure we're looking at sh code.
mimetype = `file -b -i --keep-going #{file}`.gsub(/\n/,"")
mimetype = `file -b -i #{file}`.gsub(/\n/,"")
if not /.*x-shellscript/i.match(mimetype)
$stderr.puts "File #{file} doesn't look like sh code [#{mimetype}]. Ignoring."
exit 0

@ -27,7 +27,7 @@ if not File.exists? file
end
# Make sure we're looking at Python code.
mimetype = `file -b -i --keep-going #{file}`.gsub(/\n/,"")
mimetype = `file -b -i #{file}`.gsub(/\n/,"")
if not /.*x-python/i.match(mimetype)
$stderr.puts "File #{file} doesn't look like Python [#{mimetype}]. Ignoring."
exit 0

@ -19,7 +19,7 @@ end
file = ARGV[0]
# make sure we're checking a perl script
mimetype = `file -b --keep-going #{file}`.gsub(/\n/,"")
mimetype = `file -b #{file}`.gsub(/\n/,"")
if not /.*perl/i.match(mimetype)
$stderr.puts "File #{file} doesn't look like perl [#{mimetype}]. Ignoring."
exit 0

@ -18,7 +18,7 @@ if not File.exists? file
end
# Make sure we're looking at sh code.
mimetype = `file -b -i --keep-going #{file}`.gsub(/\n/,"")
mimetype = `file -b -i #{file}`.gsub(/\n/,"")
if not /.*x-shellscript/i.match(mimetype)
$stderr.puts "File #{file} doesn't look like sh code [#{mimetype}]. Ignoring."
exit 0

Loading…
Cancel
Save