From aa75fc8fee7e55e0c78640fcbed0bf0627ba7971 Mon Sep 17 00:00:00 2001 From: Jekyll Wu Date: Sat, 10 Mar 2012 12:12:08 +0800 Subject: [PATCH] konsole -e 'man ls' should work as expected BUG: 295648 FIXED-IN: 4.9.0 --- src/Application.cpp | 22 ++++++++++++++++++---- src/ShellCommand.h | 5 ++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index a4b538f95..afdfb5f67 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -38,6 +38,7 @@ #include "SessionManager.h" #include "MainWindow.h" #include "Session.h" +#include "ShellCommand.h" using namespace Konsole; @@ -375,12 +376,25 @@ Profile::Ptr Application::processProfileChangeArgs(KCmdLineArgs* args, Profile:: // run a custom command if ( args->isSet("e") ) { + QString commandExec; QStringList commandArguments; - commandArguments << args->getOption("e"); - for ( int i = 0 ; i < args->count() ; i++ ) - commandArguments << args->arg(i); - QString commandExec = args->getOption("e"); + // Note: KCmdLineArgs::count() return the number of arguments + // that aren't options. + if ( args->count() > 0 ) { // example: konsole -e man ls + commandExec = args->getOption("e"); + + commandArguments << commandExec; + for ( int i = 0 ; i < args->count() ; i++ ) + commandArguments << args->arg(i); + + } else { // example: konsole -e "man ls" + ShellCommand shellCommand(args->getOption("e")); + + commandExec = shellCommand.command(); + commandArguments = shellCommand.arguments(); + } + if (commandExec.startsWith(QLatin1String("./"))) commandExec = QDir::currentPath() + commandExec.mid(1); diff --git a/src/ShellCommand.h b/src/ShellCommand.h index 813cd9317..3e439791b 100644 --- a/src/ShellCommand.h +++ b/src/ShellCommand.h @@ -23,6 +23,9 @@ // Qt #include +// Konsole +#include "konsole_export.h" + namespace Konsole { @@ -47,7 +50,7 @@ namespace Konsole * * */ -class ShellCommand +class KONSOLEPRIVATE_EXPORT ShellCommand { public: /**