Replace backslashes with forward slashes in command names

develop
lethosor 2015-03-06 16:53:57 -05:00
parent cb0bb4ecbd
commit 1591e67bf2
1 changed files with 6 additions and 8 deletions

@ -456,21 +456,19 @@ static std::string sc_event_name (state_change_event id) {
return "SC_UNKNOWN";
}
command_result Core::runCommand(color_ostream &con, const std::string &first, vector<string> &parts)
command_result Core::runCommand(color_ostream &con, const std::string &first_, vector<string> &parts)
{
std::string first = first_;
if (!first.empty())
{
// Disallow backslashes in commands (e.g. script names), for consistency
if(first.find('\\') != std::string::npos)
{
std::string suggestion = first;
for (size_t i = 0; i < suggestion.size(); i++)
con.printerr("Replacing backslashes with forward slashes in \"%s\"\n", first.c_str());
for (size_t i = 0; i < first.size(); i++)
{
if (suggestion[i] == '\\')
suggestion[i] = '/';
if (first[i] == '\\')
first[i] = '/';
}
con.printerr("Backslashes in command names are not valid. Use %s instead.\n", suggestion.c_str());
return CR_NOT_IMPLEMENTED;
}
// let's see what we actually got
if(first=="help" || first == "?" || first == "man")