Skip to content

Added documentation for the new -args(0) option.#890

Merged
gasche merged 3 commits intoocaml:trunkfrom
bschommer:args-manual
Nov 4, 2016
Merged

Added documentation for the new -args(0) option.#890
gasche merged 3 commits intoocaml:trunkfrom
bschommer:args-manual

Conversation

@bschommer
Copy link
Copy Markdown
Contributor

Additionally typos in the documenation of Args.read_arg(0) and Args.write_arg(0) are fixed.
As requeseted in #843.

Additionally typos in the documenation of Args.read_arg(0) and
Args.write_arg(0) are fixed.
Copy link
Copy Markdown
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large number of comments, but predominantly it's just missing hyphens!

interactively.

\item["-args" \var{filename}]
Read additional newline separated command line arguments from \var{filename}.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline-separated (hyphenated). Is this sensitive to Unix/Windows line-endings?

Read additional newline separated command line arguments from \var{filename}.

\item["-args0" \var{filename}]
Read additional NUL separated command line arguments from \var{filename}.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NUL-separated (as above). Similarly, is there any Unix/Windows line-ending conversion to worry about here (e.g. would the input file foo\r\n\0bar\r\n be read as foo\n\0bar\n\0 on Windows?)


\item["-args0" \var{filename}]
Read additional NUL separated command line arguments from \var{filename}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same points as in comp.etex


\item["-args0" \var{filename}]
Read additional NUL separated command line arguments from \var{filename}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same points as in comp.etex


\item["-args0" \var{filename}]
Read additional NUL separated command line arguments from \var{filename}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same points as in comp.etex

stdlib/arg.mli Outdated
@@ -186,12 +186,12 @@ val read_arg: string -> string array

val read_arg0: string -> string array
(** Identical to {!Arg.read_arg} but assumes NUL terminated command line
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not part of this diff, but this should really be NUL-terminated (however, the manual and the docs are very inconsistent about null/NULL/NUL!)

stdlib/arg.mli Outdated
arguments. *)

val write_arg: string -> string array -> unit
(** [Arg.write_arg file args] writes the arguments [args] newline terminated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And another hyphen for newline-terminated 😄

stdlib/arg.mli Outdated
(** [Arg.write_arg file args] writes the arguments [args] newline terminated
into the file [file]. If the any of the arguments in [args] contains a
newline use the function {!Args.write_arg0} instead *)
newline use the function {!Arg.write_arg0} instead. *)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline, use (add comma). Could possibly drop the words the function?

stdlib/arg.mli Outdated

val write_arg0: string -> string array -> unit
(** Identical to {!Arg.write_arg} but uses NUL as terminator instead *)
(** Identical to {!Arg.write_arg} but uses NUL as terminator instead. *)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asfor the (i.e. "uses NUL as the terminator"). There's a slight inconsistency that the .mli file uses "terminator" where the manual uses "separator".

@xavierleroy
Copy link
Copy Markdown
Contributor

Concerning NUL: I'm afraid few programmers know their ASCII table well enough to know that NUL stands for the character with code 0. For everyone else, it looks like a typo for NULL and is associated with null pointers.

The man page for GNU find reads:

       -print0
              True; print the full file name on the standard output,  followed
              by  a  null  character  (instead  of  the newline character that
              -print uses).  This allows file names that contain  newlines  or
              other  types  of white space to be correctly interpreted by pro‐
              grams that process the find output.  This option corresponds  to
              the -0 option of xargs.

Notice the use of "null character" instead of NUL. Likewise in the man page for xargs, option -0.

So, please don't use NUL, it's jargon. Better use "null character", perhaps with a mention that this is the character with code 0.

@gasche
Copy link
Copy Markdown
Member

gasche commented Nov 4, 2016

Despite the non-invasiveness of this patch, it won't be on time for the 4.04 release, so I think we will try to update the manual after the release. I'll create a tag for PRs for which that is relevant.

@dra27
Copy link
Copy Markdown
Member

dra27 commented Nov 4, 2016

This feature isn't in 4.04 anyway, I think?

@bschommer
Copy link
Copy Markdown
Contributor Author

I changed NUL to null character and now everywhere separated/separator is used. Also line feed is replaced by newline, since the implementation ignores the \r before \n.

@gasche
Copy link
Copy Markdown
Member

gasche commented Nov 4, 2016

This feature isn't in 4.04 anyway, I think?

Oh indeed, I had forgotten about that. Thanks.

@damiendoligez
Copy link
Copy Markdown
Member

now everywhere separated/separator is used

This is incorrect. The arguments are terminated by newlines or null characters, with the last terminator being optional when its argument is not empty:

  • empty file -> no arguments
  • one newline -> one empty argument
  • two newlines -> two empty arguments
  • etc.

If you insist on specifying a separator, then it becomes impossible to put an empty list of arguments in the file (and in that case we'll need to change the code).

Maybe we should even go so far as to signal an error when the last argument doesn't have its terminator.

@bschommer
Copy link
Copy Markdown
Contributor Author

Terminated is now used instead of seperated.

Maybe we should even go so far as to signal an error when the last argument doesn't have its terminator.

I don't think that is a good idea to enforce this since one tends to forget this easily.

@xavierleroy
Copy link
Copy Markdown
Contributor

"Be liberal in what you accept, and conservative in what you send" (Postel's law).

@gasche
Copy link
Copy Markdown
Member

gasche commented Nov 4, 2016

It is my understanding that the comments have been taken into account, so I'm going ahead and merging the PR -- thanks! If anyone has more comments, feel free to make them here, we can always update or make a second PR.

@gasche gasche merged commit d27c578 into ocaml:trunk Nov 4, 2016
camlspotter pushed a commit to camlspotter/ocaml that referenced this pull request Oct 17, 2017
Added documentation for the new -args(0) option.
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Oct 25, 2022
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
Display the exercise difficulty next to the title of the exercise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants