From: TerraTech Date: Tue, 4 Dec 2018 17:57:29 +0000 (-0800) Subject: zfs-functions.in: is_mounted() always returns 1 X-Git-Tag: zfs-0.8.0-rc3~50 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a0cc3726ed0b14ce43b0cfd4af4b703536a587c6;p=zfs zfs-functions.in: is_mounted() always returns 1 The 'while read line; ...; done' loop is run in a piped subshell therefore the 'return 0' would not cause a return from the is_mounted() function. In all cases, this function will always return 1. The fix is to 'return 1' from the subshell on a successful match (no match == return 0), and then negating the final return value. Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: TerraTech Closes #8151 --- diff --git a/etc/init.d/zfs-functions.in b/etc/init.d/zfs-functions.in index f5b74d458..490503e91 100644 --- a/etc/init.d/zfs-functions.in +++ b/etc/init.d/zfs-functions.in @@ -423,9 +423,14 @@ is_mounted() mount | \ while read line; do if echo "$line" | grep -q " on $mntpt "; then - return 0 + # returns: + # 0 on unsuccessful match + # 1 on a successful match + return 1 fi done - return 1 + # The negation will flip the subshell return result where the default + # return value is 0 when a match is not found. + return $(( !$? )) }