Fix boilerplate for sh to allow alt shebangs

This commit is contained in:
Tim Hockin 2015-06-29 13:15:12 -07:00
parent ceaddc0c44
commit 38bddc2a97
2 changed files with 8 additions and 3 deletions

View File

@ -33,11 +33,16 @@ def file_passes(filename, extension, ref, regexs):
data = f.read()
# remove build tags from the top of Go file
# remove build tags from the top of Go files
if extension == "go":
p = regexs["go_build_constraints"]
(data, found) = p.subn("", data, 1)
# remove shebang from the top of shell files
if extension == "sh":
p = regexs["shebang"]
(data, found) = p.subn("", data, 1)
data = data.splitlines()
# if our test file is smaller than the reference it surely fails!
@ -91,6 +96,8 @@ def main():
regexs["date"] = re.compile( '(2014|2015)' )
# strip // +build \n\n build constraints
regexs["go_build_constraints"] = re.compile(r"^(// \+build.*\n)+\n", re.MULTILINE)
# strip #!.* from shell scripts
regexs["shebang"] = re.compile(r"^(#!.*\n)\n*", re.MULTILINE)
for filename in filenames:
if not file_passes(filename, extension, ref, regexs):

View File

@ -1,5 +1,3 @@
#!/bin/bash
# Copyright YEAR The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");