I'm trying to run terminal commands from my swift mac app, i want the users to enter any command like they would in the terminal without having to specify the real path. Is there a way to run a command and make it look in every path that's specified in the $PATH variable?
I can run commands when I specify the path but I need it to auto-find the binary from any path in the systems $PATH variable
let path = "/usr/bin/killall" let arguments = ["Dock"] let task = Process.launchedProcess(launchPath: path, arguments: arguments) task.waitUntilExit()
In the future I would like to read .sh files and run every line in it, so for long scripts not all binaries will be in the default path.