Skip to content

Commit

Permalink
Merge pull request #59 from reeflective/dev
Browse files Browse the repository at this point in the history
Fix bugs in shell/exit commands
  • Loading branch information
maxlandon authored Nov 16, 2024
2 parents 5cd0c43 + 7943e10 commit dbc7d95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion commands/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func exitCtrlD() {
text, _ := reader.ReadString('\n')
answer := strings.TrimSpace(text)

if (answer == "Y") || (answer == "y") {
if strings.EqualFold(answer, "y") {
os.Exit(0)
}
}
5 changes: 4 additions & 1 deletion commands/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ func ExecuteShell() *cobra.Command {
Short: "Execute the remaining arguments with system shell",
DisableFlagParsing: true,
RunE: func(_ *cobra.Command, args []string) error {
if len(args) == 0 {
// Only at least one argument is needed, since the command
// itself is stripped before those args are passed as an array.
if len(args) < 1 {
return errors.New("command requires one or more arguments")
}

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

0 comments on commit dbc7d95

Please sign in to comment.