dotnet / dotnet/fsharp

It is not possible to pass command-line arguments starting with an at-sign to fsx scripts run with "dotnet fsi"

Open
#16,092 8 comments 0 reactions 0 assignees View on GitHub
Area-Documentation
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

Command-line arguments to "dotnet fsi {script}.fsx" that start with "\@" are not taken literally, and are interpreted as an instruction to read the argument value from a file with the name following the "\@".

This behavior is recursive; if the file contents are a single line starting with "\@", then the rest of the line is taken as the name of another file to read, and so on.

This leads to two problems:

1. It does not appear to be possible to pass command-line arguments starting with "\@" to fsx scripts.
2. If cycles exist in files that reference each other with "\@" syntax, the interpreter will loop infinitely if any are passed on the command-line using "\@" syntax.

**Reproduction steps**

Provide the steps required to reproduce the problem:

1. Create script "echo_args.fsx" with content:
`System.Environment.GetCommandLineArgs() |> Seq.iter (printfn "- [%s]")`
2. Create test input files
`echo Contents of test>test`
`echo @loop>loop`
`echo @two>one`
`echo @one>two`
3. Check behavior
`dotnet fsi echo_args.fsx test`
`dotnet fsi echo_args.fsx @test`
`dotnet fsi echo_args.fsx @loop`
`dotnet fsi echo_args.fsx @one`

Unless I have simply missed it, this behavior appears to be undocumented.
I have tried using backslash and "\@\@" to attempt to escape the "\@" character, but neither works.

**Expected behavior**

1. It should be possible to pass a command-line argument to an fsx script starting with "\@".
2. Cycles in files referenced using "\@" syntax should not result in an infinite loop if specified on the command-line.

**Actual behavior**

1. It does not appear to be possible to pass a command-line argument that starts with "\@"
2. Infinite looping occurs if cycles exist in files referenced with "\@"

**Known workarounds**

None at present.

**Related information**
This behavior does not appear to be documented in any of the following documentation:
https://learn.microsoft.com/en-us/dotnet/fsharp/tools/fsharp-interactive/
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet

* Operating system: Windows 10
* .NET Runtime kind: dotnet SDK 7.0.401
* Editing Tools: N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.