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