From 5c7f2675e8ddac63e603080d2ded796b8d4bbed3 Mon Sep 17 00:00:00 2001
From: Michal Hrusecky <Michal@Hrusecky.net>
Date: Mon, 29 Jan 2018 14:00:33 +0100
Subject: [PATCH] Check working directory

Make sure we are not being run from the checkout directory.

Signed-off-by: Michal Hrusecky <Michal@Hrusecky.net>
---
 compile_fw | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/compile_fw b/compile_fw
index 02261c75a..b6a6a456d 100755
--- a/compile_fw
+++ b/compile_fw
@@ -49,7 +49,13 @@ _die() {
 	exit 1
 }
 
+if [ "$BUILD_DIR" == "$SRCDIR" ]; then
+	_die "You should run this script from build directory\nIt will delete content of current working directory!"
+fi
+
 _get_version() {
+	# If first grep fails - version is not first non-empty, add 999 to the end
+	# Be aware that Condition in if also outputs the results
 	if ! grep . "${SRC_DIR}"/NEWS | head -n 1 | grep '^[0-9.]\+$'; then
 		echo "$(grep '^[0-9.]\+$' "${SRC_DIR}"/NEWS | head -n 1).999"
 	fi
-- 
GitLab