Skip to content

By default, a source code without extension would get overwritten by executable on *nix

If I have a source code without an extension, say foo, and I forget to specify the output file via -o, GHC will overwrite it with the executable itself after compilation. This occurs only on *nix-like operating systems. Presumably something similar could happen on Windows – fortunately, those who use .exe for source code are probably among the minority.

Minimum example:

#!/bin/sh
echo >foo 'main=undefined'
ghc -x hs foo
less foo     # 'foo' now contains binary data
Trac metadata
Trac field Value
Version 7.8.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by Rufflewind
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information