#!/bin/bash
go_packages=.

candidates=`go list -f '{{.Dir}}/*.go' $go_packages`
for f in $candidates; do
	filename=`basename $f`
	# skip exit.go where, the only file we should call os.Exit() from.
	[[ $filename == "exit.go" ]] && continue
	# skip *_test.go
	[[ $filename == *"_test.go" ]] && continue
	files="$f $files"
done

grep -n os.Exit $files && {
	echo 'Direct calls to os.Exit() are forbidden, please use exit.Exit() so exit.Atexit() works'
	exit 1
}

Add a check that checks there's no direct os.Exit calls
scripts: Add a check that checks there's no direct os.Exit calls

Signed-off-by: Damien Lespiau <64bd3cb94f359c1a3ce68dae5e26b40578526277@intel.com>
