Skip to content

Commit

Permalink
QA: Fixed bug #17670: Now can be disabled the echo of the result of s…
Browse files Browse the repository at this point in the history
…entences with :set echo = false

git-svn-id: http://svn.php.net/repository/pear/packages/PHP_Shell/trunk@302240 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Jesús Espino García committed Aug 14, 2010
1 parent 38c7bfd commit 528df57
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
50 changes: 50 additions & 0 deletions PHP/Shell/Extensions/Echo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
class PHP_Shell_Extensions_Echo implements PHP_Shell_Extension
{
protected $opt_echo = true;

/**
* Register a command
*
* @return void
*/
public function register()
{
$opt = PHP_Shell_Options::getInstance();
$opt->registerOption('echo', $this, 'optSetEcho');
}

/**
* Set verbose
*
* @param string $key Unused
* @param string $value One of 'false', 'on', etc
*
* @return void
*/
public function optSetEcho($key, $value)
{
switch($value) {
case "true":
case "on":
case "1":
$this->opt_echo = true;
break;
default:
$this->opt_echo = false;
break;
}
}

/**
* check if we have a echo print-out
*
* @return bool 1 if echo, 0 otherwise
*/
public function isEcho()
{
return $this->opt_echo;
}
}


4 changes: 3 additions & 1 deletion scripts/php-shell-cmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
require_once "PHP/Shell/Extensions/InlineHelp.php";
require_once "PHP/Shell/Extensions/VerbosePrint.php";
require_once "PHP/Shell/Extensions/LoadScript.php";
require_once "PHP/Shell/Extensions/Echo.php";

/**
* default error-handler
Expand Down Expand Up @@ -71,6 +72,7 @@ function PHP_Shell_defaultErrorHandler($errno, $errstr, $errfile, $errline, $err
"inlinehelp" => new PHP_Shell_Extensions_InlineHelp(),
"verboseprint" => new PHP_Shell_Extensions_VerbosePrint(),
"loadscript" => new PHP_Shell_Extensions_LoadScript(),
"echo" => new PHP_Shell_Extensions_Echo(),
)
);

Expand Down Expand Up @@ -126,7 +128,7 @@ function __autoload($classname)
$__shell_exts->exectime->startExecTime();

$__shell_retval = eval($__shell->getCode());
if (isset($__shell_retval)) {
if (isset($__shell_retval) && $__shell_exts->echo->isEcho()) {
print $__shell_exts->colour->getColour("value");

if (function_exists("__shell_print_var")) {
Expand Down

0 comments on commit 528df57

Please sign in to comment.