<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace GitWrap
{
    class Program
    {
        private static Random random = new Random();

        static void Main(string[] args)
        {
            // Bash.exe
            ProcessStartInfo bashInfo = new ProcessStartInfo();
            bashInfo.FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
            @"System32\bash.exe");

            // Loop through args and pass them to git executable
            String argsString = "-c \"git";
            for (int i = 0; i < args.Length; i++)
            {
                // Translate directory structure.
                // Use regex to translate drive letters.
                string pattern = @"(\D):\\";
                String argstr = args[i];
                foreach (Match match in Regex.Matches(args[i], pattern, RegexOptions.IgnoreCase))
                {
                    string driveLetter = match.Groups[1].ToString();
                    argstr = Regex.Replace(args[i], pattern, "/mnt/" + driveLetter.ToLower() + "/");
                }
               
                // Convert Windows path to Linux style paths
                argstr = argstr.Replace("\\", "/");
                argsString += " " + argstr;
            }

            // Append quotation to close of the argument supplied to bash.exe
            argsString += "\"";

            bashInfo.Arguments = argsString;
            bashInfo.UseShellExecute = false;
            bashInfo.RedirectStandardOutput = true;
            bashInfo.RedirectStandardError = true;
            bashInfo.CreateNoWindow = true;

            var proc = new Process
            {
                StartInfo = bashInfo
            };

            proc.OutputDataReceived += CaptureOutput;
            proc.ErrorDataReceived += CaptureError;

            proc.Start();
            proc.BeginOutputReadLine();
            proc.BeginErrorReadLine();
            proc.WaitForExit();
        }

        static void CaptureOutput(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != null)
            {
                String outputString = e.Data + Environment.NewLine;
                Console.Write(outputString);
            }
        }

        static void CaptureError(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != null)
            {
                String outputString = e.Data + Environment.NewLine;
                Console.Write(outputString);
            }
        }
    }
}<commit_msg>Cleaned up code. Added check to verify bash.exe exists.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace GitWrap
{
    class Program
    {
        private static Random random = new Random();

        static void Main(string[] args)
        {
            executeGitWithArgs(getBashPath(), args);   
        }

        static Boolean executeGitWithArgs(String bashPath, string[] args)
        {
            if (!File.Exists(bashPath))
            {
                Console.Write("[-] Error: Bash.exe not found.");
                return false;
            }

            ProcessStartInfo bashInfo = new ProcessStartInfo();
            bashInfo.FileName = bashPath;

            // Loop through args and pass them to git executable
            String argsString = "-c \"git";
            for (int i = 0; i < args.Length; i++)
            {
                // Translate directory structure.
                // Use regex to translate drive letters.
                string pattern = @"(\D):\\";
                String argstr = args[i];
                foreach (Match match in Regex.Matches(args[i], pattern, RegexOptions.IgnoreCase))
                {
                    string driveLetter = match.Groups[1].ToString();
                    argstr = Regex.Replace(args[i], pattern, "/mnt/" + driveLetter.ToLower() + "/");
                }

                // Convert Windows path to Linux style paths
                argstr = argstr.Replace("\\", "/");
                argsString += " " + argstr;
            }

            // Append quotation to close of the argument supplied to bash.exe
            argsString += "\"";

            bashInfo.Arguments = argsString;
            bashInfo.UseShellExecute = false;
            bashInfo.RedirectStandardOutput = true;
            bashInfo.RedirectStandardError = true;
            bashInfo.CreateNoWindow = true;

            var proc = new Process
            {
                StartInfo = bashInfo
            };

            proc.OutputDataReceived += CaptureOutput;
            proc.ErrorDataReceived += CaptureError;

            proc.Start();
            proc.BeginOutputReadLine();
            proc.BeginErrorReadLine();
            proc.WaitForExit();
            return true;
        }

        static void CaptureOutput(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != null)
            {
                String outputString = e.Data + Environment.NewLine;
                Console.Write(outputString);
            }
        }

        static void CaptureError(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != null)
            {
                String outputString = e.Data + Environment.NewLine;
                Console.Write(outputString);
            }
        }

        static String getBashPath()
        {
            return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
            @"System32\bash.exe");
        }
    }
}
{'fraction_non_alphanumeric': 0.09536831310887028, 'fraction_numerical': 0.001367287643137925, 'mean_word_length': 1.541033434650456, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1848154', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1385, 'n_words': 355}