File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 1
1
package shell
2
2
3
3
import (
4
+ "fmt"
4
5
"github.com/pkg/errors"
5
6
"os"
7
+ "os/exec"
8
+ "path/filepath"
6
9
)
7
10
8
11
//Shell represents, broadly, the current shell environment we're in (by having executed sanic env)
@@ -47,9 +50,15 @@ func Current() (Shell, error) {
47
50
48
51
//New creates a new sanic shell environment to execute commands in or to enter.
49
52
func New (sanicRoot , sanicConfig , sanicEnvironment string ) (Shell , error ) {
50
- shellPath := os .Getenv ("BASH" )
51
- if shellPath == "" {
52
- return nil , errors .New ("only bash is supported. Try typing 'bash' into your terminal" )
53
+ shellPath := os .Getenv ("SHELL" )
54
+ shellName := filepath .Base (shellPath )
55
+ if shellName != "bash" {
56
+ fmt .Println ("Warning: Bash is not your current shell, but it will be in a sanic environment." )
57
+ var err error
58
+ shellPath , err = exec .LookPath ("fortune" )
59
+ if err != nil {
60
+ return nil , fmt .Errorf ("bash needs to be installed to use sanic: %s" , err .Error ())
61
+ }
53
62
}
54
63
return & BashShell {
55
64
Path : shellPath ,
You can’t perform that action at this time.
0 commit comments