Skip to content

Commit dbc7d95

Browse files
authored
Merge pull request #59 from reeflective/dev
Fix bugs in shell/exit commands
2 parents 5cd0c43 + 7943e10 commit dbc7d95

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

commands/exit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func exitCtrlD() {
3434
text, _ := reader.ReadString('\n')
3535
answer := strings.TrimSpace(text)
3636

37-
if (answer == "Y") || (answer == "y") {
37+
if strings.EqualFold(answer, "y") {
3838
os.Exit(0)
3939
}
4040
}

commands/shell.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ func ExecuteShell() *cobra.Command {
1717
Short: "Execute the remaining arguments with system shell",
1818
DisableFlagParsing: true,
1919
RunE: func(_ *cobra.Command, args []string) error {
20-
if len(args) == 0 {
20+
// Only at least one argument is needed, since the command
21+
// itself is stripped before those args are passed as an array.
22+
if len(args) < 1 {
2123
return errors.New("command requires one or more arguments")
2224
}
2325

26+
// Above, the length of args is checked to be at least 2
2427
path, err := exec.LookPath(args[0])
2528
if err != nil {
2629
return err

0 commit comments

Comments
 (0)