Cleanup 'zend' command a bit
The [z]end command in hphpd runs the last manually entered snippet of php in "zend". If you typed 'z' before actually entering any php, it would segfault. Fixed a minor bug in Process::Exec, and present help if none entered. Also clarified that it will simply use your system's default php, and made it so you can override which exe to use with a hphpd config variable. The default is "php", since that is most commonly used.
Esse commit está contido em:
@@ -31,9 +31,10 @@ void CmdZend::help(DebuggerClient &client) {
|
||||
client.helpBody(
|
||||
"This is mainly for comparing results from PHP vs. HipHop. After you type "
|
||||
"in some PHP code, it will be evaluated immediately in HipHop. Then you "
|
||||
"can type '[z]end' command to re-run the same script in Zend PHP. Please "
|
||||
"note that only the most recent block of code you manually typed in was "
|
||||
"evaluated, not any earlier ones, nor the ones from a PHP file."
|
||||
"can type '[z]end' command to re-run the same script with your "
|
||||
"system-default PHP. Please note that only the most recent block of code "
|
||||
"you manually typed in is evaluated, not any earlier ones, nor the ones "
|
||||
"from a PHP file."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,12 +43,16 @@ void CmdZend::onClientImpl(DebuggerClient &client) {
|
||||
|
||||
if (client.argCount() == 0) {
|
||||
const std::string &code = client.getCode();
|
||||
string out;
|
||||
Process::Exec("php", nullptr, code.c_str(), out, &out, true);
|
||||
client.print(out);
|
||||
} else {
|
||||
help(client);
|
||||
if (!code.empty()) {
|
||||
const std::string zendExe = client.getZendExecutable();
|
||||
client.info("Executing last PHP block with \"%s\"...", zendExe.c_str());
|
||||
string out;
|
||||
Process::Exec(zendExe.c_str(), nullptr, code.c_str(), out, &out, true);
|
||||
client.print(out);
|
||||
return;
|
||||
}
|
||||
}
|
||||
help(client);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -2385,6 +2385,7 @@ void DebuggerClient::loadConfig() {
|
||||
}
|
||||
|
||||
m_sourceRoot = m_config["SourceRoot"].getString();
|
||||
m_zendExe = m_config["ZendExecutable"].getString("php");
|
||||
|
||||
if (needToWriteFile) {
|
||||
saveConfig(); // so to generate a starter for people
|
||||
|
||||
@@ -349,6 +349,8 @@ public:
|
||||
void usageLogEvent(const std::string &eventName,
|
||||
const std::string &data = "");
|
||||
|
||||
std::string getZendExecutable() const { return m_zendExe; }
|
||||
|
||||
private:
|
||||
enum InputState {
|
||||
TakingCommand,
|
||||
@@ -494,6 +496,9 @@ private:
|
||||
|
||||
// usage logging
|
||||
const char *getUsageMode();
|
||||
|
||||
// Zend executable for CmdZend, overridable via config.
|
||||
std::string m_zendExe;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -157,9 +157,11 @@ bool Process::Exec(const char *path, const char *argv[], const char *in,
|
||||
if (WEXITSTATUS(status) != 0) {
|
||||
Logger::Verbose("Status %d running command: `%s'\n",
|
||||
WEXITSTATUS(status), path);
|
||||
while (*argv) {
|
||||
Logger::Verbose(" arg: `%s'\n", *argv);
|
||||
argv++;
|
||||
if (argv) {
|
||||
while (*argv) {
|
||||
Logger::Verbose(" arg: `%s'\n", *argv);
|
||||
argv++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = true;
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário