Re: [Haskell-cafe] GHC RTS question
* Artyom Kazak [2010-02-24 10:23:07+0200] > 2010/2/24 Brandon S. Allbery KF8NH : > > On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: > >> > >> * Anthony Cowley [2010-02-21 14:15:00-0500] > >>> > >>> #! /usr/bin/env bash > >>> ./prog --RTS $* > >> > >> ./prog --RTS "$@" > >> > >> Otherwise it will work wrong if arguments contain quoted field > >> separators (e.g. spaces). > > > > > > #! /bin/sh > > ./prog --RTS ${1+"$@"} > > > > The longer specification above should work with whatever /bin/sh is around, > > whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, > > Debian/Ubuntu dash, etc. > > > > And with Windows, of course :) Haskell is cross-platform, isn't it? Haskell is a language, it does not have any notion of platform. It has several implementations, which may or may not be cross-platform. (OP asked specifically about ghc, which supports a number of platforms, including Windows.) Here we talk not about ghc itself, but about POSIX shell interpreter, which is available on every POSIX-compliant operating system. Windows (out of the box) lacks implementation of POSIX shell. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
2010/2/24 Brandon S. Allbery KF8NH : > On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: >> >> * Anthony Cowley [2010-02-21 14:15:00-0500] >>> >>> #! /usr/bin/env bash >>> ./prog --RTS $* >> >> ./prog --RTS "$@" >> >> Otherwise it will work wrong if arguments contain quoted field >> separators (e.g. spaces). > > > #! /bin/sh > ./prog --RTS ${1+"$@"} > > The longer specification above should work with whatever /bin/sh is around, > whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, > Debian/Ubuntu dash, etc. > And with Windows, of course :) Haskell is cross-platform, isn't it? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: * Anthony Cowley [2010-02-21 14:15:00-0500] #! /usr/bin/env bash ./prog --RTS $* ./prog --RTS "$@" Otherwise it will work wrong if arguments contain quoted field separators (e.g. spaces). #! /bin/sh ./prog --RTS ${1+"$@"} The longer specification above should work with whatever /bin/sh is around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, Debian/Ubuntu dash, etc. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
* Anthony Cowley [2010-02-21 14:15:00-0500] > On Sun, Feb 21, 2010 at 1:58 PM, Artyom Kazak wrote: > > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But > > I want the output to be equal to the input IN ALL CASES, without any > > quotes, additional options, etc. I want all the command line to go to > > my program. How can I do it? (The only way I know now - hacking the > > GHC. If there are no other ways, I'll do it.) > > How about a wrapper script? Something like, > > #! /usr/bin/env bash > ./prog --RTS $* > > Just use that as the front-end to your Haskell program. If you want Haskell program to get exactly the same arguments that were passed to the wrapper, use ./prog --RTS "$@" Otherwise it will work wrong if arguments contain quoted field separators (e.g. spaces). -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
2010/2/22 Ivan Miljenovic : > On 22 February 2010 10:55, Lennart Augustsson wrote: >> Supply a fix for the problem, and it will probably get included. >> There has probably been little demand for this feature so far. > > But it is a little bit weird where if you have an application that you > release into production (which, admittedly, I've never done), then end > users are able to fiddle with settings which they shouldnt' really > touch (though there's not really that much that I can see that they'd > be able to do wrong with just RTS settings...). Isn't the same situation with java, or even with any application using some config files, or with dynamic libraries ? Cheers, Thu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
On 22 February 2010 10:55, Lennart Augustsson wrote: > Supply a fix for the problem, and it will probably get included. > There has probably been little demand for this feature so far. But it is a little bit weird where if you have an application that you release into production (which, admittedly, I've never done), then end users are able to fiddle with settings which they shouldnt' really touch (though there's not really that much that I can see that they'd be able to do wrong with just RTS settings...). -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com Joan Crawford - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." - http://www.brainyquote.com/quotes/authors/j/joan_crawford.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
Supply a fix for the problem, and it will probably get included. There has probably been little demand for this feature so far. -- Lennart On Sun, Feb 21, 2010 at 10:21 PM, Ben Millwood wrote: > On Sun, Feb 21, 2010 at 7:10 PM, Max Bolingbroke > wrote: >> >> You might be able to get somewhere by writing a custom "main" function >> in C and linking it in. According to >> http://haskell.org/ghc/docs/latest/html/users_guide/options-phases.html >> if a lib specified with the -l option during compilation contains a >> "main", that will be used in preference to the one from HSrts. >> > > I think the neater way of doing this would be to use the FFI, with a > foreign export declaration making your haskell main available to a > wrapper C file, which would then initialise the RTS with a > slightly-modified argc and argv. > See http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html > for details on how to do that. > > I also think it's strange, though, that adding RTS hooks is not > optional. GHC should support some method of disabling them, in my > opinion. > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
On Sun, Feb 21, 2010 at 7:10 PM, Max Bolingbroke wrote: > > You might be able to get somewhere by writing a custom "main" function > in C and linking it in. According to > http://haskell.org/ghc/docs/latest/html/users_guide/options-phases.html > if a lib specified with the -l option during compilation contains a > "main", that will be used in preference to the one from HSrts. > I think the neater way of doing this would be to use the FFI, with a foreign export declaration making your haskell main available to a wrapper C file, which would then initialise the RTS with a slightly-modified argc and argv. See http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html for details on how to do that. I also think it's strange, though, that adding RTS hooks is not optional. GHC should support some method of disabling them, in my opinion. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
Am Sonntag 21 Februar 2010 19:58:12 schrieb Artyom Kazak: > 2010/2/21 Daniel Fischer : > > Am Sonntag 21 Februar 2010 18:20:43 schrieb Artyom Kazak: > >> > Enclose it in double quotes (perhaps single quotes would also work) > >> > >> No, I want my program to work the same way as UNIX "echo" does. > >> Without any double quotes. > > > > Okay, what about > > > > "If you absolutely positively want all the rest of the options in a > > command line to go to the program (and not the RTS), use a ––RTS." > > > > $ ./prog +RTS --RTS +RTS > > > > ? (BTW, enclosing in quotes doesn't work anyway if the argument > > consists *only* of "+RTS", same as with echo, echo "-e" doesn't output > > '-e' either). > > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But > I want the output to be equal to the input IN ALL CASES, without any > quotes, additional options, etc. I want all the command line to go to > my program. How can I do it? (The only way I know now - hacking the > GHC. If there are no other ways, I'll do it.) Shell wrapper: $ cat wopTest ./opTest +RTS --RTS $@ $ cat opTest.hs module Main (main) where import System.Environment (getArgs) main = mapM_ print =<< getArgs $ ./wopTest +RTS -sstderr -RTS "+RTS" "-sstderr" "-RTS" Other than that, hacking GHC is the only way I can think of either, since looking for RTS-options is a fixed (and generally necessary) part of the RTS. But why do you want that behaviour so much that you'd be willing to hack GHC? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
On Sun, Feb 21, 2010 at 1:58 PM, Artyom Kazak wrote: > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But > I want the output to be equal to the input IN ALL CASES, without any > quotes, additional options, etc. I want all the command line to go to > my program. How can I do it? (The only way I know now - hacking the > GHC. If there are no other ways, I'll do it.) How about a wrapper script? Something like, #! /usr/bin/env bash ./prog --RTS $* Just use that as the front-end to your Haskell program. Anthony ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
On 21 February 2010 18:58, Artyom Kazak wrote: > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But > I want the output to be equal to the input IN ALL CASES, without any > quotes, additional options, etc. I want all the command line to go to > my program. How can I do it? (The only way I know now - hacking the > GHC. If there are no other ways, I'll do it.) You might be able to get somewhere by writing a custom "main" function in C and linking it in. According to http://haskell.org/ghc/docs/latest/html/users_guide/options-phases.html if a lib specified with the -l option during compilation contains a "main", that will be used in preference to the one from HSrts. You could presumably just extend argv with the "+RTS" "--RTS" entries and then call into the one from HSrts, so this might even be quite easy. Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
2010/2/21 Daniel Fischer : > Am Sonntag 21 Februar 2010 18:20:43 schrieb Artyom Kazak: >> > Enclose it in double quotes (perhaps single quotes would also work) >> >> No, I want my program to work the same way as UNIX "echo" does. >> Without any double quotes. > > Okay, what about > > "If you absolutely positively want all the rest of the options in a command > line to go to the program (and not the RTS), use a ––RTS." > > $ ./prog +RTS --RTS +RTS > > ? (BTW, enclosing in quotes doesn't work anyway if the argument consists > *only* of "+RTS", same as with echo, echo "-e" doesn't output '-e' either). > > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But I want the output to be equal to the input IN ALL CASES, without any quotes, additional options, etc. I want all the command line to go to my program. How can I do it? (The only way I know now - hacking the GHC. If there are no other ways, I'll do it.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
Am Sonntag 21 Februar 2010 18:20:43 schrieb Artyom Kazak: > > Enclose it in double quotes (perhaps single quotes would also work) > > No, I want my program to work the same way as UNIX "echo" does. > Without any double quotes. Okay, what about "If you absolutely positively want all the rest of the options in a command line to go to the program (and not the RTS), use a ––RTS." $ ./prog +RTS --RTS +RTS ? (BTW, enclosing in quotes doesn't work anyway if the argument consists *only* of "+RTS", same as with echo, echo "-e" doesn't output '-e' either). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
> Enclose it in double quotes (perhaps single quotes would also work) No, I want my program to work the same way as UNIX "echo" does. Without any double quotes. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
Am Sonntag 21 Februar 2010 16:45:22 schrieb Artyom Kazak: > Hello everybody! > I want to write a little program, that will receive a string as > command-line argument and write it in the file. But if this string > contains '+RTS', GHC runtime won't pass the rest of the string to my > program. > What can I do to avoid this? Enclose it in double quotes (perhaps single quotes would also work) $ ./proggy "argwith +RTS in" harmlessArg otherHarmlessArg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
On Sun, Feb 21, 2010 at 05:45:22PM +0200, Artyom Kazak wrote: > Hello everybody! > I want to write a little program, that will receive a string as command-line > argument and write it in the file. But if this string contains '+RTS', GHC > runtime won't pass the rest of the string to my program. > What can I do to avoid this? Use -RTS, as in $ ghc -V The Glorious Glasgow Haskell Compilation System, version 6.10.4 $ ghc +RTS -V ghc: no input files Usage: For basic information, try the `--help' option. $ ghc +RTS -RTS -V The Glorious Glasgow Haskell Compilation System, version 6.10.4 -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GHC RTS question
Hello everybody! I want to write a little program, that will receive a string as command-line argument and write it in the file. But if this string contains '+RTS', GHC runtime won't pass the rest of the string to my program. What can I do to avoid this? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe