implement status is-breakpoint

This implements `status is-breakpoint` that returns true if the current
shell prompt is displayed in the context of a `breakpoint` command.

This also fixes several bugs. Most notably making `breakpoint` a no-op if
the shell isn't interactive. Also, typing `breakpoint` at an interactive
prompt should be an error rather than creating a new nested debugging
context.

Partial fix for #1310
This commit is contained in:
Kurtis Rader
2017-06-19 21:05:34 -07:00
parent d234a1870b
commit bd299e96b2
15 changed files with 85 additions and 33 deletions

View File

@@ -20,6 +20,7 @@ enum status_cmd_t {
STATUS_IS_LOGIN = 1,
STATUS_IS_INTERACTIVE,
STATUS_IS_BLOCK,
STATUS_IS_BREAKPOINT,
STATUS_IS_COMMAND_SUB,
STATUS_IS_FULL_JOB_CTRL,
STATUS_IS_INTERACTIVE_JOB_CTRL,
@@ -38,6 +39,7 @@ const enum_map<status_cmd_t> status_enum_map[] = {
{STATUS_CURRENT_FUNCTION, L"current-function"},
{STATUS_CURRENT_LINE_NUMBER, L"current-line-number"},
{STATUS_IS_BLOCK, L"is-block"},
{STATUS_IS_BREAKPOINT, L"is-breakpoint"},
{STATUS_IS_COMMAND_SUB, L"is-command-substitution"},
{STATUS_IS_FULL_JOB_CTRL, L"is-full-job-control"},
{STATUS_IS_INTERACTIVE, L"is-interactive"},
@@ -237,6 +239,9 @@ int builtin_status(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
return STATUS_CMD_ERROR;
}
optind++;
} else {
streams.err.append_format(BUILTIN_ERR_INVALID_SUBCMD, cmd, argv[1]);
return STATUS_INVALID_ARGS;
}
}
@@ -315,6 +320,11 @@ int builtin_status(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
retval = !is_block;
break;
}
case STATUS_IS_BREAKPOINT: {
CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd)
retval = !is_breakpoint;
break;
}
case STATUS_IS_LOGIN: {
CHECK_FOR_UNEXPECTED_STATUS_ARGS(opts.status_cmd)
retval = !is_login;