]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Avoid ShellCheck warning SC2164
authorMartin Schwenke <martin@meltin.net>
Fri, 10 Jun 2022 00:11:27 +0000 (10:11 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 22 Jul 2022 06:38:32 +0000 (06:38 +0000)
SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

A problem can only occur if /etc/ctdb/ or an important subdirectory is
removed, which means the script itself would not be found.  Use && to
silence ShellCheck.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
23 files changed:
ctdb/config/ctdb-crash-cleanup.sh
ctdb/config/debug-hung-script.sh
ctdb/config/debug_locks.sh
ctdb/config/events/legacy/00.ctdb.script
ctdb/config/events/legacy/01.reclock.script
ctdb/config/events/legacy/05.system.script
ctdb/config/events/legacy/06.nfs.script
ctdb/config/events/legacy/10.interface.script
ctdb/config/events/legacy/11.natgw.script
ctdb/config/events/legacy/11.routing.script
ctdb/config/events/legacy/13.per_ip_routing.script
ctdb/config/events/legacy/20.multipathd.script
ctdb/config/events/legacy/31.clamd.script
ctdb/config/events/legacy/40.vsftpd.script
ctdb/config/events/legacy/41.httpd.script
ctdb/config/events/legacy/48.netbios.script
ctdb/config/events/legacy/49.winbind.script
ctdb/config/events/legacy/50.samba.script
ctdb/config/events/legacy/60.nfs.script
ctdb/config/events/legacy/70.iscsi.script
ctdb/config/events/legacy/91.lvs.script
ctdb/config/statd-callout
ctdb/tests/UNIT/shellcheck/scripts/local.sh

index 896a90cda982baf32f70f5d9f7e3a63586424749..95cfd75981fd48caf8faea747baa7cf306be18ae 100755 (executable)
@@ -5,7 +5,7 @@
 #
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; echo "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && echo "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 03d5ea2f6a0d202ed63e10f81c4280dd8152c94a..c1ac0f1e1ad67961d839156f77f11201018a2519 100755 (executable)
@@ -4,7 +4,7 @@
 # for other operating systems.
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; echo "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && echo "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index b2e20250f5ac8b8e6862458d30312ce123457708..6c730ee18023cf947ba5d013d54b6f2b81cec15f 100755 (executable)
@@ -22,7 +22,7 @@
 #   accompanying patch.
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; echo "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && echo "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index b1c9890e7512dc3b94ca80a122bdb86f5fa6a02f..81c16af08a01c3e5f0b4855bf434c1a31735113b 100755 (executable)
@@ -4,7 +4,7 @@
 # elsewhere.
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index ab0f2f6a32b8e9cf58162f9ef232090d022e44ee..04068750efaa4d573c9ac843d30614f2fb74a13b 100755 (executable)
@@ -2,7 +2,7 @@
 # script to check accessibility to the reclock file on a node
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 08e401a9e730a2eda55ac1e1253dfa6499d2fff2..56920f74f38fab491274e2ac623f459c488970ba 100755 (executable)
@@ -2,7 +2,7 @@
 # ctdb event script for checking local file system utilization
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 97086f78ed00b50c99ff372eca0e8fe0cc029cfb..b937d4332549585693736ef25c1911d54a069c6f 100755 (executable)
@@ -2,7 +2,7 @@
 # script to manage nfs in a clustered environment
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 8db6b5f42feb3d36a1c81b4997b113fca84ff47d..7dfacd317d65d4b39ff7ae6bab5452b07eb6e334 100755 (executable)
@@ -6,7 +6,7 @@
 # public interface
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index b02ff7a6bf4c57f66a10584f186f71710b8985ff..fb93dea6d5eaed66b2ebcaed14048ab585e44ee7 100755 (executable)
@@ -6,7 +6,7 @@
 #
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 3a526e1ed47e95fb4e22bcdca0fce78b519f4ff3..7ba7f3bf4a8a07d9f292f3f05e5ee463eaa3f4f8 100755 (executable)
@@ -18,7 +18,7 @@
 # bond1 10.3.3.0/24 10.0.0.1
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index ed5677327a183c7b5e462b7cf5d9aebeeed8fb9c..e25647613bbc38074417a52a0606c777590502fa 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index ed6d5523a87ad9f122bfecdff599f0ca0d38f63a..a420251d92ca2e98ce2eb99c341e6d55ef69f8af 100755 (executable)
@@ -7,7 +7,7 @@
 #
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 3b19923cc1b28d796b2b318ea14286068dead31c..5d60fe3aa375ea5afb3a9a50715075f312493af8 100755 (executable)
@@ -2,7 +2,7 @@
 # event script to manage clamd in a cluster environment
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 69876d26dacb4a2205e3376ce88275e41fdd7edd..19d40071ce25305e39202b83c691d9cf227ec059 100755 (executable)
@@ -2,7 +2,7 @@
 # event strict to manage vsftpd in a cluster environment
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 3d67aee90285eec0108a977476ba77752223cd45..dd90aeda274b95bebbf4cd4acb00fb264341f928 100755 (executable)
@@ -2,7 +2,7 @@
 # event script to manage httpd in a cluster environment
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index d2cbf983b6a70801293b9a20ed2677c79480f6b7..43204476d6b258800c227c34b0faff95568e6ce0 100755 (executable)
@@ -2,7 +2,7 @@
 # ctdb event script for Netbios Name Services
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 8b1c8b853c0caea7e3dc43fd484f45f8158eb4cf..852b54165cff2b140fb0d0bc340e7d754a4c81a3 100755 (executable)
@@ -2,7 +2,7 @@
 # ctdb event script for winbind
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index b0e2fff1e0964b35eabc98d54996a68d2bb7f952..81c6e7fa6ba01318a9f9a40942d5f6a79c938a1d 100755 (executable)
@@ -2,7 +2,7 @@
 # ctdb event script for Samba
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 1b87b3d27e31f018fe652eb609bc1a900ce2ac14..8e496f73cc5a0ec32bc7de2028b30661e00d9d6b 100755 (executable)
@@ -2,7 +2,7 @@
 # script to manage nfs in a clustered environment
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 0828d473b7a9ddb053c627cf7dc7361a14e2ac3a..e74651d8eb1b51daedfa88f99b00a5009e2e68f0 100755 (executable)
@@ -3,7 +3,7 @@
 # CTDB event script for TGTD based iSCSI
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 05f0431b66139c9dff8b365507d2b80fecba2b19..885506873a0b3c0cd3acec015e57a232a628a922 100755 (executable)
@@ -2,7 +2,7 @@
 # script to manage the lvs ip multiplexer for a single public address cluster
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index 67ed2a5bc62154490fdb05acf36e95c39aeee40d..83fb92eccf006ac979176d15ef51b7f5767d0ed4 100755 (executable)
@@ -17,7 +17,7 @@
 #     ha-callout = /etc/ctdb/statd-callout
 
 [ -n "$CTDB_BASE" ] || \
-    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; echo "$PWD")
+       CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && echo "$PWD")
 
 . "${CTDB_BASE}/functions"
 
index a842fd4ae51ded677cc588b6ec13f4ad66dec102..07e72c359c25f9e073d858851a6bf9763eb80a7a 100644 (file)
@@ -25,10 +25,7 @@ shellcheck_test ()
                # SC2162: read without -r will mangle backslashes.
                #         - We never read things with backslashes,
                #           unnecessary churn.
-               # SC2164: Use cd ... || exit in case cd fails.
-               #         - Most hits are on known directories.  Too
-               #           much churn, maybe later.
-               _excludes="SC1090,SC1091,SC2162,SC2164"
+               _excludes="SC1090,SC1091,SC2162"
                unit_test shellcheck --exclude="$_excludes" "$@"
        else
                ctdb_test_skip "shellcheck not installed"