diff --git a/src/io/process.cpp b/src/io/process.cpp index 9fae90e2..3e3292d0 100644 --- a/src/io/process.cpp +++ b/src/io/process.cpp @@ -12,6 +12,7 @@ #include #include +#include "../core/generation.hpp" #include "../core/qmlglobal.hpp" #include "datastream.hpp" @@ -53,6 +54,16 @@ QList Process::command() const { return this->mCommand; } void Process::setCommand(QList command) { if (this->mCommand == command) return; this->mCommand = std::move(command); + + auto& cmd = this->mCommand.first(); + if (cmd.startsWith("file://")) { + cmd = cmd.sliced(7); + } else if (cmd.startsWith("root://")) { + cmd = cmd.sliced(7); + auto& root = EngineGeneration::findObjectGeneration(this)->rootPath; + cmd = root.filePath(cmd.startsWith('/') ? cmd.sliced(1) : cmd); + } + emit this->commandChanged(); this->startProcessIfReady(); diff --git a/src/io/process.hpp b/src/io/process.hpp index 521ee2ca..43db3165 100644 --- a/src/io/process.hpp +++ b/src/io/process.hpp @@ -51,6 +51,14 @@ class Process: public QObject { /// started process. If the property has been changed after starting a process it will /// return the new value, not the one for the currently running process. /// + /// > [!WARNING] This does not run command in a shell. All arguments to the command + /// > must be in separate values in the list, e.g. `["echo", "hello"]` + /// > and not `["echo hello"]`. + /// > + /// > Additionally, shell scripts must be run by your shell, + /// > e.g. `["sh", "script.sh"]` instead of `["script.sh"]` unless the script + /// > has a shebang. + /// /// > [!INFO] You can use `["sh", "-c", ]` to execute your command with /// > the system shell. Q_PROPERTY(QList command READ command WRITE setCommand NOTIFY commandChanged);