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