mirror of
https://github.com/KDE/konsole.git
synced 2026-05-03 20:26:45 -04:00
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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user