<commit_before>package shell

import (
	"io/ioutil"
	"os"
	"strings"
	"syscall"

	"github.com/zetamatta/nyagos/dos"
	"github.com/zetamatta/nyagos/nodos"
)

func (cmd *Cmd) lookpath() string {
	return nodos.LookPath(LookCurdirOrder, cmd.args[0], "NYAGOSPATH")
}

func (cmd *Cmd) startProcess() (int, error) {
	if cmd.UseShellExecute {
		// GUI Application
		cmdline := makeCmdline(cmd.args[1:], cmd.rawArgs[1:])
		return 0, dos.ShellExecute("open", cmd.args[0], cmdline, "")
	}
	if UseSourceRunBatch {
		lowerName := strings.ToLower(cmd.args[0])
		if strings.HasSuffix(lowerName, ".cmd") || strings.HasSuffix(lowerName, ".bat") {
			rawargs := cmd.RawArgs()
			args := make([]string, len(rawargs))
			args[0] = encloseWithQuote(cmd.args[0])
			for i, end := 1, len(rawargs); i < end; i++ {
				args[i] = rawargs[i]
			}
			// Batch files
			return RawSource(args, ioutil.Discard, false, cmd.Stdin, cmd.Stdout, cmd.Stderr)
		}
	}

	cmdline := makeCmdline(cmd.args, cmd.rawArgs)

	procAttr := &os.ProcAttr{
		Env:   os.Environ(),
		Files: []*os.File{cmd.Stdin, cmd.Stdout, cmd.Stderr},
		Sys:   &syscall.SysProcAttr{CmdLine: cmdline},
	}

	process, err := os.StartProcess(cmd.args[0], cmd.args[1:], procAttr)
	if err != nil {
		return 255, err
	}
	processState, err := process.Wait()
	if err != nil {
		return 254, err
	}
	if processState.Success() {
		return 0, nil
	}
	if t, ok := processState.Sys().(syscall.WaitStatus); ok {
		return t.ExitStatus(), nil<commit_msg>shell/*.go: fix the invalid arguments of os.StartProcess()<commit_after>package shell

import (
	"io/ioutil"
	"os"
	"strings"
	"syscall"

	"github.com/zetamatta/nyagos/dos"
	"github.com/zetamatta/nyagos/nodos"
)

func (cmd *Cmd) lookpath() string {
	return nodos.LookPath(LookCurdirOrder, cmd.args[0], "NYAGOSPATH")
}

func (cmd *Cmd) startProcess() (int, error) {
	if cmd.UseShellExecute {
		// GUI Application
		cmdline := makeCmdline(cmd.args[1:], cmd.rawArgs[1:])
		return 0, dos.ShellExecute("open", cmd.args[0], cmdline, "")
	}
	if UseSourceRunBatch {
		lowerName := strings.ToLower(cmd.args[0])
		if strings.HasSuffix(lowerName, ".cmd") || strings.HasSuffix(lowerName, ".bat") {
			rawargs := cmd.RawArgs()
			args := make([]string, len(rawargs))
			args[0] = encloseWithQuote(cmd.args[0])
			for i, end := 1, len(rawargs); i < end; i++ {
				args[i] = rawargs[i]
			}
			// Batch files
			return RawSource(args, ioutil.Discard, false, cmd.Stdin, cmd.Stdout, cmd.Stderr)
		}
	}

	cmdline := makeCmdline(cmd.args, cmd.rawArgs)

	procAttr := &os.ProcAttr{
		Env:   os.Environ(),
		Files: []*os.File{cmd.Stdin, cmd.Stdout, cmd.Stderr},
		Sys:   &syscall.SysProcAttr{CmdLine: cmdline},
	}

	process, err := os.StartProcess(cmd.args[0], cmd.args, procAttr)
	if err != nil {
		return 255, err
	}
	processState, err := process.Wait()
	if err != nil {
		return 254, err
	}
	if processState.Success() {
		return 0, nil
	}
	if t, ok := processState.Sys().(syscall.WaitStatus); ok {
		return t.ExitStatus(), nil
{'fraction_non_alphanumeric': 0.17356205852674067, 'fraction_numerical': 0.011772620248906828, 'mean_word_length': 4.006734006734007, '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': '1181191', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1155, 'n_words': 241}