Created
April 17, 2017 11:19
-
-
Save gpoul/45148076fc0ef84e72fe17eb3d31fa68 to your computer and use it in GitHub Desktop.
Shim for the WSL Ubuntu ledger binary from Win32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using System; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
LaunchCommandLineApp(args); | |
} | |
static void LaunchCommandLineApp(string[] args) | |
{ | |
// Fix the file path provided to make sure it is found | |
string ledgerArgs = System.String.Join(" ", args); | |
ledgerArgs = ledgerArgs.Replace("\\", "/"); | |
ledgerArgs = ledgerArgs.Replace("C:/", "/mnt/c/"); | |
// Call ledger through bash.exe in WSL | |
ProcessStartInfo startInfo = new ProcessStartInfo(); | |
startInfo.CreateNoWindow = false; | |
startInfo.UseShellExecute = false; | |
startInfo.FileName = "bash.exe"; | |
startInfo.WindowStyle = ProcessWindowStyle.Hidden; | |
startInfo.Arguments = "-c 'ledger " + ledgerArgs + "'"; | |
try | |
{ | |
using (Process exeProcess = Process.Start(startInfo)) | |
{ | |
exeProcess.WaitForExit(); | |
} | |
} | |
catch | |
{ | |
// TBD | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment