Running F# scripts in unix without proper file extensions results in strange behaviour
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
In any unix environment with F# 4.0 installed, running
``` bash
echo '#!/usr/bin/env fsharpi\nprintfn "Hello, World!"' > hello
chmod +x hello
./hello
```
Results in the following behaviour:
```
[12:43] eirik@eudoxos: ~/devel> ./hello
F# Interactive for F# 4.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
For help type #help;;
[Loading /home/eirik/devel/hello]
error FS0226: The file extension of '/home/eirik/devel/hello' is not recognized. Source files must have extension .fs, .fsi, .fsx, .fsscript, .ml or .mli.
>
```
While the error message clearly states what the problem is here, I think there are a couple of issues to notice:
- It is common practice to omit file extensions in executables. Perhaps we should consider supporting this in the fsi context?
- An invalid file extension will cause fsi to run in interactive mode, which seems a bit bizarre. It actually took me a while to understand what was going on because of all the text that was being output.
Contributor guide
Assessment
This issue has not been assessed yet.