diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/pmdk/utils/check-shebang.sh | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pmdk/utils/check-shebang.sh')
-rwxr-xr-x | src/pmdk/utils/check-shebang.sh | 30 |
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 |