Skip to content

Commit

Permalink
client: Add a no-op input handler
Browse files Browse the repository at this point in the history
Some shells seem to generate extra input while being redirected.
In those situations readline will complain with:
  readline: readline_callback_read_char() called with no handler!

Add a no-op input handler in non-interactive mode in order to keep
readline happy. The no-op input handler will be replaced with a
proper one if the command requires input.
  • Loading branch information
pfl committed Oct 7, 2013
1 parent b2199d0 commit 909990b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions client/input.c
Expand Up @@ -229,6 +229,16 @@ void __connmanctl_command_mode(void)
rl_attempted_completion_function = complete_command;
}

static void no_handler(char *input)
{
}

static void no_handler_mode(void)
{
rl_callback_handler_install("", no_handler);
rl_attempted_completion_function = NULL;
}

int __connmanctl_input_init(int argc, char *argv[])
{
char *help[] = {
Expand Down Expand Up @@ -264,6 +274,7 @@ int __connmanctl_input_init(int argc, char *argv[])

} else {
interactive = false;
no_handler_mode();

if (strcmp(argv[1], "--help") == 0 ||
strcmp(argv[1], "-h") == 0)
Expand All @@ -282,11 +293,11 @@ int __connmanctl_input_init(int argc, char *argv[])

g_source_remove(source);

if (interactive == true) {
if (interactive)
__connmanctl_monitor_completions(NULL);
rl_callback_handler_remove();
rl_message("");
}

rl_callback_handler_remove();
rl_message("");

dbus_connection_unref(connection);
if (main_loop)
Expand Down

0 comments on commit 909990b

Please sign in to comment.