summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/data.py')
-rw-r--r--bitbake/lib/bb/data.py40
1 files changed, 23 insertions, 17 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 14f1d896d7..9782c9f546 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -337,6 +337,12 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
337 if getVarFlag(var, "python", d): 337 if getVarFlag(var, "python", d):
338 return 0 338 return 0
339 339
340 export = getVarFlag(var, "export", d)
341 unexport = getVarFlag(var, "unexport", d)
342 func = getVarFlag(var, "func", d)
343 if not all and not export and not unexport and not func:
344 return 0
345
340 try: 346 try:
341 if all: 347 if all:
342 oval = getVar(var, d, 0) 348 oval = getVar(var, d, 0)
@@ -362,28 +368,28 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
362 if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all: 368 if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all:
363 return 0 369 return 0
364 370
371 varExpanded = expand(var, d)
372
373 if unexport:
374 o.write('unset %s\n' % varExpanded)
375 return 1
376
365 val.rstrip() 377 val.rstrip()
366 if not val: 378 if not val:
367 return 0 379 return 0
368
369 varExpanded = expand(var, d)
370 380
371 if getVarFlag(var, "func", d): 381 if func:
372# NOTE: should probably check for unbalanced {} within the var 382 # NOTE: should probably check for unbalanced {} within the var
373 o.write("%s() {\n%s\n}\n" % (varExpanded, val)) 383 o.write("%s() {\n%s\n}\n" % (varExpanded, val))
374 else: 384 return 1
375 if getVarFlag(var, "unexport", d): 385
376 o.write('unset %s\n' % varExpanded) 386 if export:
377 return 1 387 o.write('export ')
378 if getVarFlag(var, "export", d): 388
379 o.write('export ') 389 # if we're going to output this within doublequotes,
380 else: 390 # to a shell, we need to escape the quotes in the var
381 if not all: 391 alter = re.sub('"', '\\"', val.strip())
382 return 0 392 o.write('%s="%s"\n' % (varExpanded, alter))
383# if we're going to output this within doublequotes,
384# to a shell, we need to escape the quotes in the var
385 alter = re.sub('"', '\\"', val.strip())
386 o.write('%s="%s"\n' % (varExpanded, alter))
387 return 1 393 return 1
388 394
389 395