diff mbox series

fw_printenv: return non-zero status when uboot env doesn't exist

Message ID 20210825093451.6286-1-richard.burke@hivehome.com
State Rejected
Headers show
Series fw_printenv: return non-zero status when uboot env doesn't exist | expand

Commit Message

Richard Burke Aug. 25, 2021, 9:34 a.m. UTC
Match the behaviour of uboot fw_printenv by returning a non-zero exit
code when a specified env variable doesn't exist.

Signed-off-by: Richard Burke <richard.burke@hivehome.com>
---
 src/fw_printenv.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Stefano Babic Aug. 25, 2021, 9:59 a.m. UTC | #1
Hi Richard,

On 25.08.21 11:34, Richard Burke wrote:
> Match the behaviour of uboot fw_printenv by returning a non-zero exit
> code when a specified env variable doesn't exist.
> 

This is very questionable. A non-zero returns means that an error 
happens, that means the environment cannot be read and there is no 
default environment (or something in the chain was wrong).

But if the variable does not exist, there is no error and and empty 
string is returned, as expected. I find behavior is correct.

Best regards,
Stefano Babic

> Signed-off-by: Richard Burke <richard.burke@hivehome.com>
> ---
>   src/fw_printenv.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/src/fw_printenv.c b/src/fw_printenv.c
> index c457b30..5534a2e 100644
> --- a/src/fw_printenv.c
> +++ b/src/fw_printenv.c
> @@ -146,6 +146,7 @@ int main (int argc, char **argv) {
>   		} else {
>   			for (i = 0; i < argc; i++) {
>   				value = libuboot_get_env(ctx, argv[i]);
> +				ret |= (value == NULL);
>   				if (noheader)
>   					fprintf(stdout, "%s\n", value ? value : "");
>   				else
>
diff mbox series

Patch

diff --git a/src/fw_printenv.c b/src/fw_printenv.c
index c457b30..5534a2e 100644
--- a/src/fw_printenv.c
+++ b/src/fw_printenv.c
@@ -146,6 +146,7 @@  int main (int argc, char **argv) {
 		} else {
 			for (i = 0; i < argc; i++) {
 				value = libuboot_get_env(ctx, argv[i]);
+				ret |= (value == NULL);
 				if (noheader)
 					fprintf(stdout, "%s\n", value ? value : "");
 				else