]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake/data.py: corrected the output for shell syntax.
authorLianhao Lu <lianhao.lu@intel.com>
Fri, 7 Jan 2011 06:17:10 +0000 (14:17 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 7 Jan 2011 11:14:22 +0000 (11:14 +0000)
[BUGID# 645], modify the emit_var()
1. Added "#" to the beginning of each line if the comment contains
multiple lines.

2. Added "\" to the end of each line if the shell variable value
contains multiple lines.

Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
bitbake/lib/bb/data.py

index 6ec522aa4836dc049e6e6f0017b5f9bce6cfcaca..53ce7d62d313943a58d8673b75dc1ab7a6b999a3 100644 (file)
@@ -192,7 +192,8 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
         return 0
 
     if all:
-        o.write('# %s=%s\n' % (var, oval))
+        commentVal = re.sub('\n', '\n#', str(oval))
+        o.write('# %s=%s\n' % (var, commentVal))
 
     if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all:
         return 0
@@ -219,6 +220,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
     # if we're going to output this within doublequotes,
     # to a shell, we need to escape the quotes in the var
     alter = re.sub('"', '\\"', val.strip())
+    alter = re.sub('\n', ' \\\n', alter)
     o.write('%s="%s"\n' % (varExpanded, alter))
     return 0