Chapter 12 - commandPath

I love the way that this topic is presented. So well done.
I do have one question though. When we build our playground, we create this function

func pathTo(command: String) async -> String {
    await runCommand("/bin/zsh", with: ["-c", "which \(command)"])
}

yet, when you start to use the sips command, you don’t use it. In stead, you do this:

Task {
    let sipsPath = await runCommand("/bin/zsh", with: ["-c", "which sips"])
    let args = ["--getProperty", "all", imagePath]
    let imageData = await runCommand(sipsPath, with: args)
    print(imageData)
}

Why not just use this instead?

Task {
    let commandPath = await pathTo(command: "sips")
    let args = ["--getProperty", "all", imagePath]
    let imageData = await runCommand(commandPath, with: args)
    print(imageData)
}

You are quite right. I should have used that method to find the command path. D’oh!

Thanks for pointing this out. I’ll fix it in the next version