```gradle def commandLineOf(command, terminal = null) { if (System.properties['os.name'].toLowerCase().contains('windows')) { return ['cmd', '/c', command] } else if (terminal != null) { return ['bash', '-c', terminal] } else { return ['bash', '-c', command] } } task example { doLast { exec { workingDir '.' commandLine commandLineOf("git fetch") } exec { workingDir '.' commandLine commandLineOf("dir", "ls") } } } ```