Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions builtins/break/break.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ var Cmd = builtins.Command{
}

func run(_ context.Context, callCtx *builtins.CallContext, args []string) builtins.Result {
if len(args) > 0 && args[0] == "--help" {
if len(args) > 0 && (args[0] == "--help" || args[0] == "-h") {
callCtx.Outf("%s\n", helpText)
return builtins.Result{Code: 2}
return builtins.Result{}
Comment thread
thieman marked this conversation as resolved.
}
return loopctl.LoopControl(callCtx, "break", args)
}
4 changes: 2 additions & 2 deletions builtins/continue/continue.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ var Cmd = builtins.Command{
}

func run(_ context.Context, callCtx *builtins.CallContext, args []string) builtins.Result {
if len(args) > 0 && args[0] == "--help" {
if len(args) > 0 && (args[0] == "--help" || args[0] == "-h") {
callCtx.Outf("%s\n", helpText)
return builtins.Result{Code: 2}
return builtins.Result{}
Comment thread
thieman marked this conversation as resolved.
}
return loopctl.LoopControl(callCtx, "continue", args)
}
6 changes: 3 additions & 3 deletions builtins/help/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//
// Exit codes:
//
// 0 Success.
// 1 Unknown command or --help was requested.
// 0 Success or --help was requested.
// 1 Unknown command.
package help

import (
Expand Down Expand Up @@ -44,7 +44,7 @@ func registerFlags(fs *builtins.FlagSet) builtins.HandlerFunc {
return func(ctx context.Context, callCtx *builtins.CallContext, args []string) builtins.Result {
if *helpFlag {
printUsage(callCtx)
return builtins.Result{Code: 1}
return builtins.Result{}
Comment thread
thieman marked this conversation as resolved.
Comment thread
thieman marked this conversation as resolved.
}

// help <command> — show detailed help for a specific command.
Expand Down
2 changes: 1 addition & 1 deletion builtins/tests/help/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func TestHelpShowsCommandHelp(t *testing.T) {

func TestHelpFlagPrintsUsage(t *testing.T) {
stdout, _, code := runScript(t, "help --help", "", interpoption.AllowAllCommands().(interp.RunnerOption))
assert.Equal(t, 1, code)
assert.Equal(t, 0, code)
assert.Contains(t, stdout, "Usage: help")
assert.Contains(t, stdout, "Display help for builtin commands.")
}
Expand Down
12 changes: 12 additions & 0 deletions tests/scenarios/cmd/break/help_flag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# skip_assert_against_bash: true — intentional divergence from bash.
# Bash returns exit code 2 for "break --help"; rshell returns 0 per project
# convention (RULES.md: "When --help is passed: Set exit code 0 and return").
description: break --help prints usage and exits zero.
skip_assert_against_bash: true
input:
script: |+
break --help
expect:
stdout_contains: ["break: break [n]"]
stderr: ""
exit_code: 0
12 changes: 12 additions & 0 deletions tests/scenarios/cmd/break/help_flag_short.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# skip_assert_against_bash: true — intentional divergence from bash.
# Bash returns exit code 2 for "break -h"; rshell returns 0 per project
# convention (RULES.md: "When --help is passed: Set exit code 0 and return").
description: break -h prints usage and exits zero.
skip_assert_against_bash: true
input:
script: |+
break -h
expect:
stdout_contains: ["break: break [n]"]
stderr: ""
exit_code: 0
12 changes: 12 additions & 0 deletions tests/scenarios/cmd/continue/help_flag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# skip_assert_against_bash: true — intentional divergence from bash.
# Bash returns exit code 2 for "continue --help"; rshell returns 0 per project
# convention (RULES.md: "When --help is passed: Set exit code 0 and return").
description: continue --help prints usage and exits zero.
skip_assert_against_bash: true
input:
script: |+
continue --help
expect:
stdout_contains: ["continue: continue [n]"]
stderr: ""
exit_code: 0
12 changes: 12 additions & 0 deletions tests/scenarios/cmd/continue/help_flag_short.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# skip_assert_against_bash: true — intentional divergence from bash.
# Bash returns exit code 2 for "continue -h"; rshell returns 0 per project
# convention (RULES.md: "When --help is passed: Set exit code 0 and return").
description: continue -h prints usage and exits zero.
skip_assert_against_bash: true
input:
script: |+
continue -h
expect:
stdout_contains: ["continue: continue [n]"]
stderr: ""
exit_code: 0
5 changes: 4 additions & 1 deletion tests/scenarios/cmd/help/help_flag.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# skip_assert_against_bash: true — intentional divergence from bash.
# Bash returns exit code 2 for "help --help"; rshell returns 0 per project
# convention (RULES.md: "When --help is passed: Set exit code 0 and return").
description: Help --help prints usage.
skip_assert_against_bash: true
input:
Expand All @@ -6,4 +9,4 @@ input:
expect:
stdout_contains: ["Usage: help"]
stderr: ""
exit_code: 1
exit_code: 0
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# skip_assert_against_bash: true — intentional divergence from bash.
# Bash returns exit code 2 for "break --help"; rshell returns 0 per project
# convention (RULES.md: "When --help is passed: Set exit code 0 and return").
description: Break --help displays usage information.
skip_assert_against_bash: true
Comment thread
thieman marked this conversation as resolved.
input:
script: |+
for i in 1; do break --help; done
expect:
stdout: "break: break [n]\n Exit for, while, or until loops.\n \n Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing\n loops.\n \n Exit Status:\n The exit status is 0 unless N is not greater than or equal to 1.\n"
stderr: ""
exit_code: 2
exit_code: 0
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# skip_assert_against_bash: true — intentional divergence from bash.
# Bash returns exit code 2 for "continue --help"; rshell returns 0 per project
# convention (RULES.md: "When --help is passed: Set exit code 0 and return").
description: Continue --help displays usage information.
skip_assert_against_bash: true
input:
script: |+
for i in 1; do continue --help; done
expect:
stdout: "continue: continue [n]\n Resume for, while, or until loops.\n \n Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.\n If N is specified, resumes the Nth enclosing loop.\n \n Exit Status:\n The exit status is 0 unless N is not greater than or equal to 1.\n"
stderr: ""
exit_code: 2
exit_code: 0
Loading