`CTRL + <char>` leads to empty ```args```

#36 · closed · 9 comments

View on GitHub ↗

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

Comments

AndreRenaud

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?

andkae

> 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

AndreRenaud

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...

AndreRenaud

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.

andkae

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

AndreRenaud

All good - can you have a look at https://github.com/AndreRenaud/EmbeddedCLI/pull/38 and see if it behaves better?

andkae

yes 5d11f3332d8567b551d37cf066fb27c6ba63b96d avoids this behaviour. Thanks for changing.

AndreRenaud

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

andkae

Great work :) Thanks for changing.