<commit_before>package stringexec

import (
	"io/ioutil"
	"os"
	"os/exec"
	"runtime"
)

// Return a new exec.Cmd object for the given command string
func Command(cwd string, cmd string) (*exec.Cmd, error) {
	if runtime.GOOS == "windows" {
		return ExecStringWindows(cwd, cmd)
	}
	return ExecStringFriendlyUnix(cwd, cmd)
}

func ExecStringWindows(cwd string, cmd string) (*exec.Cmd, error) {
	dir, err := ioutil.TempDir("", "stringexec")
	if err != nil {
		return nil, err
	}
	err = ioutil.WriteFile(dir+"/some.bat", []byte(cmd), 0766)
	if err != nil {
		return nil, err
	}

	oCmd := exec.Command("cmd", []string{"/C", dir + "/some.bat"}...)
	oCmd.Dir = cwd
	oCmd.Stdout = os.Stdout
	oCmd.Stderr = os.Stderr
	// defer os.Remove(tmpfile.Name()) // clean up // not sure how to clean it :x
	return oCmd, nil
}

func ExecStringFriendlyUnix(cwd string, cmd string) (*exec.Cmd, error) {
	oCmd := exec.Command("sh", []string{"-c", cmd}...)<commit_msg>error: add support for pkg/support<commit_after>package stringexec

import (
	"github.com/pkg/errors"
	"io/ioutil"
	"os"
	"os/exec"
	"runtime"
)

// Return a new exec.Cmd object for the given command string
func Command(cwd string, cmd string) (*exec.Cmd, error) {
	if runtime.GOOS == "windows" {
		return ExecStringWindows(cwd, cmd)
	}
	return ExecStringFriendlyUnix(cwd, cmd)
}

func ExecStringWindows(cwd string, cmd string) (*exec.Cmd, error) {
	dir, err := ioutil.TempDir("", "stringexec")
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = ioutil.WriteFile(dir+"/some.bat", []byte(cmd), 0766)
	if err != nil {
		return nil, errors.WithStack(err)
	}

	oCmd := exec.Command("cmd", []string{"/C", dir + "/some.bat"}...)
	oCmd.Dir = cwd
	oCmd.Stdout = os.Stdout
	oCmd.Stderr = os.Stderr
	// defer os.Remove(tmpfile.Name()) // clean up // not sure how to clean it :x
	return oCmd, nil
}

func ExecStringFriendlyUnix(cwd string, cmd string) (*exec.Cmd, error) {
	oCmd := exec.Command("sh", []string{"-c", cmd}...)
{'fraction_non_alphanumeric': 0.17022357723577236, 'fraction_numerical': 0.0040650406504065045, 'mean_word_length': 3.959697732997481, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7107903', 'n_tokens_mistral': 768, 'n_tokens_neox': 742, 'n_words': 196}