11open Import
22open Fiber.O
33
4+ let apply_or_skip_empty f = function
5+ | None | Some "" -> None
6+ | Some s -> Some (f s)
7+ ;;
8+
49let norm = function
510 | "" -> None
611 | s -> Some (String. lowercase s)
@@ -53,18 +58,14 @@ let arch ~path =
5358 | Intel -> Some " x86_32"
5459 | Unknown -> None )
5560 | _ -> Fiber. return None )
56- >> | function
57- | None | Some "" -> None
58- | Some a -> Some (normalise_arch a)
61+ >> | apply_or_skip_empty normalise_arch
5962;;
6063
6164let os ~path =
6265 (match Sys. os_type with
6366 | "Unix" -> uname ~path [ " -s" ]
6467 | s -> Fiber. return (norm s))
65- >> | function
66- | None | Some "" -> None
67- | Some s -> Some (normalise_os s)
68+ >> | apply_or_skip_empty normalise_os
6869;;
6970
7071let android_release ~path =
@@ -174,6 +175,8 @@ let os_distribution ~path =
174175let os_family ~path =
175176 os ~path
176177 >> = function
178+ | Some ("freebsd" | "openbsd" | "netbsd" | "dragonfly" ) -> Fiber. return @@ Some " bsd"
179+ | Some ("win32" | "cygwin" ) -> Fiber. return @@ Some " windows"
177180 | Some "linux" ->
178181 os_release_field " ID_LIKE"
179182 >> = (function
@@ -183,8 +186,6 @@ let os_family ~path =
183186 (match Scanf. sscanf s " %s" Fun. id with
184187 | Error _ -> os_distribution ~path
185188 | Ok s -> Fiber. return @@ norm s))
186- | Some ("freebsd" | "openbsd" | "netbsd" | "dragonfly" ) -> Fiber. return @@ Some " bsd"
187- | Some ("win32" | "cygwin" ) -> Fiber. return @@ Some " windows"
188189 | _ -> os_distribution ~path
189190;;
190191
0 commit comments