# "#!..." (Re[2]: cabal configure screw-up)

Frederik Eaton frederik at a5.repetae.net
Fri Aug 26 21:36:07 EDT 2005

On Fri, Aug 26, 2005 at 09:37:20AM +0300, Krasimir Angelov wrote:
> 2005/8/25, Ross Paterson <ross at soi.city.ac.uk>:
> > On Thu, Aug 25, 2005 at 12:03:25PM +0400, Bulat Ziganshin wrote:
> > > Thursday, August 25, 2005, 7:37:39 AM, Frederik Eaton wrote:
> > > FE> I guess you could try to parse the "#!" line if MinGW is detected? ...
> > > FE> Anyway, it would seem that support for running "#!" scripts from
> > > FE> Haskell is a problem which is much more general than Cabal and should
> > > FE> be solved more centrally, like in the standard libraries.
> > >
> > > i strongly agree. ignoring of first line if it starts from "#" must
> >
> > I think Frederik is suggesting that under Windows, System.Cmd.rawSystem
> > and friends should examine the start of the file it is asked to execute,
> > looking for #! and then try to simulate Unix behaviour.  That might help
> > some things, but it won't always work, so may not be worth it.
> >
> > Haskell implementations already ignore lines starting with # if the file
> > is a literate script.
>
> It isn't so easy to simulate #! behaviour in rawSystem because the
> file path after #! is in Unix style. Cygwin keeps the mapping between
> Unix style paths and the native Windows paths. Usually /usr/bin/sh is
> mapped to something like c:\cygwin\bin\sh.exe. All executables which
> are compiled with cygwin.dll runtime library are working with Unix
> paths which are silently mapped to native paths. All GHC compiled
> executables are linked to the native msvcrt.dll runtime library  so
> they understands only the native paths. I don't think that rawSystem
> should try to emulate Unix behaviour.

Then maybe Cabal needs to be linked to cygwin.dll? I don't know
anything about Cygwin, or MinGW, or what the difference is between the
two, but if a program written in Haskell running *within* Cygwin can't
execute a #! script using rawSystem then something is wrong.

Frederik

--
http://ofb.net/~frederik/