Skip to content

Commit 545d797

Browse files
authored
Merge pull request #9 from pablodz/feat/alpine
fix shell
2 parents 0a4af14 + 466a7fb commit 545d797

File tree

5 files changed

+8
-25
lines changed

5 files changed

+8
-25
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ brew install inotify-tools
2222
sudo pacman -S inotify-tools
2323
```
2424

25-
2625
## Example
2726

2827
[Example](example/main.go)

inotifywaitgo/check.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,17 @@
11
package inotifywaitgo
22

33
import (
4-
"bufio"
54
"os/exec"
65
)
76

87
// CheckDependencies verifies if inotifywait is installed.
98
func checkDependencies() (bool, error) {
10-
cmd := exec.Command("bash", "-c", "which inotifywait")
11-
stdout, err := cmd.StdoutPipe()
9+
path, err := exec.LookPath("inotifywait")
1210
if err != nil {
1311
return false, err
1412
}
15-
16-
if err := cmd.Start(); err != nil {
17-
return false, err
18-
}
19-
20-
scanner := bufio.NewScanner(stdout)
21-
for scanner.Scan() {
22-
line := scanner.Text()
23-
if line != "" {
24-
return true, nil
25-
}
13+
if path != "" {
14+
return true, nil
2615
}
27-
28-
if err := scanner.Err(); err != nil {
29-
return false, err
30-
}
31-
3216
return false, nil
3317
}

inotifywaitgo/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77
)
88

9-
func GenerateBashCommands(s *Settings) ([]string, error) {
9+
func GenerateShellCommands(s *Settings) ([]string, error) {
1010
if s.Options == nil {
1111
return nil, errors.New(OPT_NIL)
1212
}

inotifywaitgo/killer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package inotifywaitgo
33
import "os/exec"
44

55
func killOthers() error {
6-
cmd := exec.Command("bash", "-c", "pkill inotifywait").Run()
7-
return cmd
6+
cmd := exec.Command("pkill", "inotifywait")
7+
return cmd.Run()
88
}

inotifywaitgo/watcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func WatchPath(s *Settings) {
2929
killOthers()
3030
}
3131

32-
// Generate bash command
33-
cmdString, err := GenerateBashCommands(s)
32+
// Generate shell command
33+
cmdString, err := GenerateShellCommands(s)
3434
if err != nil {
3535
s.ErrorChan <- err
3636
return

0 commit comments

Comments
 (0)