fab351
From e3b2b02c7f5b4e9f1d2a3cfe8749534959e29e3e Mon Sep 17 00:00:00 2001
fab351
From: Lubomir Rintel <lkundrak@v3.sk>
fab351
Date: Fri, 21 Jun 2019 18:39:48 +0200
fab351
Subject: [PATCH] fs-lib: drop a bashism
6b5521
fab351
Bash 5 apparently longer propagates variable assignments to local variables
fab351
in front of function calls when in POSIX mode:
6b5521
fab351
  [lkundrak@demiurge ~]$ cat feh.sh
fab351
  print_VAR () {
fab351
          echo "$VAR";
fab351
  }
6b5521
fab351
  testfunc () {
fab351
          local VAR="OLD"
fab351
          VAR=NEW print_VAR
fab351
  }
fab351
fab351
  testfunc
fab351
  [lkundrak@demiurge ~]$ bash4 --posix feh.sh
fab351
  NEW
fab351
  [lkundrak@demiurge ~]$ bash5 --posix feh.sh
fab351
  OLD
fab351
  [lkundrak@demiurge ~]$ bash5 feh.sh
fab351
  NEW
fab351
  [lkundrak@demiurge ~]$
fab351
fab351
It works the way it did in Bash 4 in non-POSIX mode, for external programs,
fab351
or for non-local variables. Don't ask me why -- it's probably some
fab351
compatibility thing for some sad old people.
fab351
fab351
However, this precisely happens when fsck_single() is calling into the
fab351
fsck_drv_com(), assigned to _drv by fsck_able(). That ruins the
fab351
TEST-70-BONDBRIDGETEAMVLAN test's server and probably more.
fab351
fab351
Let's pass the fsck driver binary via the function argument instead. It's
fab351
less messy anyway.
fab351
fab351
(cherry picked from commit 43c8c4ce0471abbb8c0fc4b8be2515cebc636030)
6b5521
---
fab351
 modules.d/99fs-lib/fs-lib.sh | 13 +++++++------
fab351
 1 file changed, 7 insertions(+), 6 deletions(-)
fab351
fab351
diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh
fab351
index d39ca1b7..11e795d9 100755
fab351
--- a/modules.d/99fs-lib/fs-lib.sh
fab351
+++ b/modules.d/99fs-lib/fs-lib.sh
fab351
@@ -44,22 +44,22 @@ fsck_able() {
fab351
             ;;
fab351
         ext?)
fab351
             type e2fsck >/dev/null 2>&1 &&
fab351
-            _drv="_drv=e2fsck fsck_drv_com" &&
fab351
+            _drv="fsck_drv_com e2fsck" &&
fab351
             return 0
fab351
             ;;
fab351
         f2fs)
fab351
 	    type fsck.f2fs >/dev/null 2>&1 &&
fab351
-	    _drv="_drv=fsck.f2fs fsck_drv_com" &&
fab351
+	    _drv="fsck_drv_com fsck.f2fs" &&
fab351
 	    return 0
fab351
 	    ;;
fab351
         jfs)
fab351
             type jfs_fsck >/dev/null 2>&1 &&
fab351
-            _drv="_drv=jfs_fsck fsck_drv_com" &&
fab351
+            _drv="fsck_drv_com jfs_fsck" &&
fab351
             return 0
fab351
             ;;
fab351
         reiserfs)
fab351
             type reiserfsck >/dev/null 2>&1 &&
fab351
-            _drv="_drv=reiserfsck fsck_drv_com" &&
fab351
+            _drv="fsck_drv_com reiserfsck" &&
fab351
             return 0
fab351
             ;;
fab351
         btrfs)
fab351
@@ -70,12 +70,12 @@ fsck_able() {
fab351
             ;;
fab351
         nfs*)
fab351
             # nfs can be a nop, returning success
fab351
-            _drv="_drv=none :" &&
fab351
+            _drv=":" &&
fab351
             return 0
fab351
             ;;
fab351
         *)
fab351
             type fsck >/dev/null 2>&1 &&
fab351
-            _drv="_drv=fsck fsck_drv_std" &&
fab351
+            _drv="fsck_drv_std fsck" &&
fab351
             return 0
fab351
             ;;
fab351
     esac
fab351
@@ -97,6 +97,7 @@ fsck_drv_btrfs() {
6b5521
 
fab351
 # common code for checkers that follow usual subset of options and return codes
fab351
 fsck_drv_com() {
fab351
+    local _drv="$1"
fab351
     local _ret
fab351
     local _out
6b5521
 
6b5521