From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 89C3D7F926 for ; Tue, 24 May 2016 08:49:03 +0200 (CEST) IronPort-PHdr: 9a23:cfMHbRd0I1va65+Zc0Yx91IHlGMj4u6mDksu8pMizoh2WeGdxc69bR7h7PlgxGXEQZ/co6odzbGG4ua8ASdcvd6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDjvcGLKFkUzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IeezAcq85Vb1VCig9eyBwvZWz9EqLcQzaynIaU2gS2jDcBRrB7VmuUp73syb+8OBg1S+IOczeQKouUCij9rpmDhTo3nQpLTk8pUjbkM19iup9qR6svVQryoLOYYyTHPx5YqCbeskVEzkSFv1NXjBMV9vvJ7AECPAMaKMB99Hw Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=adrien@notk.org; spf=Pass smtp.mailfrom=adrien@notk.org; spf=None smtp.helo=postmaster@nautica.notk.org Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of adrien@notk.org) identity=pra; client-ip=91.121.71.147; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="adrien@notk.org"; x-sender="adrien@notk.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of adrien@notk.org designates 91.121.71.147 as permitted sender) identity=mailfrom; client-ip=91.121.71.147; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="adrien@notk.org"; x-sender="adrien@notk.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@nautica.notk.org) identity=helo; client-ip=91.121.71.147; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="adrien@notk.org"; x-sender="postmaster@nautica.notk.org"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BIAgD2+ENX/5NHeVtbgzeESLcIAQ2BdoYRAoEwOBQBAQEBAQEBAWQngi2CFgEBBCMEUhALGgIFEw4CAg8FGB0BE4hGskORaAEBCAIBJIEBhSaETIdAK4IuBZg3jhYKZo42j0weAQFCggYcgU06igMBAQE X-IPAS-Result: A0BIAgD2+ENX/5NHeVtbgzeESLcIAQ2BdoYRAoEwOBQBAQEBAQEBAWQngi2CFgEBBCMEUhALGgIFEw4CAg8FGB0BE4hGskORaAEBCAIBJIEBhSaETIdAK4IuBZg3jhYKZo42j0weAQFCggYcgU06igMBAQE X-IronPort-AV: E=Sophos;i="5.26,359,1459807200"; d="scan'208";a="219447123" Received: from nautica.notk.org ([91.121.71.147]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 May 2016 08:49:02 +0200 Received: by nautica.notk.org (Postfix, from userid 1003) id 8FB7CC009; Tue, 24 May 2016 08:49:01 +0200 (CEST) Date: Tue, 24 May 2016 08:49:01 +0200 From: Adrien Nader To: Daniel =?utf-8?Q?B=C3=BCnzli?= Cc: Martin DeMello , OCaml List Message-ID: <20160524064901.GA540@notk.org> References: <61A649C2ACD24F2297F2FEC72F2969DF@erratique.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] [ANN] Bos 0.1.0 It's not really fork but Unix.open_process*. The signatures and documentation sum up the issue: val open_process_in : string -> Pervasives.in_channel [...] The command is interpreted by the shell /bin/sh (cf. system). As such, the process command-line needs to be properly quoted. I'm not going to attempt to get the whole logic right so I'll only give keywords for things that can be involved: /bin/sh, $SHELL, quoting for posix shells, quoting for windows command-line (entirely different and 200% ad-hoc over the course of 20 years), cmd.exe, %COMSPEC% (and probably more things). I see the use of a single string as the main issue because it makes supporting the quoting for windows process invocations very difficult (the entry point on windows gets a single string with holds every process argument: argv in main() is actually the result of parsing...). When spawning with a string array or string list, one isn't usually concerned about shell escapes: only special characters such as !, ':' or '&' might matter but the last really do not make sense in this context.. This makes it possible to quote each argument separately before merging everything (with quoting) and call the process (NB: there are also _exec* functions in the Microsoft CRT that could help). I consider moving away from single-string arguments a prerequisite for proper and sane handling of this. One annoyance for ocamlbuild is that it exposes that same API to its plugins. Support for wide-character functions is another change needed for better Windows support in the OCaml ecosystem. If this has to be done with API changes or new APIs, maybe it will be the right time to also remove support (or not offer them at all in the new APIs) for functions that use a single string to spawn functions. Back to the topic, as Gabrial said, there is a number of useful functions in ocamlbuild (see My_Unix for instance iirc) which work fairly well and are therefore risky changes (that's actually pretty funny logic). Nevertheless, I don't think they should stay there. -- Adrien Nader