Skip to content

Commit

Permalink
WIP try to fix regression
Browse files Browse the repository at this point in the history
Bisected to dd66eb3.
  • Loading branch information
knocte committed Sep 3, 2024
1 parent e21c92b commit 544c267
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions fsx/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ let SplitArgsIntoFsxcArgsAndUserArgs
|> List.ofArray
|> userArgsInternal FsxFsxNotFoundYet List.empty List.empty

let InjectBinSubfolderInPath(userScriptPath: string) =
let InjectBinSubfolderInPath(userScript: FileInfo) =
let userScriptPath = userScript.FullName
if not(userScriptPath.EndsWith ".fsx") then
failwithf "Assertion failed: %s should end with .fsx" userScriptPath
failwithf "Assertion failed: %s should end with .fsx" userScript.FullName

let binPath =
match userScriptPath.LastIndexOf Path.DirectorySeparatorChar with
Expand All @@ -138,6 +139,7 @@ let fsxcArgs, maybeUserScriptPath, userArgs = SplitArgsIntoFsxcArgsAndUserArgs()
let fsxcMainArguments =
match maybeUserScriptPath with
| Some userScriptPath ->
let userScriptFile = FileInfo userScriptPath

Check warning on line 142 in fsx/Program.fs

View workflow job for this annotation

GitHub Actions / windows--dotnet6

The value 'userScriptFile' is unused

Check warning on line 142 in fsx/Program.fs

View workflow job for this annotation

GitHub Actions / windows--dotnet6

The value 'userScriptFile' is unused

Check failure on line 142 in fsx/Program.fs

View workflow job for this annotation

GitHub Actions / windows--dotnet6

The value 'userScriptFile' is unused

Check failure on line 142 in fsx/Program.fs

View workflow job for this annotation

GitHub Actions / windows--dotnet6

The value 'userScriptFile' is unused

Check failure on line 142 in fsx/Program.fs

View workflow job for this annotation

GitHub Actions / windows--dotnet6

The value 'userScriptFile' is unused

Check failure on line 142 in fsx/Program.fs

View workflow job for this annotation

GitHub Actions / windows--dotnet6

The value 'userScriptFile' is unused
Seq.append fsxcArgs (Seq.singleton userScriptPath) |> Seq.toArray
| None -> fsxcArgs |> Seq.toArray

Expand All @@ -149,23 +151,23 @@ match maybeUserScriptPath with
"Compilation of anything that is not an .fsx should have been rejected by fsx"
+ " and shouldn't have reached this point. Please report this bug."
)
| _ -> ()
| Some userScriptPath ->
let userScriptFile = FileInfo userScriptPath
let finalLaunch =
{
Command =
(InjectBinSubfolderInPath userScriptFile).FullName
Arguments = String.Join(" ", userArgs)
}

let finalLaunch =
{
Command =
(InjectBinSubfolderInPath maybeUserScriptPath.Value)
.FullName
Arguments = String.Join(" ", userArgs)
}
let finalProc = Process.Execute(finalLaunch, Echo.OutputOnly)

let finalProc = Process.Execute(finalLaunch, Echo.OutputOnly)
// FIXME: fsx being an F# project instead of a launcher script means that, on
// Windows (and in Unix when installed via 'dotnet tool install fsx'), fsx will be running the user script as
// child process, which may make the memory gains of using fsx instead of fsi/fsharpi
// (as explained in the ReadMe.md file) not as prominent (while in Unix, i.e. Linux and macOS, when the
// tool is not installed via `dotnet tool install fsx`, they still are what ReadMe.md claims because we use a
// bash script which uses 'exec') // TODO: measure measure!
match finalProc.Result with
| Error(exitCode, _errOutput) -> Environment.Exit exitCode
| _ -> Environment.Exit 0
match finalProc.Result with
| Error(exitCode, _errOutput) -> Environment.Exit exitCode
| _ -> Environment.Exit 0

0 comments on commit 544c267

Please sign in to comment.