# Regression in listing commands in list mode.
# Closes: #764042

diff --git a/needrestart b/needrestart
index 96b3569..eb88fcc 100755
--- a/needrestart
+++ b/needrestart
@@ -507,14 +507,14 @@ if(defined($opt_l)) {
 		    next;
 		}
 
-		if($opt_r eq 'a') {
-		    my @cmd = restart_cmd($rc);
-		    next unless($#cmd > -1);
+		my @cmd = restart_cmd($rc);
+		next unless($#cmd > -1);
 
+		if($opt_r eq 'a') {
 		    system(@cmd);
 		}
 		else {
-		    $ui->notice(" $rc");
+		    $ui->notice(join(' ', @cmd));
 		}
 	    }
 	
@@ -524,6 +524,9 @@ if(defined($opt_l)) {
 		    $ui->notice('Restarting services using systemd...');
 		    system(@cmd);
 		}
+		else {
+		    $ui->notice(join(' ', @cmd));
+		}
 	    }
 	}
 	else {
-- 
2.1.1

