Soegtrop, Michael
2016-10-06 13:39:17 UTC
Dear OCaml users and developers,
I looked into the fact that ocamlbuild requires bash/cygwin to run. Actually it does very little use of bash and I think cmd + ln + rm would work quite well.
From comments in various list I understood that people had issues with escaping for cmd. I agree that this is a bit nasty, but not rocket science either. I guess the main issue is that for cmd not only space and tab are command argument separators, but also equal (=), comma (,) and semicolon (;). So for cmd a=b,c;d is the same as a b c d which is the same as a , = , b =;= c==d. Essentially cmd treats unquoted pieces as sed 's/[\t =,;]+/ /g'. If a name contains any of these characters, one has to quote it for cmd, but not for bash. Since = and , are not that uncommon in file names, I guess this resulted in issues.
BUT cmd splits the command line only into command names, complete argument lists and file names for redirection. That is if you call e.g. ocamlc, cmd just replaces shell variables and extracts the executable name, but does not split up the argument list into individual pieces. bash on Windows does this neither, because (afaik) Windows has at the lowest level no mechanism to pass individual arguments to an executable. The command gets a string and splitting this string and even globing is the business of the executable. So it is rather odd that this behaves substantially different for bash and for cmd. The only thing which needs to be quoted properly are command names and file names of redirections.
There might be issue with shell special characters. There are those which are not allowed in file names "\/:*?<>| and those allowed in filenames &(). I guess those not allowed in filenames don't need any special treatment, since one can't do that much with them except their special shell use. The other 3 one should be escape with ^. There is no way to quote shell special characters with cmd - they must be escaped with ^.
The only real issue is that some people seem to use build rules with "real" bash stuff in it - well if you do this I guess you anyway have a cygwin around.
So I wonder if it would be appreciated by the community to have an ocamlbuild (e.g. as a configure option) which uses cmd instead of bash. I think if one does the escaping properly, this should be good for the large majority of projects out there.
Ocamlc seems to run fine without cygwin, but I didn't test other tools like ocamllex or menhir as yet. Are there known issues?
Best regards,
Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
I looked into the fact that ocamlbuild requires bash/cygwin to run. Actually it does very little use of bash and I think cmd + ln + rm would work quite well.
From comments in various list I understood that people had issues with escaping for cmd. I agree that this is a bit nasty, but not rocket science either. I guess the main issue is that for cmd not only space and tab are command argument separators, but also equal (=), comma (,) and semicolon (;). So for cmd a=b,c;d is the same as a b c d which is the same as a , = , b =;= c==d. Essentially cmd treats unquoted pieces as sed 's/[\t =,;]+/ /g'. If a name contains any of these characters, one has to quote it for cmd, but not for bash. Since = and , are not that uncommon in file names, I guess this resulted in issues.
BUT cmd splits the command line only into command names, complete argument lists and file names for redirection. That is if you call e.g. ocamlc, cmd just replaces shell variables and extracts the executable name, but does not split up the argument list into individual pieces. bash on Windows does this neither, because (afaik) Windows has at the lowest level no mechanism to pass individual arguments to an executable. The command gets a string and splitting this string and even globing is the business of the executable. So it is rather odd that this behaves substantially different for bash and for cmd. The only thing which needs to be quoted properly are command names and file names of redirections.
There might be issue with shell special characters. There are those which are not allowed in file names "\/:*?<>| and those allowed in filenames &(). I guess those not allowed in filenames don't need any special treatment, since one can't do that much with them except their special shell use. The other 3 one should be escape with ^. There is no way to quote shell special characters with cmd - they must be escaped with ^.
The only real issue is that some people seem to use build rules with "real" bash stuff in it - well if you do this I guess you anyway have a cygwin around.
So I wonder if it would be appreciated by the community to have an ocamlbuild (e.g. as a configure option) which uses cmd instead of bash. I think if one does the escaping properly, this should be good for the large majority of projects out there.
Ocamlc seems to run fine without cygwin, but I didn't test other tools like ocamllex or menhir as yet. Are there known issues?
Best regards,
Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
--
Caml-list mailing list. Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
Caml-list mailing list. Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs