@@ -586,8 +586,6 @@ let internal directoryName (s:string) =
586586 | res -> if res = " " then " ." else res
587587
588588
589-
590-
591589//----------------------------------------------------------------------------
592590// cmd line - state for options
593591//----------------------------------------------------------------------------
@@ -620,13 +618,29 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
620618 let isInteractiveServer () = fsiServerName <> " "
621619 let recordExplicitArg arg = explicitArgs <- explicitArgs @ [ arg]
622620
623- let executableFileName =
624- lazy
625- match tcConfigB.exename with
626- | Some s -> s
627- | None ->
628- let currentProcess = System.Diagnostics.Process.GetCurrentProcess()
629- Path.GetFileName( currentProcess.MainModule.FileName)
621+ let executableFileNameWithoutExtension =
622+ lazy
623+ let getFsiCommandLine () =
624+ let fileNameWithoutExtension path = Path.GetFileNameWithoutExtension( path)
625+
626+ let currentProcess = Process.GetCurrentProcess()
627+ let processFileName = fileNameWithoutExtension currentProcess.MainModule.FileName
628+
629+ let commandLineExecutableFileName =
630+ try fileNameWithoutExtension ( Environment.GetCommandLineArgs().[ 0 ])
631+ with _ -> " "
632+
633+ let stringComparison =
634+ match Environment.OSVersion.Platform with
635+ | PlatformID.MacOSX
636+ | PlatformID.Unix -> StringComparison.Ordinal
637+ | _ -> StringComparison.OrdinalIgnoreCase
638+
639+ if String.Compare( processFileName, commandLineExecutableFileName, stringComparison) = 0
640+ then processFileName
641+ else sprintf " %s %s " processFileName commandLineExecutableFileName
642+
643+ tcConfigB.exename |> Option.defaultWith getFsiCommandLine
630644
631645
632646 // Additional fsi options are list below.
@@ -635,7 +649,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
635649 let displayHelpFsi tcConfigB ( blocks : CompilerOptionBlock list ) =
636650 DisplayBannerText tcConfigB;
637651 fprintfn fsiConsoleOutput.Out " "
638- fprintfn fsiConsoleOutput.Out " %s " ( FSIstrings.SR.fsiUsage( executableFileName .Value))
652+ fprintfn fsiConsoleOutput.Out " %s " ( FSIstrings.SR.fsiUsage( executableFileNameWithoutExtension .Value))
639653 PrintCompilerOptionBlocks blocks
640654 exit 0
641655
@@ -761,7 +775,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s
761775 fsiConsoleOutput.uprintfn " %s " ( FSIstrings.SR.fsiBanner3())
762776
763777 member __.ShowHelp () =
764- let helpLine = sprintf " %s --help" ( Path.GetFileNameWithoutExtension executableFileName. Value)
778+ let helpLine = sprintf " %s --help" executableFileNameWithoutExtension. Value
765779
766780 fsiConsoleOutput.uprintfn " "
767781 fsiConsoleOutput.uprintfnn " %s " ( FSIstrings.SR.fsiIntroTextHeader1directives());
0 commit comments