Skip to content

Fix parsing of OPAMFETCH (support quotes / proper POSIX shell syntax)#5492

Merged
kit-ty-kate merged 4 commits intoocaml:masterfrom
kit-ty-kate:opamfetch-proper-cmd
Oct 16, 2025
Merged

Fix parsing of OPAMFETCH (support quotes / proper POSIX shell syntax)#5492
kit-ty-kate merged 4 commits intoocaml:masterfrom
kit-ty-kate:opamfetch-proper-cmd

Conversation

@kit-ty-kate
Copy link
Copy Markdown
Member

Fixes #5490

@scjung
Copy link
Copy Markdown

scjung commented Mar 27, 2023

It works! Thanks for the fix 👍

Processing  1/3: [coreutil.1.70: http]
+ /usr/local/bin/wget "--header" "Authorization: token >>>redacted<<" "https://github.com/>>redacted<</coreutil/archive/refs/tags/v1.70.tar.gz" "-O" "/Users/mukka/.opam/5.0/.opam-switch/sources/coreutil.1.70/v1.70.tar.gz.part"
- --2023-03-27 09:18:43--  https://github.com/>>redacted<</coreutil/archive/refs/tags/v1.70.tar.gz
- Resolving github.com (github.com)... 20.200.245.247
- Connecting to github.com (github.com)|20.200.245.247|:443... connected.
- HTTP request sent, awaiting response... 302 Found


module Char : sig

val is_whitespace : char -> bool
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about rather following what is being proposed upstream. That way, in a few years, you can likely simply delete the code. In other words:

module Char : sig 
  include Stdlib.Char
  module Ascii : sig 
    val is_white : char -> bool
  end
end

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I knew about the PR but I didn't use the same interface at the time for several reasons:

  • the two definitions are different (e.g. \v and \f are not handled by the opam definition but are with the stdlib one)
  • it wasn't merged at the time and we have a dedicated module for compatibility functions (https://github.com/ocaml/opam/blob/master/src/core/opamCompat.ml) so it would've felt a bit weird to have a yet-to-be-part-of-the-stdlib function in it
  • OpamStd isn't meant to be a mirror of the stdlib in terms of naming, OpamCompat is

Now that it has been merged i can think about it again although i personally feel like it would be better to wait for the release of 5.4 to change the function. In the meantime i'm happy to add a TODO comment to remind ourselves to change it when 5.4 is released.

@kit-ty-kate kit-ty-kate force-pushed the opamfetch-proper-cmd branch from 1e862b7 to 491fc0c Compare January 6, 2025 14:04
(* *)
(**************************************************************************)

val of_string : string -> string list
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The new module should be in its own commit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I prefer having both usage and definition in the same commit

(* *)
(**************************************************************************)

val of_string : string -> string list
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to add a new module instead of adding it in OpamStd?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In my opinion OpamStd should only be an overlay over the standard library, a Cmd module doesn't fit that. Also the definition is big enough to warrant its own module, and in the future i'd also like to add more functions to this module like to_string.

@kit-ty-kate kit-ty-kate modified the milestones: 2.4.0~alpha1, 2.5.0~alpha1 Apr 7, 2025
@kit-ty-kate kit-ty-kate force-pushed the opamfetch-proper-cmd branch from 491fc0c to 67f8596 Compare October 2, 2025 04:11
@kit-ty-kate kit-ty-kate requested a review from rjbou October 2, 2025 04:15
@kit-ty-kate kit-ty-kate force-pushed the opamfetch-proper-cmd branch 2 times, most recently from 4fd3e2a to ab7b60e Compare October 2, 2025 14:48
@rjbou rjbou force-pushed the opamfetch-proper-cmd branch 2 times, most recently from a85676c to 7f7abbc Compare October 16, 2025 17:26
Copy link
Copy Markdown
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

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

I've updated the PR, lgtm!
I moved the addition of the new module into its own commit as it is meant to evolve on its own, and I changed its name into OpamShellCommand (OpamCmd is too generic).
I've also added ocaml' 5.4 Char.Ascii.is_white in OpamCompat instead of our own definition (even it is not exactly the same).
You can see the diff in the last force push (the first is the rebase).

@rjbou rjbou force-pushed the opamfetch-proper-cmd branch from 7f7abbc to 00074d3 Compare October 16, 2025 17:51
@kit-ty-kate
Copy link
Copy Markdown
Member Author

ocaml-benchmarks failed due to a lack of disk space on the test machine

@kit-ty-kate kit-ty-kate merged commit 9640d87 into ocaml:master Oct 16, 2025
43 of 44 checks passed
@kit-ty-kate kit-ty-kate deleted the opamfetch-proper-cmd branch October 16, 2025 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tokenize OPAMFETCH value properly, not splitting by whitespaces

4 participants