summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJekyll Wu <adaptee@gmail.com>2012-03-10 04:12:08 (GMT)
committerJekyll Wu <adaptee@gmail.com>2012-03-10 05:22:14 (GMT)
commitaa75fc8fee7e55e0c78640fcbed0bf0627ba7971 (patch)
tree810180945c0067c7bed3d3cd20553c55fae210c4
parentcd090f2d1d40f18fedfca8992e4d4f4dc7fe0d97 (diff)
konsole -e 'man ls' should work as expected
BUG: 295648 FIXED-IN: 4.9.0
-rw-r--r--src/Application.cpp22
-rw-r--r--src/ShellCommand.h5
2 files changed, 22 insertions, 5 deletions
diff --git a/src/Application.cpp b/src/Application.cpp
index a4b538f..afdfb5f 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 813cd93..3e43979 100644
--- a/src/ShellCommand.h
+++ b/src/ShellCommand.h
@@ -23,6 +23,9 @@
// Qt
#include <QtCore/QStringList>
+// Konsole
+#include "konsole_export.h"
+
namespace Konsole
{
@@ -47,7 +50,7 @@ namespace Konsole
* </li>
* </ul>
*/
-class ShellCommand
+class KONSOLEPRIVATE_EXPORT ShellCommand
{
public:
/**