summaryrefslogtreecommitdiffstats
path: root/src/pmdk/utils/check-shebang.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/pmdk/utils/check-shebang.sh
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pmdk/utils/check-shebang.sh')
-rwxr-xr-xsrc/pmdk/utils/check-shebang.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pmdk/utils/check-shebang.sh b/src/pmdk/utils/check-shebang.sh
new file mode 100755
index 000000000..1051d178b
--- /dev/null
+++ b/src/pmdk/utils/check-shebang.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2017-2019, Intel Corporation
+#
+# utils/check-shebang.sh -- interpreter directive check script
+#
+set -e
+
+err_count=0
+
+for file in $@ ; do
+ [ ! -f $file ] && continue
+ SHEBANG=`head -n1 $file | cut -d" " -f1`
+ [ "${SHEBANG:0:2}" != "#!" ] && continue
+ if [ "$SHEBANG" != "#!/usr/bin/env" -a $SHEBANG != "#!/bin/sh" ]; then
+ INTERP=`echo $SHEBANG | rev | cut -d"/" -f1 | rev`
+ echo "$file:1: error: invalid interpreter directive:" >&2
+ echo " (is: \"$SHEBANG\", should be: \"#!/usr/bin/env $INTERP\")" >&2
+ ((err_count+=1))
+ fi
+done
+
+if [ "$err_count" == "0" ]; then
+ echo "Interpreter directives are OK."
+else
+ echo "Found $err_count errors in interpreter directives!" >&2
+ err_count=1
+fi
+
+exit $err_count