protected function filterCommand($command, $tail)
    {
        $command = trim($command);
        if (!$command) {
            throw new ShellException('Command cannot be empty.');
        }

        if ($tail && !strpos($command, $tail)) {
            $command .= $tail;
        }

        return $command;
    }