]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
script/run-cbt.sh: drop bashism 38515/head
authorKefu Chai <kchai@redhat.com>
Thu, 10 Dec 2020 03:13:55 +0000 (11:13 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 10 Dec 2020 03:25:54 +0000 (11:25 +0800)
* "local" is not supported by POSIX shell, so drop it
* assign "$*" to a non-array variable, see
  https://github.com/koalaman/shellcheck/wiki/SC2124
* fail early if "cd" fails, see
  https://github.com/koalaman/shellcheck/wiki/SC2164
* quote "$(...)" with quotes to avoid string split

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/script/run-cbt.sh

index f238cac7d1fb8f087325f4718ce14ca6b675ee12..116cc77f22f0eb982f7b9b10c67d2f163a410f40 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 usage() {
-    local prog_name=$1
+    prog_name=$1
     shift
     cat <<EOF
 usage:
@@ -86,13 +86,13 @@ fi
 # store absolute path before changing cwd
 source_dir=$(readlink -f $source_dir)
 if ! $use_existing; then
-    cd $build_dir
+    cd $build_dir || exit
     # seastar uses 128*8 aio in reactor for io and 10003 aio for events pooling
     # for each core, if it fails to enough aio context, the seastar application
     # bails out. and take other process into consideration, let's make it
     # 32768 per core
-    max_io=$(expr 32768 \* $(nproc))
-    if test $(/sbin/sysctl --values fs.aio-max-nr) -lt $max_io; then
+    max_io=$(expr 32768 \* "$(nproc)")
+    if test "$(/sbin/sysctl --values fs.aio-max-nr)" -lt $max_io; then
         sudo /sbin/sysctl -q -w fs.aio-max-nr=$max_io
     fi
     if $classical; then
@@ -105,7 +105,7 @@ if ! $use_existing; then
            --crimson --nodaemon --redirect-output \
            --osd-args "--memory 4G"
     fi
-    cd -
+    cd - || exit
 fi
 
 for config_file in $config_files; do
@@ -123,7 +123,7 @@ for config_file in $config_files; do
 done
 
 if ! $use_existing; then
-    cd $build_dir
+    cd $build_dir || exit
     if $classical; then
       $source_dir/src/stop.sh
     else