caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Filename.quote - again
@ 2002-04-14 18:03 Vitaly Lugovsky
  2002-04-15  8:12 ` [Caml-list] " Xavier Leroy
  0 siblings, 1 reply; 14+ messages in thread
From: Vitaly Lugovsky @ 2002-04-14 18:03 UTC (permalink / raw)
  To: xavier.leroy; +Cc: caml-list


 Hi!

 I already reported about Filename.quote bug
(or feature?) in current ocaml cvs. I can't
understand the meaning of the following code:

-----------------------
(* $Id: filename.ml,v 1.25 2002/03/12 16:16:56 xleroy Exp $ *)

let generic_quote quotequote s =
  let l = String.length s in
  let b = Buffer.create (l + 20) in
  Buffer.add_char b '\''; (* HERE!!! *)
  for i = 0 to l - 1 do
    if s.[i] = '\''
    then Buffer.add_string b quotequote
    else Buffer.add_char b  s.[i]
  done;
  Buffer.add_char b '\''; (* AND HERE!!!! *)
  Buffer.contents b
---------------------------

 It makes gcc crazy when you passing linking
options with spaces inside (try to compile
camltk418 for example).


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* [Caml-list] Re: Filename.quote - again
  2002-04-14 18:03 [Caml-list] Filename.quote - again Vitaly Lugovsky
@ 2002-04-15  8:12 ` Xavier Leroy
  2002-04-15 12:49   ` Vitaly Lugovsky
  0 siblings, 1 reply; 14+ messages in thread
From: Xavier Leroy @ 2002-04-15  8:12 UTC (permalink / raw)
  To: Vitaly Lugovsky; +Cc: caml-list

> I can't understand the meaning of the following code:

Filename.quote puts its argument between single quotes:
        foo.ml  -->  'foo.ml'
and if there's a single quote inside the argument, the following is
generated:
        foo'bar --> 'foo'\''bar'
i.e. the ' causes the current quote to be closed, an unquoted \' to be
generated, and a new quote to be opened.  This seems to work fine with
any Unix shell.

>  It makes gcc crazy when you passing linking
> options with spaces inside (try to compile
> camltk418 for example).

Can you provide a more specific bug report?  What is passed to gcc
that gcc doesn't like?

- Xavier Leroy

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* [Caml-list] Re: Filename.quote - again
  2002-04-15  8:12 ` [Caml-list] " Xavier Leroy
@ 2002-04-15 12:49   ` Vitaly Lugovsky
  2002-04-15 13:26     ` Andrej Bauer
  0 siblings, 1 reply; 14+ messages in thread
From: Vitaly Lugovsky @ 2002-04-15 12:49 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: caml-list

On Mon, 15 Apr 2002, Xavier Leroy wrote:

> > I can't understand the meaning of the following code:
> 
> Filename.quote puts its argument between single quotes:
>         foo.ml  -->  'foo.ml'
> and if there's a single quote inside the argument, the following is
> generated:
>         foo'bar --> 'foo'\''bar'

 I can't understand, what is it for?!? We don't have file names with
spaces...

> i.e. the ' causes the current quote to be closed, an unquoted \' to be
> generated, and a new quote to be opened.  This seems to work fine with
> any Unix shell.

 Sure, it works too fine...

> >  It makes gcc crazy when you passing linking
> > options with spaces inside (try to compile
> > camltk418 for example).
> 
> Can you provide a more specific bug report?  What is passed to gcc
> that gcc doesn't like?

(from camltk418)

$ocamlc -custom -linkall -o ocamltktop -I ../support \
    -ccopt -L../support -cclib -lcamltk -ccopt "" \
 -cclib "-ltk8.3 -ltcl8.3 -ldl " -ccopt " -L/usr/X11R6/lib" \
 -cclib " -lSM -lICE -lX11  -lm" \
 toplevellib.cma camltk.cma topmain.cmo
i586-alt-linux-gcc:  -lSM -lICE -lX11  -lm: No such file or directory
i586-alt-linux-gcc:  -lSM -lICE -lX11  -lm: No such file or directory
Error while building custom runtime system

 With '-verbose' option I got something like
gcc ... ' -L/usr/X11R6/lib ' ' -lSM -lICE -lX11  -lm' ...
                             ^^^^^^^^^^^^^^^^^^^^^^^^

 gcc treats this as a file name, not as an options, thanx
to the single quotes.



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Re: Filename.quote - again
  2002-04-15 12:49   ` Vitaly Lugovsky
@ 2002-04-15 13:26     ` Andrej Bauer
  2002-04-15 13:47       ` Vitaly Lugovsky
       [not found]       ` <"from Andrej.Bauer"@andrej.com>
  0 siblings, 2 replies; 14+ messages in thread
From: Andrej Bauer @ 2002-04-15 13:26 UTC (permalink / raw)
  To: caml-list


Vitaly Lugovsky <vsl@ontil.ihep.su> writes:
> $ocamlc -custom -linkall -o ocamltktop -I ../support \
>     -ccopt -L../support -cclib -lcamltk -ccopt "" \
>  -cclib "-ltk8.3 -ltcl8.3 -ldl " -ccopt " -L/usr/X11R6/lib" \
>  -cclib " -lSM -lICE -lX11  -lm" \
>  toplevellib.cma camltk.cma topmain.cmo
> i586-alt-linux-gcc:  -lSM -lICE -lX11  -lm: No such file or directory
> i586-alt-linux-gcc:  -lSM -lICE -lX11  -lm: No such file or directory
> Error while building custom runtime system
> 
>  With '-verbose' option I got something like
> gcc ... ' -L/usr/X11R6/lib ' ' -lSM -lICE -lX11  -lm' ...
>                              ^^^^^^^^^^^^^^^^^^^^^^^^ 
>  gcc treats this as a file name, not as an options, thanx
> to the single quotes.

Instead of using a single -cclib to pass three C libraries at the same
time (which you noted doesn't work), you should use -cclib three
times, once for each library:

camlc -custom -linkall -o ocamltktop -I ../support \
      -ccopt -L../support -cclib -lcamltk -ccopt "" \
      -cclib "-ltk8.3" -cclib "-ltcl8.3" -cclib "-ldl "
      -ccopt "-L/usr/X11R6/lib" \
      -cclib "-lSM" -cclib "-lICE" -cclib "-lX11"  -cclib "-lm" \
      toplevellib.cma camltk.cma topmain.cmo

Since there could be a library with a space or a single quote in its
name, ocaml does the correct thing. How is it supposed to know that
your library is not called "SM -lICE -lX11 -lm"? I admit only a crazy
person would create such a library, but that is irrelevant.

Andrej Bauer
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Re: Filename.quote - again
  2002-04-15 13:26     ` Andrej Bauer
@ 2002-04-15 13:47       ` Vitaly Lugovsky
       [not found]       ` <"from Andrej.Bauer"@andrej.com>
  1 sibling, 0 replies; 14+ messages in thread
From: Vitaly Lugovsky @ 2002-04-15 13:47 UTC (permalink / raw)
  To: Andrej Bauer; +Cc: caml-list

On 15 Apr 2002, Andrej Bauer wrote:

> >  With '-verbose' option I got something like
> > gcc ... ' -L/usr/X11R6/lib ' ' -lSM -lICE -lX11  -lm' ...
> >                              ^^^^^^^^^^^^^^^^^^^^^^^^ 
> >  gcc treats this as a file name, not as an options, thanx
> > to the single quotes.
> 
> Instead of using a single -cclib to pass three C libraries at the same
> time (which you noted doesn't work), you should use -cclib three
> times, once for each library:

 No way. I have the same results with it... ocamlc tries to pass
all libraries in the one QUOTED string. And, there is no
need in that quotation - so, it'll be better to remove it.

> Since there could be a library with a space or a single quote in its
> name, ocaml does the correct thing.

 It'll be better to quote a space '\ ' just like \'...

> How is it supposed to know that
> your library is not called "SM -lICE -lX11 -lm"? I admit only a crazy
> person would create such a library, but that is irrelevant.

 I think, it'll be better to forbid this. We don't know how external
linkers will treat this options - as file name, as option, as a space
separated options...


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* [Caml-list] command arguments sticking together
       [not found]       ` <"from Andrej.Bauer"@andrej.com>
@ 2002-04-19  5:58         ` Brock
  2002-04-19  9:08           ` Jérôme Marant
  2002-04-19  9:22           ` [Caml-list] command arguments sticking together Jacques Garrigue
  0 siblings, 2 replies; 14+ messages in thread
From: Brock @ 2002-04-19  5:58 UTC (permalink / raw)
  To: caml-list


I am attempting to write an ocaml program which acts as a script when a data
file for it starts with

#!/myscript option1 option2 ...

The problem is that I am using the included Arg module to parse the arguments,
but when myscript is called it only sees one argument consisting of all the
arguments stuffed together... which the Arg routines don't care for much.

So does anyone have any ideas to work around this?

--Brock
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] command arguments sticking together
  2002-04-19  5:58         ` [Caml-list] command arguments sticking together Brock
@ 2002-04-19  9:08           ` Jérôme Marant
  2002-04-19 10:01             ` [Caml-list] Prerelease - Announce ocaml-swig Benedikt Grundmann
  2002-04-19  9:22           ` [Caml-list] command arguments sticking together Jacques Garrigue
  1 sibling, 1 reply; 14+ messages in thread
From: Jérôme Marant @ 2002-04-19  9:08 UTC (permalink / raw)
  To: caml-list

On Fri, Apr 19, 2002 at 05:58:57AM +0000, Brock wrote:
> 
> I am attempting to write an ocaml program which acts as a script when a data
> file for it starts with
> 
> #!/myscript option1 option2 ...
> 
> The problem is that I am using the included Arg module to parse the arguments,
> but when myscript is called it only sees one argument consisting of all the
> arguments stuffed together... which the Arg routines don't care for much.
> 
> So does anyone have any ideas to work around this?

  Is the Sys.argv array not enough for you?

-- 
Jérôme Marant
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] command arguments sticking together
  2002-04-19  5:58         ` [Caml-list] command arguments sticking together Brock
  2002-04-19  9:08           ` Jérôme Marant
@ 2002-04-19  9:22           ` Jacques Garrigue
  2002-04-19 12:21             ` Florian Hars
  1 sibling, 1 reply; 14+ messages in thread
From: Jacques Garrigue @ 2002-04-19  9:22 UTC (permalink / raw)
  To: rbw3; +Cc: caml-list

> I am attempting to write an ocaml program which acts as a script when a data
> file for it starts with
> 
> #!/myscript option1 option2 ...
> 
> The problem is that I am using the included Arg module to parse the arguments,
> but when myscript is called it only sees one argument consisting of all the
> arguments stuffed together... which the Arg routines don't care for much.

Could you explain a bit more what is your problem?
What is this /myscript? and these options? how do you use it?
If myscript is a bytecode non-custom exexcutable, then you may run into
problems, since you have trampolined #!s, which usually doesn't work
anyway.

       Jacques Garrigue
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* [Caml-list] Prerelease - Announce ocaml-swig
  2002-04-19  9:08           ` Jérôme Marant
@ 2002-04-19 10:01             ` Benedikt Grundmann
  0 siblings, 0 replies; 14+ messages in thread
From: Benedikt Grundmann @ 2002-04-19 10:01 UTC (permalink / raw)
  To: Jérôme Marant; +Cc: caml-list

Hi all,

I just wanted to inform you that I'm writing an ocaml - module for SWIG.  It
will definitly take some more time until I can publish it, but nevertheless
I'm on it.  For those of you who don't know SWIG have a look at
http://www.swig.org.  I guess I can publish the first version -- which will not support 
C++ class wrapping -- in the middle of may.  If you have any suggestions to
make, or know of any shortcomings / pitfalls of the current C/C++ interface
generators for ocaml which you don't want to see inside swig-ocaml please tell
me :-).


Happy coding,

Bene

P.S:

swig-ocaml will definitely support C++, but first things first :-)

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] command arguments sticking together
  2002-04-19  9:22           ` [Caml-list] command arguments sticking together Jacques Garrigue
@ 2002-04-19 12:21             ` Florian Hars
  2002-04-19 13:01               ` Christopher Quinn
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Hars @ 2002-04-19 12:21 UTC (permalink / raw)
  To: Jacques Garrigue; +Cc: rbw3, caml-list

begin  Jacques Garrigue quote:
> > #!/myscript option1 option2 ...
> > 
> > The problem is that I am using the included Arg module to parse the arguments,
> > but when myscript is called it only sees one argument consisting of all the
> > arguments stuffed together... which the Arg routines don't care for much.
>
> Could you explain a bit more what is your problem?

His problem is that he is using Unix or a shell that behaves as
a Unix-shell:

       If the program is a file beginning with #!, the  remainder
       of  the  first  line specifies an interpreter for the pro­
       gram.  The shell executes  the  specified  interpreter  on
       operating  systems that do not handle this executable for­
       mat themselves.  The arguments to the interpreter  consist
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       of  a  single  optional argument following the interpreter
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
       name on the first line of the  program,  followed  by  the
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       name of the program, followed by the command arguments, if
       any.

This is from the bash man page, but other shells should do the same thing, 
and it is the normal behaviour for #!-scripts under Unix.

Yours, Florian.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] command arguments sticking together
  2002-04-19 12:21             ` Florian Hars
@ 2002-04-19 13:01               ` Christopher Quinn
  2002-04-19 13:33                 ` Christopher Quinn
  0 siblings, 1 reply; 14+ messages in thread
From: Christopher Quinn @ 2002-04-19 13:01 UTC (permalink / raw)
  Cc: caml-list

Here's a trick I found amongst Gerd Stolpmann's goodies.

-------------------------
! /bin/sh
# (*
exec ocaml "$0" "$@"
*)
directory ".";; (* or some other directive *)

Array.iteri
   (fun i arg ->
     print_endline ("[" ^ string_of_int i ^
                    "] " ^ arg)
   )
   Sys.argv



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] command arguments sticking together
  2002-04-19 13:01               ` Christopher Quinn
@ 2002-04-19 13:33                 ` Christopher Quinn
       [not found]                   ` <"from cq"@htec.demon.co.uk>
  0 siblings, 1 reply; 14+ messages in thread
From: Christopher Quinn @ 2002-04-19 13:33 UTC (permalink / raw)
  Cc: caml-list

What I meant is actually:

#!/bin/sh
# (*
exec myscript a b c ....
*)
caml code...


Christopher Quinn wrote:
> Here's a trick I found amongst Gerd Stolpmann's goodies.
> 
> -------------------------
> ! /bin/sh
> # (*
> exec ocaml "$0" "$@"
> *)
> directory ".";; (* or some other directive *)
> 
> Array.iteri
>   (fun i arg ->
>     print_endline ("[" ^ string_of_int i ^
>                    "] " ^ arg)
>   )
>   Sys.argv
> 

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] command arguments sticking together
       [not found]                   ` <"from cq"@htec.demon.co.uk>
@ 2002-04-19 19:39                     ` Brock
  2002-04-20 11:09                       ` Alain Frisch
  0 siblings, 1 reply; 14+ messages in thread
From: Brock @ 2002-04-19 19:39 UTC (permalink / raw)
  To: Christopher Quinn; +Cc: caml-list

This is getting close to what I need, and indeed solves the
multiple-arguments-stuck-into-a-single-argument problem. What I'm trying to do
is take the program mhtml (which is written in caml) and allow it to be used as
a script interpreter for MacroHTML. The body of such a script could be
something as simple as:

#!/usr/bin/mhtml -I /path/to/include/files
<h1>Hello!</h1>

And the idea is that the body of the script should be passed to mhtml through
stdin, just like with the other interpreters. The problem I'm having with the
suggested solution is that mhtml is not getting the rest of the file through
stdin like I expect it to. I tried to do this:

#!/bin/sh
exec mhtml arg1 arg2 arg3 ...
data...

but mhtml is not getting the data, instead mhtml is trying to get input from
the real stdin. I tried to make a sort of wrapper script but have been
unsuccesfull so far... the wrapper looked like this:

#!/bin/sh
exec mhtml $@

And then the body of the .mhtml file I want interpreted would look like:
#!/path/to/wrapper -I /path/to/include/files
<h1>hello</h1>

But then I get the shell trying to interpret the data part (the html stuff) of
the file! Any tips would be appreciated. Possibly a better solution would be to
get ocaml to parse the arguments even if they are all stuck together?

--Brock

On 2002.04.19.14.33, Christopher Quinn wrote:
|What I meant is actually:
|
|#!/bin/sh
|# (*
|exec myscript a b c ....
|*)
|caml code...
...
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] command arguments sticking together
  2002-04-19 19:39                     ` Brock
@ 2002-04-20 11:09                       ` Alain Frisch
  0 siblings, 0 replies; 14+ messages in thread
From: Alain Frisch @ 2002-04-20 11:09 UTC (permalink / raw)
  To: Brock; +Cc: Christopher Quinn, caml-list

On Fri, 19 Apr 2002, Brock wrote:

> This is getting close to what I need, and indeed solves the
> multiple-arguments-stuck-into-a-single-argument problem. What I'm trying to do
> is take the program mhtml (which is written in caml) and allow it to be used as
> a script interpreter for MacroHTML. The body of such a script could be
> something as simple as:
>
> #!/usr/bin/mhtml -I /path/to/include/files
> <h1>Hello!</h1>
>
> And the idea is that the body of the script should be passed to mhtml through
> stdin, just like with the other interpreters.

No, this is not the way Unix works: the file is not dumped to the
interpreter stdin, but the script filename is added to the interpreter
command line.

-- Alain

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-04-20 11:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-14 18:03 [Caml-list] Filename.quote - again Vitaly Lugovsky
2002-04-15  8:12 ` [Caml-list] " Xavier Leroy
2002-04-15 12:49   ` Vitaly Lugovsky
2002-04-15 13:26     ` Andrej Bauer
2002-04-15 13:47       ` Vitaly Lugovsky
     [not found]       ` <"from Andrej.Bauer"@andrej.com>
2002-04-19  5:58         ` [Caml-list] command arguments sticking together Brock
2002-04-19  9:08           ` Jérôme Marant
2002-04-19 10:01             ` [Caml-list] Prerelease - Announce ocaml-swig Benedikt Grundmann
2002-04-19  9:22           ` [Caml-list] command arguments sticking together Jacques Garrigue
2002-04-19 12:21             ` Florian Hars
2002-04-19 13:01               ` Christopher Quinn
2002-04-19 13:33                 ` Christopher Quinn
     [not found]                   ` <"from cq"@htec.demon.co.uk>
2002-04-19 19:39                     ` Brock
2002-04-20 11:09                       ` Alain Frisch

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