Skip to content

Commit

Permalink
fix: If Bash does not exist, use sh (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
WaterLemons2k committed Mar 30, 2023
1 parent 55f4462 commit 947ff98
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,13 @@ func (conf *DnsConfig) getAddrFromCmd(addrType string) string {
if runtime.GOOS == "windows" {
execCmd = exec.Command("powershell", "-Command", cmd)
} else {
execCmd = exec.Command("bash", "-rc", cmd)
// If Bash does not exist, use sh
_, err := exec.LookPath("bash")
if err != nil {
execCmd = exec.Command("sh", "-c", cmd)
} else {
execCmd = exec.Command("bash", "-rc", cmd)
}
}
// run cmd
out, err := execCmd.CombinedOutput()
Expand Down

0 comments on commit 947ff98

Please sign in to comment.