diff options
| -rwxr-xr-x | sbolint | 31 | 
1 files changed, 30 insertions, 1 deletions
| @@ -235,6 +235,13 @@ that haven't been updated).  =item - +The script must exit with failure status if the build fails. Normally this +is done with B<set -e> somewhere near the top of the script. Also allowed +is B<#!/bin/bash -e> (or B<-ue, -eu, etc>) on the first line, or manual +checks with B<|| exit 1>. If none of these things are found, it's an error. + +=item - +  README must exist, have mode 0644, its character encoding must be  either ASCII or UTF-8 without BOM, and it may not contain tab characters. @@ -1334,9 +1341,13 @@ sub check_script {  	my @lines = check_and_read($file);  	return unless scalar @lines; +	my $bash_e_opt;  	if($lines[0] !~ /^#!/) {  		log_error("$file:1: missing or invalid shebang line (should be '#!/bin/bash')"); -	} elsif($lines[0] !~ m,#!/bin/bash(?: (?:-e|-eu|-ue|-e -u|-u -e))?$,) { +	} elsif($lines[0] =~ m,#!/bin/bash(?:\s+(-e|-eu|-ue|-e -u|-u -e))?\s*$,) { +		my $arg = $1; +		$bash_e_opt = 1 if defined($arg) && $arg =~ /e/; +	} else {  		log_warning("$file:1: shebang line should be #!/bin/bash (possibly with -e/-u arg(s)), not '$lines[0]'");  	} @@ -1345,6 +1356,7 @@ sub check_script {  	my ($cdpkg, $codestart, $lint_enabled, $print_pkg_name, $pkg_type, $arch_lineno);  	my ($old_arch, $old_flags, $have_py2, $have_py3);  	my ($libsuf_set, $flags_set, $libsuf_used, $flags_used); +	my ($set_e, $or_exit_1);  	$lint_enabled = 1;  	for(@lines) { @@ -1516,6 +1528,15 @@ sub check_script {  		if(/^[^#]*\$\{?SLKCFLAGS/) {  			$flags_used = $lineno;  		} + +		if(/^[^#]*set\s+([^#]+)/) { +			my $arg = $1; +			$set_e = $lineno if $arg =~ /e/; +		} + +		if(/^[^#]*\|\|\s+exit\s+1/) { +			$or_exit_1 = $lineno; +		}  	}  	if(not defined($prgnam)) { @@ -1620,6 +1641,14 @@ sub check_script {  	if($libsuf_set && (!$libsuf_used)) {  		log_note("$file:$libsuf_set: LIBDIRSUFFIX gets set, but never used.");  	} + +	## warn "\$set_e: " . ($set_e || 0); +	## warn "\$bash_e_opt: " . ($bash_e_opt || 0); +	## warn "\$or_exit_1: " . ($or_exit_1 || 0); + +	if(!(defined $set_e || defined $bash_e_opt || defined $or_exit_1)) { +		log_error("$file: this script has no error checking (need bash -e option, 'set -e', or '|| exit 1')."); +	}  }  sub check_doinst { | 
