diff --git a/cli/src/connections.c b/cli/src/connections.c index 83a94010fb..c777ddd771 100644 --- a/cli/src/connections.c +++ b/cli/src/connections.c @@ -5837,6 +5837,9 @@ nmcli_editor_tab_completion (char *text, int start, int end) generator_func = gen_setting_names; else if (strcmp (prompt_tmp, EDITOR_PROMPT_PROPERTY) == 0) generator_func = gen_property_names; + else if ( g_str_has_suffix (rl_prompt, prompt_yes_no (TRUE, NULL)) + || g_str_has_suffix (rl_prompt, prompt_yes_no (FALSE, NULL))) + generator_func = gen_func_bool_values_l10n; else if (g_str_has_prefix (prompt_tmp, "nmcli")) { if (!strchr (prompt_tmp, '.')) { int level = g_str_has_prefix (prompt_tmp, "nmcli>") ? 0 : 1; @@ -6553,6 +6556,23 @@ is_connection_dirty (NMConnection *connection, NMRemoteConnection *remote) NM_SETTING_COMPARE_FLAG_EXACT); } +static gboolean +confirm_quit (void) +{ + char *answer; + gboolean want_quit = FALSE; + + answer = nmc_readline (_("The connection is not saved. " + "Do you really want to quit? %s"), + prompt_yes_no (FALSE, NULL)); + answer = answer ? g_strstrip (answer) : NULL; + if (answer && matches (answer, WORD_LOC_YES) == 0) + want_quit = TRUE; + + g_free (answer); + return want_quit; +} + /* * Submenu for detailed property editing * Return: TRUE - continue; FALSE - should quit @@ -6708,16 +6728,10 @@ property_edit_submenu (NmCli *nmc, case NMC_EDITOR_SUB_CMD_QUIT: if (is_connection_dirty (connection, *rem_con)) { - char *tmp_str; - do { - tmp_str = nmc_get_user_input (_("The connection is not saved. " - "Do you really want to quit? [y/n]\n")); - } while (!tmp_str); - if (matches (tmp_str, "yes") == 0) { + if (confirm_quit ()) { cmd_property_loop = FALSE; should_quit = TRUE; /* we will quit nmcli */ } - g_free (tmp_str); } else { cmd_property_loop = FALSE; should_quit = TRUE; /* we will quit nmcli */ @@ -7573,14 +7587,8 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t case NMC_EDITOR_MAIN_CMD_QUIT: if (is_connection_dirty (connection, rem_con)) { - char *tmp_str; - do { - tmp_str = nmc_get_user_input (_("The connection is not saved. " - "Do you really want to quit? [y/n]\n")); - } while (!tmp_str); - if (matches (tmp_str, "yes") == 0) + if (confirm_quit ()) cmd_loop = FALSE; /* quit command loop */ - g_free (tmp_str); } else cmd_loop = FALSE; /* quit command loop */ break;