Commit a2fb91569e1a126c428f1a6f04a8a71186c1ee25

Authored by nbm
1 parent db136921

Add options to pexec, so that it can be used to, for example, append the

output of a command to a given file.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4434 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 11 additions and 3 deletions
lib/util/ktutil.inc
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * 5 *
6 * Small non-domain-specific utility functions 6 * Small non-domain-specific utility functions
7 * 7 *
8 - * Copyright (c) 2004 Jam Warehouse http://www.jamwarehouse.com 8 + * Copyright (c) 2004, 2005 Jam Warehouse http://www.jamwarehouse.com
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -169,8 +169,16 @@ class KTUtil { @@ -169,8 +169,16 @@ class KTUtil {
169 /** 169 /**
170 * Portably execute a command on any of the supported platforms. 170 * Portably execute a command on any of the supported platforms.
171 */ 171 */
172 - function pexec($aCmd) {  
173 - $sCmd = KTUtil::safeShellString($aCmd); 172 + function pexec($aCmd, $aOptions = null) {
  173 + if (is_array($aCmd)) {
  174 + $sCmd = KTUtil::safeShellString($aCmd);
  175 + } else {
  176 + $sCmd = $aCmd;
  177 + }
  178 + $sAppend = KTUtil::arrayGet($aOptions, 'append');
  179 + if ($sAppend) {
  180 + $sCmd .= " >> " . escapeshellarg($sAppend);
  181 + }
174 if (OS_WINDOWS) { 182 if (OS_WINDOWS) {
175 $sCmd = "start /b " . $sCmd; 183 $sCmd = "start /b " . $sCmd;
176 } 184 }