Skip to content

Commit

Permalink
Merge pull request #37 from oalders/command
Browse files Browse the repository at this point in the history
Try harder to run command -v
  • Loading branch information
oalders authored Aug 16, 2024
2 parents cfdfaa5 + a8e4771 commit c700ef3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## 0.5.4 - 2024-08-16

- Run "command -v" via "sh -c" (GH#37) (Olaf Alders)

## 0.5.3 - 2024-06-22

- Parse versions for: dig, perldoc, fpp, fzf, screen, sqlite3 and typos (GH#35)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {
kong.Name("is"),
kong.Description("an inspector for your environment"),
kong.UsageOnError(),
kong.Vars{"version": "0.5.3"},
kong.Vars{"version": "0.5.4"},
)

// Run kongplete.Complete to handle completion requests
Expand Down
4 changes: 3 additions & 1 deletion test/is.bats
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bats

@test "is --version" {
./is --version
run ./is --version
[ "$status" -eq 0 ]
[ "$output" = "0.5.4" ]
}

@test "is --help" {
Expand Down
7 changes: 5 additions & 2 deletions there.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ 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 {
if ctx.Debug {
log.Printf("Error was: %v\n", err)
log.Printf("Running \"which %s\"\n", r.Name)
}
cmd := exec.Command("which", r.Name) //nolint:gosec
Expand Down

0 comments on commit c700ef3

Please sign in to comment.