-
Notifications
You must be signed in to change notification settings - Fork 818
It is not possible to pass command-line arguments starting with an at-sign to fsx scripts run with "dotnet fsi" #16092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This depends on where you run the script from. I am guessing you are trying to run this from powershell - there Usually you could escape it with quotations, like |
Thank you for the response. Powershell can be ruled out; this behavior occurs when running directly from cmd.exe. However, I can confirm that both:
... do successfully pass the argument Are you able to shed any light on the origin of this behavior, and the source code for it? I think "--" is a good workaround for most use-cases, but not all. So to summarize, the remaining issues as I see it are:
|
The response file handling is a feature of the System.CommandLine library that the dotnet CLI is built with. It applies response file handling to every command. Can you try escaping the @ with another @? |
@baronfel Using |
Searching "System.CommandLine library" revealed the following documentation: Althougth this documentation is just over a year old, and suggests that "System.CommandLine" is in "preview"? |
... and now that I know what to look for, running (Although it does not mention @) It probably didn't help me that I was originally using the dotnet 6 SDK, which had a bug that caused |
The -- behavior is a very common CLI usage pattern specifically for this use case - when you must pass through some tokens un-touched to the running program. It's definitely not a hack or workaround, rather it's the established way to communicate intent when there can be ambiguity in the semantics of a CLI application. |
Indeed; this is POSIX behavior. So, from my earlier list of remaining issues:
So, one minor documentation gripe about not spelling-out "@" behavior in "dotnet fsi --help" and https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/fsharp-interactive-options , and everything else is for System.CommandLine. |
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:
Reproduction steps
Provide the steps required to reproduce the problem:
System.Environment.GetCommandLineArgs() |> Seq.iter (printfn "- [%s]")
echo Contents of test>test
echo @loop>loop
echo @two>one
echo @one>two
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
Actual behavior
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
The text was updated successfully, but these errors were encountered: