Whamcloud - gitweb
LU-14707 tests: Prefer #!/bin/bash 79/49479/4
authorTimothy Day <timday@amazon.com>
Thu, 15 Dec 2022 06:19:01 +0000 (06:19 +0000)
committerOleg Drokin <green@whamcloud.com>
Tue, 31 Jan 2023 02:34:34 +0000 (02:34 +0000)
Change remaining #!/bin/sh to use bash.
Add a warning to the git-hook about using
sh in shebangs. Using bash allows scripts to
freely use bash-isms and lowers the risks
of bugs on Debian based platforms.

Also, change remaining callers to use bash
rather than sh.

Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I10f3e8f71435c38cfc1650dd13168d7ed5d3b31f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49479
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
23 files changed:
LUSTRE-VERSION-GEN
autogen.sh
contrib/git-hooks/prepare-commit-msg
contrib/lbuild/lbuild
debian/dkms.conf.in
debian/lustre-client-modules-dkms.postinst
debian/lustre-client-modules-dkms.prerm
debian/postinst
debian/postrm
debian/rules
lnet/utils/lnetunload
lustre/BUILDING
lustre/conf/resource/Lustre
lustre/conf/resource/healthLNET
lustre/conf/resource/healthLUSTRE
lustre/scripts/dkms.mkconf
lustre/scripts/ko2iblnd-probe
lustre/scripts/lc_mon
lustre/scripts/lustre_req_history
lustre/tests/runiozone
lustre/tests/runobdstat
lustre/tests/runvmstat
lustre/tests/test-framework.sh

index 9d34753..fecef2e 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 DEFAULT_VERSION=2.15.53
 LVF=LUSTRE-VERSION-FILE
index f8b7741..40b05bf 100644 (file)
@@ -1,7 +1,4 @@
-#!/bin/sh
-
-# NOTE: Please avoid bashisms (bash specific syntax) in this script
-
+#!/bin/bash
 set -e
 pw="$PWD"
 for dir in libcfs lnet lustre snmp ; do
index 2178e9e..77caa69 100755 (executable)
@@ -54,6 +54,13 @@ if [[ -x "$SHELLCHECK" && "$SHELLCHECK_RUN" == "yes" ]]; then
        # Example End   --
        mod_files=($(awk '/modified:.*\.sh|new:.*\.sh/ { print $3 }' $1))
        for cur_file in ${mod_files[@]}; do
+               # Shebangs should prefer bash over regular sh. This allows
+               # scripts to freely use bash-isms and lowers the risks of
+               # failures on Debian based platforms. Output a small warning
+               # if #!/bin/sh is found.
+               echo "#" $(grep -Hn "#\!/bin/sh" "$cur_file" && \
+                       echo " : Please don't use sh in shebangs.") >> "$1"
+
                # Get start/end range of lines that needs to be reported
                # range presently not used will come in handy when dealing with
                # warnings reported by shellcheck
index f6a750f..a21d17b 100755 (executable)
@@ -1072,7 +1072,7 @@ build_spl_zfs() {
            speclist="$pkg.spec $pkg-kmod.spec $pkg-dkms.spec"
        fi
 
-       sh autogen.sh || return 255
+       bash autogen.sh || return 255
 
        if  ! ./configure --with-linux=${LINUX} --with-linux-obj=${LINUXOBJ:-$LINUX} \
            ${spldir:+--with-spl="${spldir}"} 2>&1 ||
index 6a8a1b6..2cd63b0 100644 (file)
@@ -8,7 +8,7 @@ PACKAGE_NAME="lustre-client-modules"
 PACKAGE_VERSION="@UPVERSION@"
 
 # We need to run autogen.sh between builds, see Ubuntu bug #952817
-MAKE="sh autogen.sh && ./configure --with-linux=$kernel_source_dir --with-linux-obj=$kernel_source_dir --disable-server --disable-quilt --disable-dependency-tracking --disable-doc --disable-utils --disable-iokit --disable-snmp --disable-tests --enable-quota --with-kmp-moddir=updates && make"
+MAKE="bash autogen.sh && ./configure --with-linux=$kernel_source_dir --with-linux-obj=$kernel_source_dir --disable-server --disable-quilt --disable-dependency-tracking --disable-doc --disable-utils --disable-iokit --disable-snmp --disable-tests --enable-quota --with-kmp-moddir=updates && make"
 CLEAN="make distclean || true"
 
 AUTOINSTALL="yes"
index a05e2a5..28f069e 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 DEPMOD_DIR="/etc/depmod.d"
 LUSTRE_DEPMOD_FILE="${DEPMOD_DIR}/lustre.conf"
index 2affdf0..476b60f 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 DEPMOD_DIR="/etc/depmod.d"
 LUSTRE_DEPMOD_FILE="${DEPMOD_DIR}/lustre.conf"
@@ -7,4 +7,4 @@ LUSTRE_DEPMOD_FILE="${DEPMOD_DIR}/lustre.conf"
 # If DEPMOD_DIR is empty, we also created it, thus remove it.
 [ ! "$(ls -A ${DEPMOD_DIR} 2>/dev/null)" ] && { rm -rf ${DEPMOD_DIR}; }
 
-depmod -a
\ No newline at end of file
+depmod -a
index 91db28f..377c042 100755 (executable)
@@ -130,7 +130,7 @@ autogen-stamp: patch-stamp
                cp /usr/share/misc/config.sub ldiskfs/config.sub; \
                cp /usr/share/misc/config.guess config.guess; \
                cp /usr/share/misc/config.guess ldiskfs/config.guess; \
-               sh build/autogen.sh; \
+               bash build/autogen.sh; \
        fi; \
        touch $@
 
index fdc64ba..b61f938 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 lnds=$(echo k{sock,qsw,{open,i,v,o2,c}ib,ra,ptl,mx}lnd)
 
index f652ca9..5bf0774 100644 (file)
@@ -7,7 +7,7 @@ web sites below.  Also consider downloading a pre-packaged Lustre
 kernel and utilities from https://downloads.whamcloud.com/
 
 To build:
-  sh autogen.sh
+  bash autogen.sh
   ./configure --with-linux=/usr/src/lustre_patched_kernel_tree
   make
 
index 91f15c4..6971a86 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # License:      GNU General Public License (GPL)v2
 # Description:  Manages Lustre server on a shared storage
index 8ebf587..8631478 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 #
 #      LNet OCF RA
index 4ca2e5e..a184892 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 #
 #      HealthLUSTRE OCF RA
index 2cd7cb5..ae481d1 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 PROG=$0
 
index 5d07886..7b7e1e2 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # flags of IB devices which present
 HFI=0
index ac4be84..f3f2fb9 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Given one or more Lustre objects, create a mon configuration file
 # naming the mon watches based on the Lustre object names 
@@ -136,4 +136,4 @@ do
 done
 
 echo "Mon config completed - new mon config is $TMPMONCFG"
-exit 0
\ No newline at end of file
+exit 0
index 0bbab70..e0d4681 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 
 # Purpose:
index b364abe..0403ab0 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 [ -z "$SIZE" ] && SIZE=5g
 [ -z "$COUNT" ] && COUNT=100
 [ -z "$VERIFY" ] && VERIFY="-+d"
index 7fd61ee..7f9b78d 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 PATH=`dirname $0`/../utils:$PATH
 
 llobdstat $1 1 | while read LINE; do
index 8a5a7df..4371d38 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 DELAY=1
 null() {
        :
index 7970291..64d7f3d 100755 (executable)
@@ -827,7 +827,7 @@ load_modules_local() {
                        [ ! -f "$sbin_mount" ] && touch "$sbin_mount"
                        if [ ! -s "$sbin_mount" -a -w "$sbin_mount" ]; then
                                cat <<- EOF > "$sbin_mount"
-                               #!/bin/sh
+                               #!/bin/bash
                                #STUB MARK
                                echo "This $sbin_mount just a mountpoint." 1>&2
                                echo "It is never supposed to be run." 1>&2