All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bitbake-getvar: Do not output anything with --value and undefined variable
@ 2023-09-25  3:22 Peter Kjellerstedt
  2023-09-25  9:22 ` [bitbake-devel] " Richard Purdie
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Kjellerstedt @ 2023-09-25  3:22 UTC (permalink / raw)
  To: bitbake-devel

Rather than outputting the string "None" when an unknown variable is
used together with --value, output nothing. This is consistent with the
no --value case where only a comment stating that the variable is not
known is output.

This also means it is now possible to differentiate between an undefined
variable and an empty variable since the empty variable will be output
as a linefeed.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 bitbake/bin/bitbake-getvar | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/bitbake/bin/bitbake-getvar b/bitbake/bin/bitbake-getvar
index 4a9eb4f311..806bbd8e4e 100755
--- a/bitbake/bin/bitbake-getvar
+++ b/bitbake/bin/bitbake-getvar
@@ -43,9 +43,12 @@ if __name__ == "__main__":
         else:
             tinfoil.prepare(quiet=2, config_only=True)
             d = tinfoil.config_data
+        value = None
         if args.flag:
-            print(str(d.getVarFlag(args.variable, args.flag, expand=(not args.unexpand))))
+            value = d.getVarFlag(args.variable, args.flag, expand=(not args.unexpand))
         elif args.value:
-            print(str(d.getVar(args.variable, expand=(not args.unexpand))))
+            value = d.getVar(args.variable, expand=(not args.unexpand))
         else:
             bb.data.emit_var(args.variable, d=d, all=True)
+        if value is not None:
+            print(str(value))


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-09-25 20:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-25  3:22 [PATCH] bitbake-getvar: Do not output anything with --value and undefined variable Peter Kjellerstedt
2023-09-25  9:22 ` [bitbake-devel] " Richard Purdie
2023-09-25 10:16   ` Peter Kjellerstedt
2023-09-25 10:30     ` Richard Purdie
2023-09-25 13:55       ` Peter Kjellerstedt
2023-09-25 14:06         ` Richard Purdie
2023-09-25 16:00           ` Peter Kjellerstedt
2023-09-25 16:17             ` Richard Purdie
2023-09-25 18:39               ` Mario Domenech Goulart
2023-09-25 20:29                 ` Peter Kjellerstedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.