* [PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore
@ 2019-07-23 6:27 Yongcheng Yang
2019-07-23 6:27 ` [PATCH 2/2] nfs4_getfacl: revise the Usage format as new options added Yongcheng Yang
2019-07-23 16:36 ` [PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore J. Bruce Fields
0 siblings, 2 replies; 3+ messages in thread
From: Yongcheng Yang @ 2019-07-23 6:27 UTC (permalink / raw)
To: J . Bruce Fields; +Cc: linux-nfs, Yongcheng Yang
The getopt_long() function will return '?' if encounters an option
character that was not in optstring. So it's impossible to tell the
option '-?' from an unrecognized option. Don't mention it in Usage.
Signed-off-by: Yongcheng Yang <yongcheng.yang@gmail.com>
---
nfs4_getfacl/nfs4_getfacl.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/nfs4_getfacl/nfs4_getfacl.c b/nfs4_getfacl/nfs4_getfacl.c
index 4df2b04..2f57866 100644
--- a/nfs4_getfacl/nfs4_getfacl.c
+++ b/nfs4_getfacl/nfs4_getfacl.c
@@ -88,10 +88,14 @@ int main(int argc, char **argv)
case 'c':
ignore_comment = 1;
break;
- default:
+ case 'h':
usage(1);
res = 0;
goto out;
+ case '?':
+ default:
+ usage(0);
+ goto out;
}
}
@@ -131,7 +135,7 @@ static void usage(int label)
{
if (label)
fprintf(stderr, "%s %s -- get NFSv4 file or directory access control lists.\n", execname, VERSION);
- fprintf(stderr, "Usage: %s [-R] file ...\n -H, --more-help\tdisplay ACL format information\n -?, -h, --help\tdisplay this help text\n -R --recursive\trecurse into subdirectories\n -c, --omit-header\tDo not display the comment header (Do not print filename)\n", execname);
+ fprintf(stderr, "Usage: %s [-R] file ...\n -H, --more-help\tdisplay ACL format information\n -h, --help\tdisplay this help text\n -R --recursive\trecurse into subdirectories\n -c, --omit-header\tDo not display the comment header (Do not print filename)\n", execname);
}
static void more_help()
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] nfs4_getfacl: revise the Usage format as new options added
2019-07-23 6:27 [PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore Yongcheng Yang
@ 2019-07-23 6:27 ` Yongcheng Yang
2019-07-23 16:36 ` [PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore J. Bruce Fields
1 sibling, 0 replies; 3+ messages in thread
From: Yongcheng Yang @ 2019-07-23 6:27 UTC (permalink / raw)
To: J . Bruce Fields; +Cc: linux-nfs, Yongcheng Yang
Signed-off-by: Yongcheng Yang <yongcheng.yang@gmail.com>
---
nfs4_getfacl/nfs4_getfacl.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/nfs4_getfacl/nfs4_getfacl.c b/nfs4_getfacl/nfs4_getfacl.c
index 2f57866..e068095 100644
--- a/nfs4_getfacl/nfs4_getfacl.c
+++ b/nfs4_getfacl/nfs4_getfacl.c
@@ -135,7 +135,16 @@ static void usage(int label)
{
if (label)
fprintf(stderr, "%s %s -- get NFSv4 file or directory access control lists.\n", execname, VERSION);
- fprintf(stderr, "Usage: %s [-R] file ...\n -H, --more-help\tdisplay ACL format information\n -h, --help\tdisplay this help text\n -R --recursive\trecurse into subdirectories\n -c, --omit-header\tDo not display the comment header (Do not print filename)\n", execname);
+
+ static const char *gfusage = \
+ "Usage: %s [OPTIONS] file ...\n"
+ " .. where OPTIONS is any (or none) of:\n"
+ " -H, --more-help display ACL format information\n"
+ " -h, --help display this help text\n"
+ " -R, --recursive recurse into subdirectories\n"
+ " -c, --omit-header Do not display the comment header (Do not print filename)\n";
+
+ fprintf(stderr, gfusage, execname);
}
static void more_help()
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore
2019-07-23 6:27 [PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore Yongcheng Yang
2019-07-23 6:27 ` [PATCH 2/2] nfs4_getfacl: revise the Usage format as new options added Yongcheng Yang
@ 2019-07-23 16:36 ` J. Bruce Fields
1 sibling, 0 replies; 3+ messages in thread
From: J. Bruce Fields @ 2019-07-23 16:36 UTC (permalink / raw)
To: Yongcheng Yang; +Cc: J . Bruce Fields, linux-nfs
On Tue, Jul 23, 2019 at 02:27:12PM +0800, Yongcheng Yang wrote:
> The getopt_long() function will return '?' if encounters an option
> character that was not in optstring. So it's impossible to tell the
> option '-?' from an unrecognized option. Don't mention it in Usage.
Thanks, both patches applied.--b.
>
> Signed-off-by: Yongcheng Yang <yongcheng.yang@gmail.com>
> ---
> nfs4_getfacl/nfs4_getfacl.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/nfs4_getfacl/nfs4_getfacl.c b/nfs4_getfacl/nfs4_getfacl.c
> index 4df2b04..2f57866 100644
> --- a/nfs4_getfacl/nfs4_getfacl.c
> +++ b/nfs4_getfacl/nfs4_getfacl.c
> @@ -88,10 +88,14 @@ int main(int argc, char **argv)
> case 'c':
> ignore_comment = 1;
> break;
> - default:
> + case 'h':
> usage(1);
> res = 0;
> goto out;
> + case '?':
> + default:
> + usage(0);
> + goto out;
> }
> }
>
> @@ -131,7 +135,7 @@ static void usage(int label)
> {
> if (label)
> fprintf(stderr, "%s %s -- get NFSv4 file or directory access control lists.\n", execname, VERSION);
> - fprintf(stderr, "Usage: %s [-R] file ...\n -H, --more-help\tdisplay ACL format information\n -?, -h, --help\tdisplay this help text\n -R --recursive\trecurse into subdirectories\n -c, --omit-header\tDo not display the comment header (Do not print filename)\n", execname);
> + fprintf(stderr, "Usage: %s [-R] file ...\n -H, --more-help\tdisplay ACL format information\n -h, --help\tdisplay this help text\n -R --recursive\trecurse into subdirectories\n -c, --omit-header\tDo not display the comment header (Do not print filename)\n", execname);
> }
>
> static void more_help()
> --
> 2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-23 16:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-23 6:27 [PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore Yongcheng Yang
2019-07-23 6:27 ` [PATCH 2/2] nfs4_getfacl: revise the Usage format as new options added Yongcheng Yang
2019-07-23 16:36 ` [PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore J. Bruce Fields
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).