Browse Source

checkbashism_tap: ignore non-shell-script files

tags/v0.11.0
Christian Hofstaedtler 7 years ago
parent
commit
73593abb71
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      tap/checkbashism_tap

+ 8
- 0
tap/checkbashism_tap View File

@@ -17,6 +17,14 @@ if not File.exists? file
exit 1
end

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


output = %x{checkbashisms --posix #{file} 2>&1}

num_lines = output.lines.count / 2 # checkbasims has one line message and one line code


Loading…
Cancel
Save