Correct (and simplify) command parsing in profiles with respect to spaces.

BUG: 188230

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=992625
This commit is contained in:
Kurt Hindenburg
2009-07-07 12:50:31 +00:00
parent 4961215664
commit 041c4de4a2

View File

@@ -21,6 +21,7 @@
#include "ShellCommand.h"
// Qt
#include <KShell>
#include <KDebug>
using namespace Konsole;
@@ -31,31 +32,7 @@ static bool expandEnv(QString& text);
ShellCommand::ShellCommand(const QString& fullCommand)
{
bool inQuotes = false;
QString builder;
for ( int i = 0 ; i < fullCommand.count() ; i++ )
{
QChar ch = fullCommand[i];
const bool isLastChar = ( i == fullCommand.count() - 1 );
const bool isQuote = ( ch == '\'' || ch == '\"' );
if ( !isLastChar && isQuote )
inQuotes = !inQuotes;
else
{
if ( (!ch.isSpace() || inQuotes) && !isQuote )
builder.append(ch);
if ( (ch.isSpace() && !inQuotes) || ( i == fullCommand.count()-1 ) )
{
_arguments << builder;
builder.clear();
}
}
}
_arguments = KShell::splitArgs(fullCommand);
}
ShellCommand::ShellCommand(const QString& command , const QStringList& arguments)
{