[PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux