Skip to content

Commit c700ef3

Browse files
authored
Merge pull request #37 from oalders/command
Try harder to run command -v
2 parents cfdfaa5 + a8e4771 commit c700ef3

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## 0.5.4 - 2024-08-16
4+
5+
- Run "command -v" via "sh -c" (GH#37) (Olaf Alders)
6+
37
## 0.5.3 - 2024-06-22
48

59
- Parse versions for: dig, perldoc, fpp, fzf, screen, sqlite3 and typos (GH#35)

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func main() {
2929
kong.Name("is"),
3030
kong.Description("an inspector for your environment"),
3131
kong.UsageOnError(),
32-
kong.Vars{"version": "0.5.3"},
32+
kong.Vars{"version": "0.5.4"},
3333
)
3434

3535
// Run kongplete.Complete to handle completion requests

test/is.bats

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env bats
22

33
@test "is --version" {
4-
./is --version
4+
run ./is --version
5+
[ "$status" -eq 0 ]
6+
[ "$output" = "0.5.4" ]
57
}
68

79
@test "is --help" {

there.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@ import (
55
"errors"
66
"log"
77
"os/exec"
8+
"strings"
89

910
"github.com/oalders/is/types"
1011
)
1112

1213
// Run "is there ...".
1314
func (r *ThereCmd) Run(ctx *types.Context) error {
14-
cmd := exec.Command("command", "-v", r.Name) //nolint:gosec
15+
args := []string{"-c", "command -v " + r.Name}
16+
cmd := exec.Command("sh", args...)
1517
if ctx.Debug {
16-
log.Printf("Running \"command -v %s\"\n", r.Name)
18+
log.Printf("Running \"sh %s\"\n", strings.Join(args, " "))
1719
}
1820
err := cmd.Run()
1921
if err != nil {
2022
if ctx.Debug {
23+
log.Printf("Error was: %v\n", err)
2124
log.Printf("Running \"which %s\"\n", r.Name)
2225
}
2326
cmd := exec.Command("which", r.Name) //nolint:gosec

0 commit comments

Comments
 (0)