linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: bfields@fieldses.org (J. Bruce Fields)
To: Yongcheng Yang <yongcheng.yang@gmail.com>
Cc: "J . Bruce Fields" <bfields@redhat.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/2] nfs4_getfacl: return 1 for unknown option and won't use '-?' anymore
Date: Tue, 23 Jul 2019 12:36:06 -0400	[thread overview]
Message-ID: <20190723163606.GA16908@fieldses.org> (raw)
In-Reply-To: <20190723062713.20570-1-yongcheng.yang@gmail.com>

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

      parent reply	other threads:[~2019-07-23 16:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190723163606.GA16908@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=bfields@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=yongcheng.yang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).