<commit_before>package com.github.jishida.gradle.shellscript.task

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction

import static com.github.jishida.gradle.shellscript.ShellScriptStrings.*
import static com.github.jishida.gradle.shellscript.util.EnvironmentUtils.windows

class ShellScript extends DefaultTask implements ShellScriptTask {
    File workingDir
    List<String> args
    String mSystem = DEFAULT_SHELL_SCRIPT_M_SYSTEM
    File scriptFile

    ShellScript() {
        super()
        group = ID
        if (windows) {
            dependsOn(Tasks.MSYS2_SETUP)
        }
    }

    @Input
    Map getShellScriptInputs() {
        final def result = [:]
        result['mSystem'] = mSystem ?: (Object) DEFAULT_SHELL_SCRIPT_M_SYSTEM

        if (workingDir != null) {
            result['workingDir'] = workingDir
        }
        if (args != null) {
            result['args'] = args
        }
        if (scriptFile != null) {
            result['scriptFile'] = scriptFile
            if (scriptFile.file) {
                result['scriptFileModified'] = scriptFile.lastModified()
            }
        }
        result
    }

    @Input
    String getShellExecutable() {
        windows ? shellScript?.msys2?.bashFile?.canonicalPath : shellScript?.unixShell
    }

    @Input
    List<String> getShellArgs() {
        shellScript?.shellArgs
    }

    @TaskAction
    protected void run() {
        project.exec {
            it.executable = shellExecutable

            final def args_ = []
            if (windows) {
                args_ << '--login'

                final def env = [:] << System.getenv()
                env['MSYSTEM'] = mSystem ?: DEFAULT_SHELL_SCRIPT_M_SYSTEM
                env['CHERE_INVOKING'] = '1'
                it.environment = env
            }
            if (!shellArgs.empty)
                args_.addAll(shellArgs)
            if (args != null && !args.empty)
                args_.addAll(args)
            if (scriptFile != null)
                args_ << scriptFile.canonicalPath
            it.args = args_

            if (workingDir != null) {
                workingDir.mkdirs()
            }
            it.workingDir = workingDir
        }.rethrowFailure()
    }
}<commit_msg>fix ShellSctipt task class<commit_after>package com.github.jishida.gradle.shellscript.task

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction

import static com.github.jishida.gradle.shellscript.ShellScriptStrings.*
import static com.github.jishida.gradle.shellscript.util.EnvironmentUtils.windows

class ShellScript extends DefaultTask implements ShellScriptTask {
    File workingDir
    List<String> args
    String mSystem = DEFAULT_SHELL_SCRIPT_M_SYSTEM
    File scriptFile

    ShellScript() {
        super()
        group = ID
        if (windows) {
            dependsOn(Tasks.MSYS2_SETUP)
        }
    }

    @Input
    Map getShellScriptInputs() {
        final def result = [:]
        result['mSystem'] = mSystem ?: (Object) DEFAULT_SHELL_SCRIPT_M_SYSTEM

        if (workingDir != null) {
            result['workingDir'] = workingDir
        }
        if (args != null) {
            result['args'] = args
        }
        if (scriptFile != null) {
            result['scriptFile'] = scriptFile
            if (scriptFile.file) {
                result['scriptFileModified'] = scriptFile.lastModified()
            }
        }
        result
    }

    @Input
    String getShellExecutable() {
        windows ? shellScript?.msys2?.bashFile?.canonicalPath : shellScript?.unixShell
    }

    @Input
    List<String> getShellArgs() {
        shellScript?.shellArgs
    }

    @TaskAction
    protected void run() {
        final def workingDir_ = workingDir ?: project.projectDir

        project.exec {
            it.executable = shellExecutable

            final def args_ = []
            if (windows) {
                args_ << '--login'

                it.environment['MSYSTEM'] = mSystem ?: DEFAULT_SHELL_SCRIPT_M_SYSTEM
                it.environment['CHERE_INVOKING'] = '1'
            }
            if (!shellArgs.empty)
                args_.addAll(shellArgs)
            if (args != null && !args.empty)
                args_.addAll(args)
            if (scriptFile != null)
                args_ << scriptFile.canonicalPath
            it.args = args_

            if (workingDir_ != null) {
                workingDir_.mkdirs()
            }
            it.workingDir = workingDir_
        }.rethrowFailure()
    }
}
{'fraction_non_alphanumeric': 0.09852109612875164, 'fraction_numerical': 0.0013049151805132667, 'mean_word_length': 1.8476780185758515, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 7, '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': '4630003', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1268, 'n_words': 248}