def absolute_command(cmd, path: nil)
      was_array = cmd.is_a?(Array)
      cmd = if was_array
        cmd.dup
      else
        Shellwords.split(cmd)
      end
      # Don't try to touch anything if the first value looks like a flag or a path.
      if cmd.first && !cmd.first.start_with?('-') && !cmd.first.include?(::File::SEPARATOR)
        # If which returns false, just leave it I guess.
        cmd[0] = which(cmd.first, path: path) || cmd.first
      end
      cmd = shelljoin(cmd) unless was_array
      cmd
    end
def absolute_command(cmd, path: nil)
      was_array = cmd.is_a?(Array)
      cmd = if was_array
        cmd.dup
      else
        Shellwords.split(cmd)
      end
      # Don't try to touch anything if the first value looks like a flag or a path.
      if cmd.first && !cmd.first.start_with?('-') && !cmd.first.include?(::File::SEPARATOR)
        # If which returns false, just leave it I guess.
        cmd[0] = which(cmd.first, path: path) || cmd.first
      end
      cmd = shelljoin(cmd) unless was_array
      cmd
    end
Convert the executable in a string or array command to an absolute path.

 @param cmd [String, Array<String>] Command to fix up.
 @param path [String, nil] Replacement $PATH for executable lookup.
 @return [String, Array<String>]