linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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

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).