[zorg] r223552 - Make printed commands safe for copy and paste in Jenkins build console
Chris Matthews
cmatthews5 at apple.com
Fri Dec 5 16:38:36 PST 2014
Author: cmatthews
Date: Fri Dec 5 18:38:36 2014
New Revision: 223552
URL: http://llvm.org/viewvc/llvm-project?rev=223552&view=rev
Log:
Make printed commands safe for copy and paste in Jenkins build console
Modified:
zorg/trunk/zorg/jenkins/build.py
Modified: zorg/trunk/zorg/jenkins/build.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/jenkins/build.py?rev=223552&r1=223551&r2=223552&view=diff
==============================================================================
--- zorg/trunk/zorg/jenkins/build.py (original)
+++ zorg/trunk/zorg/jenkins/build.py Fri Dec 5 18:38:36 2014
@@ -20,9 +20,16 @@ def next_section(name):
def header(name):
print "@@@", name, "@@@"
+
def footer():
print "@@@@@@"
+
+def quote_sh_string(string):
+ """Make things that we print shell safe for copy and paste."""
+ return "\\'".join("'" + p + "'" for p in string.split("'"))
+
+
class Configuration(object):
"""docstring for Configuration"""
def __init__(self, args):
@@ -388,7 +395,8 @@ def build_upload_artifact():
def run_cmd(working_dir, cmd):
"""Run a command in a working directory, and make sure it returns zero."""
old_cwd = os.getcwd()
- sys.stdout.write("cd {}\n{}\n".format(working_dir, ' '.join(cmd)))
+ cmd_to_print = ' '.join([quote_sh_string(x) for x in cmd])
+ sys.stdout.write("cd {}\n{}\n".format(working_dir, cmd_to_print))
sys.stdout.flush()
start_time = datetime.datetime.now()
More information about the llvm-commits
mailing list