Browse Source

tools/qvm-run: do not color the output unless --pass-io is used

Since no output from VM is passed (and even if it would, it's redirected
to /dev/null), there is no need to switch output color.
This fixes the case when qvm-run is started in background - the color
change would affect further shell output.

Fixes QubesOS/qubes-issues#4808
Marek Marczykowski-Górecki 5 years ago
parent
commit
b1a191446a
1 changed files with 5 additions and 4 deletions
  1. 5 4
      qubesadmin/tools/qvm_run.py

+ 5 - 4
qubesadmin/tools/qvm_run.py

@@ -197,11 +197,12 @@ def run_command_single(args, vm):
 def main(args=None, app=None):
     '''Main function of qvm-run tool'''
     args = parser.parse_args(args, app=app)
-    if args.color_output is None and args.filter_esc:
-        args.color_output = '31'
+    if args.passio:
+        if args.color_output is None and args.filter_esc:
+            args.color_output = 31
 
-    if args.color_stderr is None and os.isatty(sys.stderr.fileno()):
-        args.color_stderr = 31
+        if args.color_stderr is None and os.isatty(sys.stderr.fileno()):
+            args.color_stderr = 31
 
     if len(args.domains) > 1 and args.passio and not args.localcmd:
         parser.error('--passio cannot be used when more than 1 qube is chosen '