mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
scripts: Use shell quoting when displaying commands to be run.
This way, commands with arguments containing whitespace or metacharacters are unambiguously readable. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
committed by
Tim Abbott
parent
de5e3d3fbd
commit
510c97d861
@@ -7,6 +7,7 @@ import logging
|
||||
import os
|
||||
import pwd
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -153,7 +154,7 @@ def release_deployment_lock():
|
||||
def run(args, **kwargs):
|
||||
# type: (Sequence[str], **Any) -> None
|
||||
# Output what we're doing in the `set -x` style
|
||||
print("+ %s" % (" ".join(args)))
|
||||
print("+ %s" % (" ".join(map(shlex.quote, args)),))
|
||||
|
||||
if kwargs.get('shell'):
|
||||
# With shell=True we can only pass string to Popen
|
||||
@@ -163,7 +164,8 @@ def run(args, **kwargs):
|
||||
subprocess.check_call(args, **kwargs)
|
||||
except subprocess.CalledProcessError:
|
||||
print()
|
||||
print(WHITEONRED + "Error running a subcommand of %s: %s" % (sys.argv[0], " ".join(args)) +
|
||||
print(WHITEONRED + "Error running a subcommand of %s: %s" %
|
||||
(sys.argv[0], " ".join(map(shlex.quote, args))) +
|
||||
ENDC)
|
||||
print(WHITEONRED + "Actual error output for the subcommand is just above this." +
|
||||
ENDC)
|
||||
|
||||
Reference in New Issue
Block a user