* [U-Boot] [PATCH 1/2] tools/env: allow option "-n" for fw_printenv
@ 2010-09-15 17:46 Daniel Hobi
2010-09-15 17:46 ` [U-Boot] [PATCH 2/2] tools/env: fail on invalid options Daniel Hobi
2010-09-18 21:56 ` [U-Boot] [PATCH 1/2] tools/env: allow option "-n" for fw_printenv Wolfgang Denk
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Hobi @ 2010-09-15 17:46 UTC (permalink / raw)
To: u-boot
In commit bd7b26f8 (Tools: set multiple variable with fw_setenv utility),
the option parsing was changed to getopt_long(3), but option "-n"
of fw_printenv was not included.
This leads to an error message "invalid option -- 'n'" on stderr,
although the output on stdout is correct.
Signed-off-by: Daniel Hobi <daniel.hobi@schmid-telecom.ch>
---
tools/env/fw_env_main.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index 82116b4..baf3a4d 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -59,7 +59,7 @@ void usage(void)
fprintf(stderr, "fw_printenv/fw_setenv, "
"a command line interface to U-Boot environment\n\n"
- "usage:\tfw_printenv\n"
+ "usage:\tfw_printenv [-n] [variable name]\n"
"\tfw_setenv [variable name] [variable value]\n"
"\tfw_setenv -s [ file ]\n"
"\tfw_setenv -s - < [ file ]\n\n"
@@ -93,9 +93,12 @@ main(int argc, char *argv[])
cmdname = p + 1;
}
- while ((c = getopt_long (argc, argv, "s:h",
+ while ((c = getopt_long (argc, argv, "ns:h",
long_options, NULL)) != EOF) {
switch (c) {
+ case 'n':
+ /* handled in fw_printenv */
+ break;
case 's':
script_file = optarg;
break;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 2/2] tools/env: fail on invalid options
2010-09-15 17:46 [U-Boot] [PATCH 1/2] tools/env: allow option "-n" for fw_printenv Daniel Hobi
@ 2010-09-15 17:46 ` Daniel Hobi
2010-09-15 19:18 ` Wolfgang Denk
2010-09-18 21:56 ` [U-Boot] [PATCH 1/2] tools/env: allow option "-n" for fw_printenv Wolfgang Denk
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Hobi @ 2010-09-15 17:46 UTC (permalink / raw)
To: u-boot
Signed-off-by: Daniel Hobi <daniel.hobi@schmid-telecom.ch>
---
tools/env/fw_env_main.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index baf3a4d..381ed14 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -105,6 +105,8 @@ main(int argc, char *argv[])
case 'h':
usage();
return EXIT_SUCCESS;
+ default: /* '?' */
+ return EXIT_FAILURE;
}
}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 2/2] tools/env: fail on invalid options
2010-09-15 17:46 ` [U-Boot] [PATCH 2/2] tools/env: fail on invalid options Daniel Hobi
@ 2010-09-15 19:18 ` Wolfgang Denk
2010-09-16 12:36 ` [U-Boot] [PATCH 2/2 v2] " Daniel Hobi
0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Denk @ 2010-09-15 19:18 UTC (permalink / raw)
To: u-boot
Dear Daniel Hobi,
In message <1284572787-9842-2-git-send-email-daniel.hobi@schmid-telecom.ch> you wrote:
>
> Signed-off-by: Daniel Hobi <daniel.hobi@schmid-telecom.ch>
> ---
> tools/env/fw_env_main.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
> index baf3a4d..381ed14 100644
> --- a/tools/env/fw_env_main.c
> +++ b/tools/env/fw_env_main.c
> @@ -105,6 +105,8 @@ main(int argc, char *argv[])
> case 'h':
> usage();
> return EXIT_SUCCESS;
> + default: /* '?' */
> + return EXIT_FAILURE;
This should print an error message before returning; for example, run
usage() as in the 'h' case - just with different return code.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
He had quite a powerful intellect, but it was as powerful like a
locomotive, and ran on rails and was therefore almost impossible to
steer. - Terry Pratchett, _Lords and Ladies_
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 2/2 v2] tools/env: fail on invalid options
2010-09-15 19:18 ` Wolfgang Denk
@ 2010-09-16 12:36 ` Daniel Hobi
2010-09-18 21:56 ` Wolfgang Denk
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Hobi @ 2010-09-16 12:36 UTC (permalink / raw)
To: u-boot
Signed-off-by: Daniel Hobi <daniel.hobi@schmid-telecom.ch>
---
v2:
- print a hint to --help before returning
tools/env/fw_env_main.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
Hi Wolfgang,
On 15.09.2010 21:18, Wolfgang Denk wrote:
> In message <1284572787-9842-2-git-send-email-daniel.hobi@schmid-telecom.ch> you wrote:
>> + default: /* '?' */
>> + return EXIT_FAILURE;
>
> This should print an error message before returning; for example, run
> usage() as in the 'h' case - just with different return code.
getopt_long(3) already prints a suitable error message (also see [PATCH 1/2]):
$ fw_printenv -a
fw_printenv: invalid option -- 'a'
v2 of this patch additionally prints a hint to the user, in the same way
as some Linux core utilities (Debian coreutils: cat, date and 94 others).
I prefer this solution to calling usage() which would hide the real error
message by printing 20 additional lines.
Best regards,
Daniel
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index baf3a4d..c654057 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -105,6 +105,10 @@ main(int argc, char *argv[])
case 'h':
usage();
return EXIT_SUCCESS;
+ default: /* '?' */
+ fprintf(stderr, "Try `%s --help' for more information."
+ "\n", cmdname);
+ return EXIT_FAILURE;
}
}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 1/2] tools/env: allow option "-n" for fw_printenv
2010-09-15 17:46 [U-Boot] [PATCH 1/2] tools/env: allow option "-n" for fw_printenv Daniel Hobi
2010-09-15 17:46 ` [U-Boot] [PATCH 2/2] tools/env: fail on invalid options Daniel Hobi
@ 2010-09-18 21:56 ` Wolfgang Denk
1 sibling, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2010-09-18 21:56 UTC (permalink / raw)
To: u-boot
Dear Daniel Hobi,
In message <1284572787-9842-1-git-send-email-daniel.hobi@schmid-telecom.ch> you wrote:
> In commit bd7b26f8 (Tools: set multiple variable with fw_setenv utility),
> the option parsing was changed to getopt_long(3), but option "-n"
> of fw_printenv was not included.
>
> This leads to an error message "invalid option -- 'n'" on stderr,
> although the output on stdout is correct.
>
> Signed-off-by: Daniel Hobi <daniel.hobi@schmid-telecom.ch>
> ---
> tools/env/fw_env_main.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It's a small world, but I wouldn't want to paint it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 2/2 v2] tools/env: fail on invalid options
2010-09-16 12:36 ` [U-Boot] [PATCH 2/2 v2] " Daniel Hobi
@ 2010-09-18 21:56 ` Wolfgang Denk
0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2010-09-18 21:56 UTC (permalink / raw)
To: u-boot
Dear Daniel Hobi,
In message <1284640569-8527-1-git-send-email-daniel.hobi@schmid-telecom.ch> you wrote:
>
> Signed-off-by: Daniel Hobi <daniel.hobi@schmid-telecom.ch>
> ---
> v2:
> - print a hint to --help before returning
>
> tools/env/fw_env_main.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Certainly there are things in life that money can't buy, but it's
very funny - Did you ever try buying them without money? - Ogden Nash
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-09-18 21:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-15 17:46 [U-Boot] [PATCH 1/2] tools/env: allow option "-n" for fw_printenv Daniel Hobi
2010-09-15 17:46 ` [U-Boot] [PATCH 2/2] tools/env: fail on invalid options Daniel Hobi
2010-09-15 19:18 ` Wolfgang Denk
2010-09-16 12:36 ` [U-Boot] [PATCH 2/2 v2] " Daniel Hobi
2010-09-18 21:56 ` Wolfgang Denk
2010-09-18 21:56 ` [U-Boot] [PATCH 1/2] tools/env: allow option "-n" for fw_printenv Wolfgang Denk
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.