mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-17 19:21:15 -03:00
builtin break/continue: support -h/--help argument
These are not generic builtins because we check whether they're inside a loop. There's no reason to not support "break -h" when we support "if -h" etc.; do that.
This commit is contained in:
@@ -19,7 +19,7 @@ Description
|
||||
|
||||
``break`` halts a currently running loop (*LOOP_CONSTRUCT*), such as a :doc:`for <for>` or :doc:`while <while>` loop. It is usually added inside of a conditional block such as an :doc:`if <if>` block.
|
||||
|
||||
There are no parameters for ``break``.
|
||||
The **-h** or **--help** option displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
@@ -15,6 +15,8 @@ Description
|
||||
|
||||
``continue`` skips the remainder of the current iteration of the current inner loop, such as a :doc:`for <for>` loop or a :doc:`while <while>` loop. It is usually added inside of a conditional block such as an :doc:`if <if>` statement or a :doc:`switch <switch>` statement.
|
||||
|
||||
The **-h** or **--help** option displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
||||
@@ -978,6 +978,13 @@ fn builtin_break_continue(
|
||||
let is_break = argv[0] == "break";
|
||||
let argc = argv.len();
|
||||
|
||||
let opts = HelpOnlyCmdOpts::parse(argv, parser, streams)?;
|
||||
|
||||
if opts.print_help {
|
||||
builtin_print_help(parser, streams, argv[0]);
|
||||
return Ok(SUCCESS);
|
||||
}
|
||||
|
||||
if argc != 1 {
|
||||
let error_message = wgettext_fmt!(BUILTIN_ERR_UNKNOWN, argv[0], argv[1]);
|
||||
builtin_print_help_error(parser, streams, argv[0], &error_message);
|
||||
|
||||
@@ -442,6 +442,15 @@ eval continue
|
||||
#CHECKERR: Error-message: continue: Not inside of loop
|
||||
#CHECKERR: Documentation for continue
|
||||
|
||||
break -h
|
||||
#CHECKERR: Documentation for break
|
||||
break --help
|
||||
#CHECKERR: Documentation for break
|
||||
$dyn_break -h
|
||||
#CHECKERR: Documentation for break
|
||||
continue -h
|
||||
#CHECKERR: Documentation for continue
|
||||
|
||||
# Test implicit cd. This should do nothing.
|
||||
./
|
||||
|
||||
|
||||
Reference in New Issue
Block a user