Skip to content

CTRL + <char> leads to empty args #36

Closed

Description

@andkae

Hi Andre,

i played a little more around with EmbeddedCLI and if i use a control sequence similar to CTRL + r for searching it messes the cli up. For instance if i enter:

CTRL+x CTRL+x CTRL+x

i got following result:

POSIX>   
Got 3 args
Arg 0/3: ''
Arg 1/3: ''
Arg 2/3: ''

If i use now the arrow up and backspace, following happens to the shell:

POSI

I can take a look later, now it only to log the behaviour.

Thanks.

BR,
Andreas

Activity

  1. AndreRenaud commented on Jan 28, 2026

    @AndreRenaud
    Owner

    I don't entirely get what you mean. Do you mean Ctrl-X <space> Ctrl-X <space> Ctrl-X ? I don't see that doing anything odd for me. Perhaps I'm missing the sequence?

    If you can throw a (failing) test cast together, that'd be great?

  2. andkae commented on Jan 28, 2026

    @andkae
    ContributorAuthor

    Do you mean Ctrl-X <space> Ctrl-X <space> Ctrl-X

    Yes you type into the shell CTRL-x followed by an followed by CTRL-x if i now push enter i get as response some empty arguments Arg 0/3: '' and so on.

    If you can throw a (failing) test cast together, that'd be great?

    There i can try to fill in such a sequence

  3. changed the title [-]`CTRL + <char>` messes history up[/-] [+]`CTRL + <char>` messes cursor position up[/+] on Jan 28, 2026
  4. AndreRenaud commented on Jan 28, 2026

    @AndreRenaud
    Owner

    Ok. I don't see the prompt being messed up, but I do see the args being wrong. The issue is that it's inserting the Ctrl-x as a 'normal' character - it doesn't interpret it. I'm not 100% sure if that's wrong or not - it's not unreasonable to just insert any character we see that we're not interpreting unchanged into the output stream. But dropping non-ascii wouldn't be a bad idea either...

  5. AndreRenaud commented on Jan 28, 2026

    @AndreRenaud
    Owner

    A change like this might fix it, but would mean that any extended UTF-8 characters would get dropped. I don't know if they work anyway.

    diff --git a/embedded_cli.c b/embedded_cli.c
    index 6313a20..d7ef8fd 100644
    --- a/embedded_cli.c
    +++ b/embedded_cli.c
    @@ -399,7 +399,8 @@ bool embedded_cli_insert_char(struct embedded_cli *cli, char ch)
                 cli_putchar(cli, '\n', true);
                 break;
             default:
    -            if (ch > 0)
    +            // Printable characters
    +            if (ch >= ' ' && ch <= '~')
                     embedded_cli_insert_default_char(cli, ch);
             }
         }
    

    Perhaps just changing if (ch > 0) to if (ch >= ' ') might be enough - drop the CTRL-? stuff, but keep everything else.

  6. andkae commented on Jan 28, 2026

    @andkae
    ContributorAuthor

    No stress, we need not a fast solution, i noticed only this behaviour and like to note it :)

  7. changed the title [-]`CTRL + <char>` messes cursor position up[/-] [+]`CTRL + <char>` leads to empty ```args```[/+] on Jan 28, 2026
  8. AndreRenaud commented on Jan 28, 2026

    @AndreRenaud
    Owner

    All good - can you have a look at #38 and see if it behaves better?

  9. andkae commented on Jan 28, 2026

    @andkae
    ContributorAuthor

    yes 5d11f33 avoids this behaviour. Thanks for changing.

  10. AndreRenaud commented on Jan 28, 2026

    @AndreRenaud
    Owner

    Thanks. I snuck in a few other minor tweaks that I noticed, but I'll merge it all together.

  11. andkae commented on Jan 28, 2026

    @andkae
    ContributorAuthor

    Great work :) Thanks for changing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions