@@ -2,23 +2,24 @@ package main
22
33import (
44 "fmt"
5− "github.com/replit/prybar/utils"
65 "os"
76 "os/exec"
87 "path/filepath"
98 "syscall"
9+
10+ "github.com/replit/prybar/utils"
1011)
1112
1213func Execute(config *utils.Config) {
14+ args := []string{}
1315
14− emacs, err := exec.LookPath("emacs")
15−
16− if err != nil {
17− panic(err)
16+ if _, err := os.Stat("Cask"); err == nil {
17+ if _, err := exec.LookPath("cask"); err == nil {
18+ args = append(args, "cask", "exec")
19+ }
1820 }
1921
2022 execPath, err := os.Executable()
21−
2223 if err != nil {
2324 panic(err)
2425 }
@@ -26,6 +27,11 @@ func Execute(config *utils.Config) {
2627 runDir := filepath.Dir(execPath)
2728 replPath := filepath.Join(runDir, "prybar_assets", "elisp", "repl.el")
2829
30+ args = append(
31+ args, "emacs", "-nw", "-Q", "--load", replPath,
32+ "--eval", "(prybar-repl)",
33+ )
34+
2935 os.Setenv("PRYBAR_EVAL", config.Exp)
3036 os.Setenv("PRYBAR_EXEC", config.Code)
3137 os.Setenv("PRYBAR_PS1", config.Ps1)
@@ -45,18 +51,22 @@ func Execute(config *utils.Config) {
4551 }
4652
4753 if !(config.Interactive || config.OurInteractive) {
48− fmt.Fprintln(os.Stderr, "prybar-elisp: warn: non-interactive mode not implemented");
54+ fmt.Fprintln(os.Stderr, "prybar-elisp: warn: non-interactive mode not implemented")
4955 }
5056
5157 if config.Ps2 != "... " {
52− fmt.Fprintln(os.Stderr, "prybar-elisp: warn: ps2 not implemented");
58+ fmt.Fprintln(os.Stderr, "prybar-elisp: warn: ps2 not implemented")
5359 }
5460
55− args := []string{"emacs", "-nw", "-Q", "--load", replPath, "--eval", "(prybar-repl)"}
56− err = syscall.Exec(emacs, args, os.Environ())
61+ path, err := exec.LookPath(args[0])
62+ if err != nil {
63+ fmt.Fprintf(os.Stderr, "%s: command not found\n", args[0])
64+ }
5765
66+ err = syscall.Exec(path, args, os.Environ())
5867 if err != nil {
59− panic(err)
68+ fmt.Fprintf(os.Stderr, "failed to exec %s: %s\n", path, err)
69+ os.Exit(1)
6070 }
6171
6272}