Skip to content

Commit

Permalink
Run "command -v" via "sh -c"
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Aug 16, 2024
1 parent cfdfaa5 commit 6d4efed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions there.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import (
"errors"
"log"
"os/exec"
"strings"

"github.com/oalders/is/types"
)

// Run "is there ...".
func (r *ThereCmd) Run(ctx *types.Context) error {
cmd := exec.Command("command", "-v", r.Name) //nolint:gosec
args := []string{"-c", "command -v " + r.Name}
cmd := exec.Command("sh", args...)
if ctx.Debug {
log.Printf("Running \"command -v %s\"\n", r.Name)
log.Printf("Running \"sh %s\"\n", strings.Join(args, " "))
}
err := cmd.Run()
if err != nil {
Expand Down

0 comments on commit 6d4efed

Please sign in to comment.