[Haskell-cafe] Re: HS-Plugins 1.0 chokes on simple test, WinXP GHC-6.6

Iain Alexander ia at stryx.demon.co.uk
Mon Mar 12 21:28:37 EDT 2007

> > I'm running cygwin on WinXP and got a different failure (below) from
> the
> > latest darcs hs-plugins.  Line 11 is right after the TOP definition. 
> Does
> > anyone have a theory about what's going on here? - Conal
> looks like the TOP and GHC_LIB_PATH values are the output of external
> commands, such as ghc --print-libdir, and someone forgot to remove the
> linefeeds from the output before inserting it in the script?

Recent versions of cygwin bash do not by default handle DOS/Windows-style line 
endings well.  See any recent bash release notice on cygwin-announce for 
details, but here are the juicy bits.

According to Eric Blake
volunteer cygwin bash maintainer

4. This version of bash has a cygwin-specific shell option, named "igncr" to 
force bash to ignore \r, independently of cygwin's mount style.  As of bash-
3.2.3-5, it controls regular scripts, command substitution, and sourced files.  
I hope to convince the upstream bash maintainer to accept this patch into the 
future bash 4.0 even on Linux, rather than keeping it a cygwin-specific patch, 
but only time will tell.  There are several ways to activate this option:  

4a. For a single affected script, add this line just after the she-bang:
 (set -o igncr) 2>/dev/null && set -o igncr; # comment is needed

4b. For a single script, invoke bash explicitly with the shopt, as in
'bash -o igncr ./myscript' rather than the simpler './myscript'.

4c. To affect all scripts, export the environment variable BASH_ENV,
pointing to a file that sets the shell option as desired.  Bash will
source this file on startup for every script.

4d. Added in the bash-3.2-2 release: export the environment variable SHELLOPTS 
with igncr included in it.  It is read-only from within bash, but you can set 
it before invoking bash; once in bash, it auto-tracks the current state of 'set 
-o igncr'.  If exported, then all bash child processes inherit the same option 
settings; with the exception added in 3.2.9-11 that certain interactive options 
are not inherited in non-interactive use.  

5. You can also experiment with the IFS variable for controlling how bash will 
treat \r during variable expansion.  
Iain Alexander      ia at stryx.demon.co.uk

More information about the Haskell-Cafe mailing list