summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--release/util.py8
-rwxr-xr-xrepo11
2 files changed, 10 insertions, 9 deletions
diff --git a/release/util.py b/release/util.py
index df7a5638..c839b872 100644
--- a/release/util.py
+++ b/release/util.py
@@ -16,6 +16,7 @@
16 16
17import os 17import os
18import re 18import re
19import shlex
19import subprocess 20import subprocess
20import sys 21import sys
21 22
@@ -35,12 +36,7 @@ KEYID_ECC = "E1F9040D7A3F6DAFAC897CD3D3B95DA243E48A39"
35 36
36def cmdstr(cmd): 37def cmdstr(cmd):
37 """Get a nicely quoted shell command.""" 38 """Get a nicely quoted shell command."""
38 ret = [] 39 return " ".join(shlex.quote(x) for x in cmd)
39 for arg in cmd:
40 if not re.match(r"^[a-zA-Z0-9/_.=-]+$", arg):
41 arg = f'"{arg}"'
42 ret.append(arg)
43 return " ".join(ret)
44 40
45 41
46def run(opts, cmd, check=True, **kwargs): 42def run(opts, cmd, check=True, **kwargs):
diff --git a/repo b/repo
index 782afb6e..2526ab03 100755
--- a/repo
+++ b/repo
@@ -57,9 +57,14 @@ class Trace:
57trace = Trace() 57trace = Trace()
58 58
59 59
60def cmdstr(cmd):
61 """Get a nicely quoted shell command."""
62 return " ".join(shlex.quote(x) for x in cmd)
63
64
60def exec_command(cmd): 65def exec_command(cmd):
61 """Execute |cmd| or return None on failure.""" 66 """Execute |cmd| or return None on failure."""
62 trace.print(":", " ".join(cmd)) 67 trace.print(":", cmdstr(cmd))
63 try: 68 try:
64 if platform.system() == "Windows": 69 if platform.system() == "Windows":
65 ret = subprocess.call(cmd) 70 ret = subprocess.call(cmd)
@@ -506,7 +511,7 @@ def run_command(cmd, **kwargs):
506 # Run & package the results. 511 # Run & package the results.
507 proc = subprocess.Popen(cmd, **kwargs) 512 proc = subprocess.Popen(cmd, **kwargs)
508 (stdout, stderr) = proc.communicate(input=cmd_input) 513 (stdout, stderr) = proc.communicate(input=cmd_input)
509 dbg = ": " + " ".join(cmd) 514 dbg = ": " + cmdstr(cmd)
510 if cmd_input is not None: 515 if cmd_input is not None:
511 dbg += " 0<|" 516 dbg += " 0<|"
512 if stdout == subprocess.PIPE: 517 if stdout == subprocess.PIPE:
@@ -843,7 +848,7 @@ def _GetRepoConfig(name):
843 return None 848 return None
844 else: 849 else:
845 print( 850 print(
846 f"repo: error: git {' '.join(cmd)} failed:\n{ret.stderr}", 851 f"repo: error: git {cmdstr(cmd)} failed:\n{ret.stderr}",
847 file=sys.stderr, 852 file=sys.stderr,
848 ) 853 )
849 # This will raise subprocess.CalledProcessError for us. 854 # This will raise subprocess.CalledProcessError for us.