CommandRenderer.php 678 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Shell;
  7. class CommandRenderer implements CommandRendererInterface
  8. {
  9. /**
  10. * Render command with arguments
  11. *
  12. * @param string $command
  13. * @param array $arguments
  14. * @return string
  15. */
  16. public function render($command, array $arguments = [])
  17. {
  18. $command = preg_replace('/(\s+2>&1)*(\s*\|)|$/', ' 2>&1$2', $command);
  19. $arguments = array_map('escapeshellarg', $arguments);
  20. if (empty($arguments)) {
  21. return $command;
  22. }
  23. return vsprintf($command, $arguments);
  24. }
  25. }