git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 01/10] Add a parseopt mode to git-rev-parse to bring parse-options to shell scripts.

From
RWRalf Wildenhues <ralf.wildenhues@gmx.de>
Date
Nov 4, 2007, 11:29 UTC
Message-ID
<20071104112931.GB2119@ins.uni-bonn.de>
In-Reply-To
<1194172262-1563-2-git-send-email-madcoder@debian.org>
Hello Pierre,
A couple of language nits:
* Pierre Habouzit wrote on Sun, Nov 04, 2007 at 11:30:53AM CET:
Show 10 quoted lines
> +PARSEOPT
> +--------
> +
> +In `--parseopt` mode, `git-rev-parse` helps massaging options to bring to shell
> +scripts the same facilities C builtins have. It works as an option normalizer
> +(e.g. splits single switches aggregate values), a bit like `getopt(1)` does.
> +
> +It takes on the standard input the specification of the options to parse and
> +understand, and echoes on the standard ouput a line suitable for `sh(1)` `eval`
> +to replace the arguments with normalized ones.  In case of error, it ouputs
s/ouputs/outputs/
Show 6 quoted lines
> +usage on the standard error stream, and exits with code 129.
> +
> +Input Format
> +~~~~~~~~~~~~
> +
> +`git-ref-parse --parseopt` input format is fully text based. It has two parts,

s/^/The / s/git-ref-parse/git-rev-parse/

> +separated by a line that contains only `--`. The lines before (should be more
> +than one) are used for the usage. The lines after describe the options.
I would write
  s/before/& the `--`/
  s/after/& the `--`/
or maybe write "separator" instead of `--`.
[...]
Show 9 quoted lines
> +`<opt_spec>`::
> +	its format is the short option character, then the long option name
> +        separated by a comma. Both parts are not required, though at least one
> +        is necessary. `h,help`, `dry-run` and `f` are all three correct
> +        `<opt_spec>`.
> +
> +`<arg_spec>`::
> +	an `<arg_spec>` tells the option parser if the option has an argument
> +        (`=`), an optionnal one (`?` though its use is discouraged) or none
s/optionnal/optional/
> +        (no `<arg_spec>` in that case).
> +
> +The rest of the line after as many spaces up to the ending line feed is used
> +as the help associated to the option.
I'd write (in case that is technically correct):
  After following white space, the rest of the line after is used as the
  help associated to the option.
> +Blank lines are ignored, and lines that don't match this specification are used
> +as option group headers (start the line with a space to purposely create such
> +lines).
I'd write:
  ... to create such lines on purpose.
Show 8 quoted lines
> +Example
> +~~~~~~~
> +
> +------------
> +OPTS_SPEC="\
> +some-command [options] <args>...
> +
> +some-command does foo and bar !
Please no white space before "!".
Show 8 quoted lines
> +--
> +h,help    show the help
> +
> +foo       some nifty option --foo
> +bar=      some cool option --bar with an argument
> +
> +  An option group Header
> +C?        option C with an optionnal argument"
s/optionnal/optional/

Cheers, Ralf

Previous: Junio C HamanoNext: Ralf Wildenhues
Message 17 of 20 in “ph/parseopt-sh reloaded”
  1. Pierre HabouzitNov 4, 2007
  2. 01/10 Add a parseopt mode to git-rev-parse to bring parse-options to shell scripts.Pierre Habouzit, Nov 4, 2007
  3. 02/10 Update git-sh-setup(1) to allow transparent use of git-rev-parse --parseoptPierre Habouzit, Nov 4, 2007
  4. 03/10 Migrate git-clean.sh to use git-rev-parse --parseopt.Pierre Habouzit, Nov 4, 2007
  5. 04/10 Migrate git-clone to use git-rev-parse --parseoptPierre Habouzit, Nov 4, 2007
  6. 05/10 Migrate git-am.sh to use git-rev-parse --parseoptPierre Habouzit, Nov 4, 2007
  7. 06/10 Migrate git-merge.sh to use git-rev-parse --parseoptPierre Habouzit, Nov 4, 2007
  8. 07/10 Migrate git-instaweb.sh to use git-rev-parse --parseoptPierre Habouzit, Nov 4, 2007
  9. 08/10 Migrate git-checkout.sh to use git-rev-parse --parseopt --keep-dashdashPierre Habouzit, Nov 4, 2007
  10. 09/10 Migrate git-quiltimport.sh to use git-rev-parse --parseoptPierre Habouzit, Nov 4, 2007
  11. 10/10 Migrate git-repack.sh to use git-rev-parse --parseoptPierre Habouzit, Nov 4, 2007
  12. Pierre HabouzitNov 4, 2007
  13. Nicolas PitreNov 6, 2007
  14. Junio C HamanoNov 6, 2007
  15. Nicolas PitreNov 6, 2007
  16. Junio C HamanoNov 6, 2007
  17. Ralf WildenhuesNov 4, 2007
  18. Ralf WildenhuesNov 4, 2007
  19. Junio C HamanoNov 4, 2007
  20. Pierre HabouzitNov 4, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.