Skip to content

Commit 950fc32

Browse files
mbolivarmarc-hb
authored andcommittedJan 14, 2025·
config: upgrade dbg to err on missing option
A user has pointed out that west's behavior in the following case is confusing: west config foo.bar=baz The desired behavior is "set foo.bar to baz". Instead, west exits 1 without printing anything on the console. Let's make it clearer that the user is inadventently asking for the value of an option called "foo.bar=baz", since right now there is no rule forbidding "=" in option names, so the above confusing case is actually asking for section "foo", key "bar=baz". With this patch, west prints: ERROR: foo.bar=baz is unset to stderr along with exiting 1, making it clearer that something went wrong. Note that since this doesn't print to stdout, the new output won't be confused with the value of the option by well-behaved programs. In general, 'west config' documents no guarantees about when it prints to stderr, and new error messages showing up on stderr is in line with general de facto standard expectations for command line programs. However, users may need to redirect stderr to /dev/null (or do similarly on Windows) now if they aren't interested in this output. Reported-by: David Brown <david.brown@linaro.org> Signed-off-by: Martí Bolívar <marti.bolivar@oss.qualcomm.com>
1 parent 3ab7d2f commit 950fc32

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎src/west/app/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def read(self, args):
191191
if value is not None:
192192
self.inf(value)
193193
else:
194-
self.dbg(f'{args.name} is unset')
194+
self.err(f'{args.name} is unset')
195195
raise CommandError(returncode=1)
196196

197197
def append(self, args):

0 commit comments

Comments
 (0)
Please sign in to comment.