Skip to content
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

fsx: fix regression that made fsxc misbehave #44

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions fsx/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ 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 Down Expand Up @@ -149,23 +153,29 @@ 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."
)
| _ -> ()

let finalLaunch =
{
Command =
(InjectBinSubfolderInPath maybeUserScriptPath.Value)
.FullName
Arguments = String.Join(" ", userArgs)
}

let finalProc = Process.Execute(finalLaunch, Echo.OutputOnly)
// FIXME: fsx being an F# project instead of a launcher script means that, on
| Some userScriptPath ->
// FIXME: we shouldn't need to use FileInfo below, and in fact it looks
// dangerous because userScriptPath could be a relative path, but relative
// to what? to current dir or to folder where fsx/fsxc is? so I'm not
// sure what's going when creating the FileInfo instance here, but if we
// try to not use FileInfo then we cause a regression, see this PR:
// https://github.com/nblockchain/fsx/pull/44
let userScriptFile = FileInfo userScriptPath

let finalLaunch =
{
Command = (InjectBinSubfolderInPath userScriptFile).FullName
Arguments = String.Join(" ", userArgs)
}

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
2 changes: 1 addition & 1 deletion version.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BaseVersion=0.6.0
BaseVersion=0.6.1
Loading