summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBrion Vibber <brion@status.net>2009-12-14 11:51:38 -0800
committerBrion Vibber <brion@status.net>2009-12-14 11:51:38 -0800
commitb93068083e4366aa6847471c5fae34d770bbad18 (patch)
tree3357804478ca3369af2f20778d85e298b5317522 /scripts
parenta199bd808a9dce64dd1d9a137b853b6ba0f6811b (diff)
Clean up console output for non-interactive mode (handy for batch setup scripts)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/console.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/scripts/console.php b/scripts/console.php
index 210d2b6b2..329caf472 100755
--- a/scripts/console.php
+++ b/scripts/console.php
@@ -73,7 +73,7 @@ function read_input_line($prompt)
*/
function readline_emulation($prompt)
{
- if(file_exists(trim(shell_exec('which bash')))) {
+ if(CONSOLE_INTERACTIVE && file_exists(trim(shell_exec('which bash')))) {
$encPrompt = escapeshellarg($prompt);
$command = "read -er -p $encPrompt && echo \"\$REPLY\"";
$encCommand = escapeshellarg($command);
@@ -103,7 +103,9 @@ function readline_emulation($prompt)
if (feof(STDIN)) {
return false;
}
- print $prompt;
+ if (CONSOLE_INTERACTIVE) {
+ print $prompt;
+ }
return fgets(STDIN);
}
@@ -123,13 +125,16 @@ function console_help()
print "Type ctrl+D or enter 'exit' to exit.\n";
}
-
-print "StatusNet interactive PHP console... type ctrl+D or enter 'exit' to exit.\n";
-$prompt = common_config('site', 'name') . '> ';
+if (CONSOLE_INTERACTIVE) {
+ print "StatusNet interactive PHP console... type ctrl+D or enter 'exit' to exit.\n";
+ $prompt = common_config('site', 'name') . '> ';
+}
while (!feof(STDIN)) {
$line = read_input_line($prompt);
if ($line === false) {
- print "\n";
+ if (CONSOLE_INTERACTIVE) {
+ print "\n";
+ }
break;
} elseif ($line !== '') {
try {
@@ -154,5 +159,7 @@ while (!feof(STDIN)) {
print get_class($e) . ": " . $e->getMessage() . "\n";
}
}
- print "\n";
+ if (CONSOLE_INTERACTIVE) {
+ print "\n";
+ }
}