From 5d02459e9a1a9119812380cb5779bbb59063c651 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 2 Aug 2017 15:57:26 +0200 Subject: [PATCH] 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. --- tap/checkbashism_tap | 2 +- tap/pep8_tap | 2 +- tap/perlcritic_tap | 2 +- tap/shellcheck_tap | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tap/checkbashism_tap b/tap/checkbashism_tap index 04aaac8..ae50782 100755 --- a/tap/checkbashism_tap +++ b/tap/checkbashism_tap @@ -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 diff --git a/tap/pep8_tap b/tap/pep8_tap index d6a192f..919b87a 100755 --- a/tap/pep8_tap +++ b/tap/pep8_tap @@ -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 diff --git a/tap/perlcritic_tap b/tap/perlcritic_tap index f62f0c2..a572c1f 100755 --- a/tap/perlcritic_tap +++ b/tap/perlcritic_tap @@ -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 diff --git a/tap/shellcheck_tap b/tap/shellcheck_tap index e50f31a..07d4d09 100755 --- a/tap/shellcheck_tap +++ b/tap/shellcheck_tap @@ -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