[PATCH 1/3] tgt-admin: avoid zsh-specific syntax in system() call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"lsof &> /dev/null" is apparently zsh (and maybe some other shells,
but not bash) for "redirect both stderr and stdout".  Under bash,
I believe what this means is "execute the prior command in the
background, and then execute the meaningless "> /dev/null" command".
That wouldn't be a problem except that the return code becomes the
return code of the "> /dev/null", hiding the return code of the
'lsof' command.

Fix: use the more-standard "lsof >/dev/null 2>&1" syntax.

Signed-off-by: Dan Mick <dan.mick@xxxxxxxxxxx>
---
 scripts/tgt-admin |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/tgt-admin b/scripts/tgt-admin
index d374172..183b0af 100755
--- a/scripts/tgt-admin
+++ b/scripts/tgt-admin
@@ -1319,7 +1319,7 @@ sub check_device {
 	# Check if userspace uses this device
 	my $lsof_check = check_exe("lsof");
 	if ($lsof_check ne 1) {
-		system("lsof $backing_store &>/dev/null");
+		system("lsof $backing_store >/dev/null 2>&1");
 		my $exit_value  = $? >> 8;
 		if ($exit_value eq 0) {
 			execute("# Device $backing_store is used (already tgtd target?).");
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux