From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org, stephen@brennan.io,
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v2 3/3] kernel-shark: Add quotation marks parsing example/test
Date: Wed, 18 Sep 2019 17:23:19 +0300 [thread overview]
Message-ID: <20190918142319.11821-4-y.karadz@gmail.com> (raw)
In-Reply-To: <20190918142319.11821-1-y.karadz@gmail.com>
The example implements a small GUI that executes shell commands.
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
kernel-shark/examples/CMakeLists.txt | 4 +++
kernel-shark/examples/cmd_split.cpp | 52 ++++++++++++++++++++++++++++
2 files changed, 56 insertions(+)
create mode 100644 kernel-shark/examples/cmd_split.cpp
diff --git a/kernel-shark/examples/CMakeLists.txt b/kernel-shark/examples/CMakeLists.txt
index e16216e..35e6b1e 100644
--- a/kernel-shark/examples/CMakeLists.txt
+++ b/kernel-shark/examples/CMakeLists.txt
@@ -23,3 +23,7 @@ target_link_libraries(dplot kshark-plot)
message(STATUS "widgetdemo")
add_executable(widgetdemo widgetdemo.cpp)
target_link_libraries(widgetdemo kshark-gui)
+
+message(STATUS "cmd_split")
+add_executable(cmd_split cmd_split.cpp)
+target_link_libraries(cmd_split kshark-gui)
diff --git a/kernel-shark/examples/cmd_split.cpp b/kernel-shark/examples/cmd_split.cpp
new file mode 100644
index 0000000..ac68844
--- /dev/null
+++ b/kernel-shark/examples/cmd_split.cpp
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright (C) 2017 VMware Inc, Yordan Karadzhov (VMware) <y.karadz@gmail.com>
+ */
+
+// C++
+#include<iostream>
+using namespace std;
+
+// Qt
+#include <QtWidgets>
+
+// KernelShark
+#include "KsUtils.hpp"
+
+int main(int argc, char **argv)
+{
+ QString text = "echo \"I want \\\" here\" \\\n \"and \\\' here\"";
+ QApplication a(argc, argv);
+ QStringList argList;
+ bool ok = true;
+ QProcess proc;
+
+ while (ok) {
+ text = QInputDialog::getMultiLineText(nullptr,
+ "Shell quoting test",
+ "Shell input:",
+ text,
+ &ok);
+
+ if (ok) {
+ argList = KsUtils::splitArguments(text);
+ qInfo() << argList;
+
+ proc.setProgram(argList.takeFirst());
+ proc.setArguments(argList);
+
+ proc.start();
+ proc.waitForFinished();
+
+ cout << proc.errorString().toStdString()
+ << endl
+ << proc.readAllStandardError().toStdString()
+ << endl
+ << proc.readAllStandardOutput().toStdString()
+ << endl;
+ }
+ }
+
+ return 0;
+}
--
2.20.1
next prev parent reply other threads:[~2019-09-18 14:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-18 14:23 [PATCH v2 0/3] Support "shell quoting" in the Record dialog Yordan Karadzhov (VMware)
2019-09-18 14:23 ` [PATCH v2 1/3] kernel-shark: Provide parsing for quotation marks in Record command line Yordan Karadzhov (VMware)
2019-09-19 23:20 ` Steven Rostedt
2019-09-20 9:48 ` Yordan Karadzhov (VMware)
2019-09-18 14:23 ` [PATCH v2 2/3] kernel-shark: give more space to the command field of the Record dialog Yordan Karadzhov (VMware)
2019-09-18 14:23 ` Yordan Karadzhov (VMware) [this message]
2019-09-19 23:12 ` [PATCH v2 3/3] kernel-shark: Add quotation marks parsing example/test Steven Rostedt
2019-09-20 9:50 ` Yordan Karadzhov (VMware)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190918142319.11821-4-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=stephen@brennan.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).