caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocamlbuild single quotes causing trouble
@ 2007-06-22 14:53 Andrew Warshaver
  2007-06-22 17:10 ` [Caml-list] " Alain Frisch
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Warshaver @ 2007-06-22 14:53 UTC (permalink / raw)
  To: caml-list

Hi all,

I was trying to compile a project using ocamlbuild with an external 
library located distantly, so I did the following (I am also doing 
preprocessing on the file):

ocamlbuild -libs pcre -cflags -I,~/multi-oc/lib -pp "camlp4o 
~/multi-oc\/lib/pa_type_conv.cmo ~/multi-oc/lib/pa_sexp_conv.cmo" 
live_query.byte

Then ocamlbuild eventually runs the following command:

/usr/local/home/godi310/godi/bin/ocamlc.opt -c -I '~/multi-oc/lib' -pp 
'camlp4o ~/multi-oc/lib/pa_type_conv.cmo 
~/multi-oc/lib/pa_sexp_conv.cmo' -o id.cmi id.mli

and spits the error:

File "id.mli", line 1, characters 0-9:
Unbound module Jane
Command exited with code 2.

I noticed, however, if I remove the single quotes from the command -- 
like this --

/usr/local/home/godi310/godi/bin/ocamlc.opt -c -I ~/multi-oc/lib -pp 
'camlp4o ~/multi-oc/lib/pa_type_conv.cmo 
~/multi-oc/lib/pa_sexp_conv.cmo' -o id.cmi id.mli

it works just fine.  I also discovered that if I don't use the ~ abbrev. 
then everything is happy (although this took me a long time to 
discover!).  Is this a problem with ocamlbuild, or something deeper, or 
perhaps even expected behaviour?

Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] ocamlbuild single quotes causing trouble
  2007-06-22 14:53 ocamlbuild single quotes causing trouble Andrew Warshaver
@ 2007-06-22 17:10 ` Alain Frisch
  2007-06-22 17:46   ` Andrew Warshaver
  0 siblings, 1 reply; 4+ messages in thread
From: Alain Frisch @ 2007-06-22 17:10 UTC (permalink / raw)
  To: Andrew Warshaver; +Cc: caml-list

Andrew Warshaver wrote:
> it works just fine.  I also discovered that if I don't use the ~ abbrev.
> then everything is happy (although this took me a long time to
> discover!).

The shell is responsible to expand ~ before calling the program. If you
quote it, it won't be expanded; this is normal. When you put ~ on
ocamlbuild's command line, as in "-I,~/multi-oc/lib" it is not expanded
either (~ is interpreted only at the beginning of a word on the command
line).

> Is this a problem with ocamlbuild, or something deeper, or
> perhaps even expected behaviour?

Maybe ocamlbuild should support natively options like "-I xxx" (without
quotes), so that xxx will be processed by the shell.

-- Alain


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] ocamlbuild single quotes causing trouble
  2007-06-22 17:10 ` [Caml-list] " Alain Frisch
@ 2007-06-22 17:46   ` Andrew Warshaver
  2007-06-22 20:38     ` Philippe Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Warshaver @ 2007-06-22 17:46 UTC (permalink / raw)
  To: Alain Frisch; +Cc: caml-list


Alain Frisch wrote:
> Andrew Warshaver wrote:
>> it works just fine.  I also discovered that if I don't use the ~ abbrev.
>> then everything is happy (although this took me a long time to
>> discover!).
> 
> The shell is responsible to expand ~ before calling the program. If you
> quote it, it won't be expanded; this is normal. When you put ~ on
> ocamlbuild's command line, as in "-I,~/multi-oc/lib" it is not expanded
> either (~ is interpreted only at the beginning of a word on the command
> line).
> 
Thanks for the explanation.  But is there any reason that ocamlbuild has 
to add the single quotes when transferring the argument to ocamlc?  And, 
if it didn't, would it then work appropriately?

>> Is this a problem with ocamlbuild, or something deeper, or
>> perhaps even expected behaviour?
> 
> Maybe ocamlbuild should support natively options like "-I xxx" (without
> quotes), so that xxx will be processed by the shell.
> 
> -- Alain


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] ocamlbuild single quotes causing trouble
  2007-06-22 17:46   ` Andrew Warshaver
@ 2007-06-22 20:38     ` Philippe Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Philippe Wang @ 2007-06-22 20:38 UTC (permalink / raw)
  To: Andrew Warshaver, ocaml ml

Andrew Warshaver wrote:
>
> Alain Frisch wrote:
>> Andrew Warshaver wrote:
>>> it works just fine.  I also discovered that if I don't use the ~ 
>>> abbrev.
>>> then everything is happy (although this took me a long time to
>>> discover!).
>>
>> The shell is responsible to expand ~ before calling the program. If you
>> quote it, it won't be expanded; this is normal. When you put ~ on
>> ocamlbuild's command line, as in "-I,~/multi-oc/lib" it is not expanded
>> either (~ is interpreted only at the beginning of a word on the command
>> line).
>>
> Thanks for the explanation.  But is there any reason that ocamlbuild 
> has to add the single quotes when transferring the argument to 
> ocamlc?  And, if it didn't, would it then work appropriately?
The quotes are necessary to consider that the block is a single argument.
If you want to remove those quotes, then you have to "guess" what the 
user meant (i.e. guessing where the quotes would have been if they were 
there).
In some cases, it's impossible to guess with a 100% accuracy...

Well, I suggest you to use $HOME instead of ~.
(then you have to use double quotes instead of quotes, so that the shell 
expands $HOME, as the variables inside simple quotes don't expand -- 
well I hope you are not using a too weird shell ;-)


--
  Philippe Wang
    mail[at]philippewang.info


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-22 20:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-22 14:53 ocamlbuild single quotes causing trouble Andrew Warshaver
2007-06-22 17:10 ` [Caml-list] " Alain Frisch
2007-06-22 17:46   ` Andrew Warshaver
2007-06-22 20:38     ` Philippe Wang

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).