Skip to content

Commit 8a4ccf3

Browse files
committed
Exec & ShellExec return Fix
1 parent 4fbfd9c commit 8a4ccf3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

exec.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package phpfuncs
22

33
import (
44
"bytes"
5-
"fmt"
65
"log"
76
"os"
87
"os/exec"
@@ -13,30 +12,31 @@ import (
1312
// Original : https://www.php.net/manual/tr/function.exec.php
1413
//
1514
// exec() executes the given command.
16-
func Exec(of string) {
15+
func Exec(of string) string {
1716
var out bytes.Buffer
1817
cmd := exec.Command(of)
1918
cmd.Stdout = &out
2019
err := cmd.Run()
2120
if err != nil {
2221
log.Fatal(err)
2322
}
23+
return out.String()
2424
}
2525

2626
// ShellExec - Execute command via shell and return the complete output as a string
2727
//
2828
// Original : https://www.php.net/manual/en/function.shell-exec.php
2929
//
3030
// This function is identical to the backtick operator.
31-
func ShellExec(of string) {
31+
func ShellExec(of string) string {
3232
var out bytes.Buffer
3333
cmd := exec.Command(of)
3434
cmd.Stdout = &out
3535
err := cmd.Run()
3636
if err != nil {
3737
log.Fatal(err)
3838
}
39-
fmt.Printf("%q\n", out.String())
39+
return out.String()
4040
}
4141

4242
// Exit - Output a message and terminate the current script

0 commit comments

Comments
 (0)