summaryrefslogtreecommitdiff
path: root/jenkins-helpers.sh
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2020-05-01 15:38:17 +0100
committerDavid Spickett <david.spickett@linaro.org>2020-05-05 12:11:32 +0000
commit9c23692ad251743e1bdcce142b43bc6d4b2e333f (patch)
tree5d145b34ff2cc24d0a824216a462e022ee3e4189 /jenkins-helpers.sh
parente5712005c171f9813cb02f9014f8feb850893c2c (diff)
jenkins-helpers.sh: Add pwd check function
Used in other scripts to check that pwd isnt / before deleting things. Change-Id: Id3e284a486f300c97e92f730e84183340c999dd9
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r--jenkins-helpers.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh
index 97295651..a11d264a 100644
--- a/jenkins-helpers.sh
+++ b/jenkins-helpers.sh
@@ -1,5 +1,17 @@
#!/bin/bash
+sanity_check_pwd ()
+{
+ (
+ set -euf -o pipefail
+
+ if [[ $(pwd) == "/" ]]; then
+ echo "pwd is unexpectedly \"/\", exiting"
+ exit 1;
+ fi
+ )
+}
+
# Print absolute path to a file or directory
# $1: Path (must exist)
abs_path ()