@@ -1381,12 +1381,16 @@ function delete_dir( $dir ) {
13811381
13821382/**
13831383 * Function to generate random password.
1384+ *
1385+ * @param int $length Length of random password required.
1386+ *
1387+ * @return string Random Password of specified length.
13841388 */
1385- function random_password () {
1389+ function random_password ( $ length = 12 ) {
13861390 $ alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ' ;
13871391 $ pass = array ();
13881392 $ alphaLength = strlen ( $ alphabet ) - 1 ;
1389- for ( $ i = 0 ; $ i < 12 ; $ i ++ ) {
1393+ for ( $ i = 0 ; $ i < $ length ; $ i ++ ) {
13901394 $ n = rand ( 0 , $ alphaLength );
13911395 $ pass [] = $ alphabet [$ n ];
13921396 }
@@ -1425,18 +1429,52 @@ function default_debug( $launch ) {
14251429
14261430/**
14271431 * Default Launch command.
1432+ * This takes care of executing the command as well as debugging it to terminal as well as file.
14281433 *
1429- * @param Object $launch EE::Launch command object
1434+ * @param string $command The command to be executed via EE::launch();
1435+ * @param array $env Environment variables to set when running the command.
1436+ * @param string $cwd Directory to execute the command in.
1437+ *
1438+ * @return bool True if executed successfully. False if failed.
14301439 */
1431- function default_launch ( $ command ) {
1432- $ launch = EE ::launch ( $ command , false , true );
1440+ function default_launch ( $ command, $ env = null , $ cwd = null ) {
1441+ $ launch = EE ::launch ( $ command , false , true , $ env , $ cwd );
14331442 default_debug ( $ launch );
14341443 if ( ! $ launch ->return_code ) {
14351444 return true ;
14361445 }
1446+
14371447 return false ;
14381448}
14391449
1450+ /**
1451+ * Function that takes care of executing the command as well as debugging it to terminal as well as file.
1452+ *
1453+ * @param string $command The command to be executed via exec();
1454+ *
1455+ * @return bool True if executed successfully. False if failed.
1456+ */
1457+ function default_exec ( $ command ) {
1458+ exec ( $ command , $ out , $ return_code );
1459+ EE ::debug ( 'COMMAND: ' . $ command );
1460+ EE ::debug ( 'STDOUT: ' . implode ( $ out ) );
1461+ EE ::debug ( 'RETURN CODE: ' . $ return_code );
1462+ if ( ! $ return_code ) {
1463+ return true ;
1464+ }
1465+ return false ;
1466+ }
1467+
1468+ /**
1469+ * Function that takes care of executing the command as well as debugging it to terminal as well as file.
1470+ *
1471+ * @param string $command The command to be executed via shell_exec();
1472+ */
1473+ function default_shell_exec ( $ command ) {
1474+ EE ::debug ( 'COMMAND: ' . $ command );
1475+ EE ::debug ( 'STDOUT: ' . shell_exec ( $ command ) );
1476+ }
1477+
14401478/**
14411479 * Function to return the type from arguments.
14421480 *
0 commit comments