public static function quoteArgument($argument, $escape = false)
    {
        if ($escape) {
            return escapeshellarg($argument);
        }

        if (strpos($argument, '"') !== false) {
            if (strpos($argument, "'") !== false) {
                throw new BuildException("Can't handle single and double quotes in same argument");
            }

            return '\'' . $argument . '\'';
        }

        if (strpos($argument, "'") !== false
            || strpos($argument, ' ') !== false
            // WIN9x uses a bat file for executing commands
            || (OsCondition::isFamily('win32') && strpos($argument, ';') !== false)
        ) {
            return '"' . $argument . '"';
        }

        return $argument;
    }