caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <oandrieu@nerim.net>
To: Matthieu Dubuget <matthieu.dubuget@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Sys.command and quotes
Date: Tue, 5 May 2009 11:44:43 +0200	[thread overview]
Message-ID: <95513600905050244q3a83696cs3a5fe02d322a1a80@mail.gmail.com> (raw)
In-Reply-To: <49FFFFB5.1090403@gmail.com>

On Tue, May 5, 2009 at 10:58, Matthieu Dubuget
<matthieu.dubuget@gmail.com> wrote:
> Hello,
>
> I have a problem with mingw version of ocaml (compiled by hand, or with
> godi).
>
> 1- Is the following reproducible?
>
> 2- If yes, do you consider this as a bug?
>
> It seems that in "Sys.command s", if the first and the last characters of s
> are '"', they are elided?

that's probably just the Windows command interpreter behaviour.
Sys.command calls the C library system() function which ends up
calling CMD.EXE. This one has an utterly byzantine behavior concerning
quotations marks.

cf. http://technet.microsoft.com/en-us/library/bb490880.aspx

« Processing quotation marks

If you specify /c or /k, cmd processes the remainder of string and
quotation marks are preserved only if all of the following conditions
are met:

    * You do not use /s.
    * You use exactly one set of quotation marks.
    * You do not use any special characters within the quotation marks
(for example: &<>( ) @ ^ |).
    * You use one or more white-space characters within the quotation marks.
    * The string within quotation marks is the name of an executable file.

If the previous conditions are not met, string is processed by
examining the first character to verify whether or not it is an
opening quotation mark. If the first character is an opening quotation
mark, it is stripped along with the closing quotation mark. Any text
following the closing quotation marks is preserved.
»

IIRC a sort of workaround is to always add extra " in your command line:
  go ["\"" ; .... ; "\""]

good luck
-- 
  Olivier


  parent reply	other threads:[~2009-05-05  9:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-05  8:58 Matthieu Dubuget
2009-05-05  9:37 ` [Caml-list] " Francois Pottier
2009-05-05 19:59   ` Matthieu Dubuget
2009-05-05  9:44 ` Olivier Andrieu [this message]
2009-05-05  9:45 ` Sylvain Le Gall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95513600905050244q3a83696cs3a5fe02d322a1a80@mail.gmail.com \
    --to=oandrieu@nerim.net \
    --cc=caml-list@inria.fr \
    --cc=matthieu.dubuget@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).